mf2_printer

Crates.iomf2_printer
lib.rsmf2_printer
version0.1.2
sourcesrc
created_at2024-10-13 15:31:39.798354
updated_at2024-10-13 15:32:43.860164
descriptionPrinter for MessageFormat 2
homepage
repositoryhttps://github.com/lucacasonato/mf2-tools
max_upload_size
id1407426
size44,782
Luca Casonato (lucacasonato)

documentation

README

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.

Commit count: 148

cargo fmt