2 releases

0.1.1 Oct 13, 2024
0.1.0 Oct 13, 2024

#3 in #valid-utf-8

Download history 1/week @ 2026-01-01 35/week @ 2026-01-08 31/week @ 2026-01-15 14/week @ 2026-01-22 28/week @ 2026-01-29 42/week @ 2026-02-05 89/week @ 2026-02-12 19/week @ 2026-02-19 75/week @ 2026-02-26 127/week @ 2026-03-05 13/week @ 2026-03-12 123/week @ 2026-03-19 108/week @ 2026-03-26 96/week @ 2026-04-02 103/week @ 2026-04-09

434 downloads per month
Used in mf2_printer

GPL-3.0-or-later

115KB
3.5K SLoC

mf2_parser

The mf2_parser crate provides a parser for the Message Format 2 syntax. It can parse any sequence of Unicode scalar values (valid UTF-8) into an AST representing the Message Format 2 syntax. The parser has very strong error recovery, so it can parse even very broken or incomplete input (like is common in editors).

Use the mf2_printer crate to pretty-print the AST back into the human-readable MessageFormat 2 syntax.

Usage

Add this to your Cargo.toml:

[dependencies]
mf2_parser = "0.1"

Then you can parse a string like this:

use mf2_parser::parse;

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

println!("AST: {:?}", ast);

License

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

No runtime deps