Skip to content

Google Docs exported RTF not being parsed correctly #17

@craigchiang

Description

@craigchiang

Hi! I was trying to implement the parser in my program and was testing with RTF files exported from different sources (MS word, Google Docs,...). I found the parser seems to be ignoring the spaces between words from Google Docs exported ones (Sample Text.rtf.zip). When printing out it'd be: Loremipsumodoramet, consectetueradipiscingelit. ..., but it should be Lorem ipsum odor amet, consectetuer adipiscing elit. ....

Also attaching how it looks like in my local text editor(Mac) which has the correct spaces: Image

Code I'm using to parse:

fn main() {
    let rtf_text = include_str!("Sample Text.rtf");
    let tokens = Lexer::scan(rtf_text).expect("Invalid RTF content");
    let doc = Parser::new(tokens).parse();
    println!("{}", doc.unwrap().get_text());
}

Would there be a way that I could preserve the spaces in this case?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions