fn rebuild_rendered_text(text: &str) -> RichText {
    let mut current_pos = 0;
    let mut builder = RichTextBuilder::new();
    let mut tag_stack = Vec::new();

    let parser = Parser::new_ext(text, Options::ENABLE_STRIKETHROUGH);
    for event in parser {
        match event {
            ParseEvent::Start(tag) => {
                tag_stack.push((current_pos, tag));
            }
            ParseEvent::Text(txt) => {
                builder.push(&txt);
                current_pos += txt.len();
            }
            ParseEvent::End(end_tag) => {
                let (start_off, tag) = tag_stack
                    .pop()
                    .expect("parser does not return unbalanced tags");
                assert_eq!(end_tag, tag, "mismatched tags?");
                add_attribute_for_tag(
                    &tag,
                    builder.add_attributes_for_range(start_off..current_pos),
                );
                if add_newline_after_tag(&tag) {
                    builder.push("\n\n");
                    current_pos += 2;
                }
            }
            ParseEvent::Code(txt) => {
                builder.push(&txt).font_family(FontFamily::MONOSPACE);
                current_pos += txt.len();
            }
            ParseEvent::Html(txt) => {
                builder
                    .push(&txt)
                    .font_family(FontFamily::MONOSPACE)
                    .text_color(BLOCKQUOTE_COLOR);
                current_pos += txt.len();
            }
            ParseEvent::HardBreak => {
                builder.push("\n\n");
                current_pos += 2;
            }
            _ => (),
        }
    }
    builder.build()
}
/// Parse a markdown string and generate a `RichText` object with
/// the appropriate attributes.
Parse a markdown string and generate a `RichText` object with
the appropriate attributes.
Parse a markdown string and generate a ` RichText ` object with the appropriate attributes .
fn rebuild_rendered_text(text: &str) -> RichText {
    let mut current_pos = 0;
    let mut builder = RichTextBuilder::new();
    let mut tag_stack = Vec::new();
    let parser = Parser::new_ext(text, Options::ENABLE_STRIKETHROUGH);
    for event in parser {
        match event {
            ParseEvent::Start(tag) => {
                tag_stack.push((current_pos, tag));
            }
            ParseEvent::Text(txt) => {
                builder.push(&txt);
                current_pos += txt.len();
            }
            ParseEvent::End(end_tag) => {
                let (start_off, tag) = tag_stack
                    .pop()
                    .expect("parser does not return unbalanced tags");
                assert_eq!(end_tag, tag, "mismatched tags?");
                add_attribute_for_tag(
                    &tag,
                    builder.add_attributes_for_range(start_off..current_pos),
                );
                if add_newline_after_tag(&tag) {
                    builder.push("\n\n");
                    current_pos += 2;
                }
            }
            ParseEvent::Code(txt) => {
                builder.push(&txt).font_family(FontFamily::MONOSPACE);
                current_pos += txt.len();
            }
            ParseEvent::Html(txt) => {
                builder
                    .push(&txt)
                    .font_family(FontFamily::MONOSPACE)
                    .text_color(BLOCKQUOTE_COLOR);
                current_pos += txt.len();
            }
            ParseEvent::HardBreak => {
                builder.push("\n\n");
                current_pos += 2;
            }
            _ => (),
        }
    }
    builder.build()
}
fn rebuild_rendered_text ( text : & str ) -> RichText { let mut current_pos = 0 ; let mut builder = RichTextBuilder :: new ( ) ; let mut tag_stack = Vec :: new ( ) ; let parser = Parser :: new_ext ( text , Options :: ENABLE_STRIKETHROUGH ) ; for event in parser { match event { ParseEvent :: Start ( tag ) => { tag_stack . push ( ( current_pos , tag ) ) ; } ParseEvent :: Text ( txt ) => { builder . push ( & txt ) ; current_pos += txt . len ( ) ; } ParseEvent :: End ( end_tag ) => { let ( start_off , tag ) = tag_stack . pop ( ) . expect ( " " ) ; assert_eq ! ( end_tag tag " " ) ; add_attribute_for_tag ( & tag , builder . add_attributes_for_range ( start_off .. current_pos ) , ) ; if add_newline_after_tag ( & tag ) { builder . push ( " \n \n " ) ; current_pos += 2 ; } } ParseEvent :: Code ( txt ) => { builder . push ( & txt ) . font_family ( FontFamily :: MONOSPACE ) ; current_pos += txt . len ( ) ; } ParseEvent :: Html ( txt ) => { builder . push ( & txt ) . font_family ( FontFamily :: MONOSPACE ) . text_color ( BLOCKQUOTE_COLOR ) ; current_pos += txt . len ( ) ; } ParseEvent :: HardBreak => { builder . push ( " \n \n " ) ; current_pos += 2 ; } _ => ( ) , } } builder . build ( ) }
Parse a markdown string and generate a `RichText` object with
the appropriate attributes.
Parse a markdown string and generate a ` RichText ` object with the appropriate attributes .
text
&str
text
&str