mf2_printer 0.1.2

Printer for MessageFormat 2
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 44.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.24 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lucacasonato/mf2-tools
    9 1 8
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lucacasonato nicolo-ribaudo

mf2_printer

The mf2_printer crate provides a pretty-printer for the Message Format 2 syntax. It can pretty-print an AST representing the Message Format 2 syntax back into the human-readable MessageFormat 2 syntax.

Use the mf2_parser crate to parse a MessageFormat 2 string into an AST.

Usage

Add this to your Cargo.toml:

[dependencies]
mf2_printer = "0.1"

Then you can parse a string like this:

use mf2_parser::parse;
use mf2_printer::print;

let (ast, diagnostics, source_text_info) = parse("Hello, {$name}!");
if !diagnostics.is_empty() {
  panic!("Failed to parse message: {:?}", diagnostics);
}

let pretty_printed = print(&ast, None);
println!("Pretty-printed: {}", pretty_printed);

License

This project is licensed under GPL-3.0-or-later.