enriched-text

Rust parser for text/enriched as defined by rfc1523
git clone git://git.alexwennerberg.com/enriched-text
Log | Files | Refs | LICENSE

commit e200316f30885cec99aef646de8a5043a9c191b2
parent bc5da8514053115e8889b59d6fb995cf0d8ab48f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun,  9 Jan 2022 08:50:27 -0800

Add plaintext example

Diffstat:
Aexamples/plain_text.rs | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/examples/plain_text.rs b/examples/plain_text.rs @@ -0,0 +1,14 @@ +use enriched_text::{EnrichedTextParser, Token}; + +fn main() { + let input = "Dear world--\r\nHello! 😋 Let's be <bold>bold</bold><<>><<>>\r\n\r\nlove, Alex"; + let parser = EnrichedTextParser::new(&input.as_bytes()); + let mut output = String::new(); + for t in parser { + match t { + Token::Text(a) => output.push_str(std::str::from_utf8(&a).unwrap()), + _ => {} + } + } + println!("{}", output); +}