Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing inline code span with a single newline loses the newline #655

Open
mgeisler opened this issue Jun 3, 2023 · 3 comments
Open

Parsing inline code span with a single newline loses the newline #655

mgeisler opened this issue Jun 3, 2023 · 3 comments

Comments

@mgeisler
Copy link
Collaborator

mgeisler commented Jun 3, 2023

According to the Commonmark playground and the Commonmark spec, the string

"`\n`"

should be parsed into

[
  Start(Paragraph)
  Code(" ")
  End(Paragraph)
]

since newline is normalized as a space.

However, when parsing the string with pulldown-cmark 0.9.3, I get

[
  Start(Paragraph)
  Code("")
  End(Paragraph)
]

instead. I used this little test program:

use pulldown_cmark::{Event, Parser};

fn main() {
    let text = "`\n`";
    eprintln!("{text:?} -> [");
    for event in Parser::new(&text) {
        match event {
            Event::Code(code) => eprintln!("  Code({:?})", &*code),
            _ => eprintln!("  {event:?}"),
        }
    }
    eprintln!("]");
}

Note that "`foo\n`" and "`\nfoo`" are parsed correctly with a trailing and leading space, respectively.

I found this while trying round-trip strings through pulldown-cmark-to-cmark (Byron/pulldown-cmark-to-cmark#55).

@mgeisler mgeisler changed the title Parsing ` "\n" ` loses the newline Parsing inline code span with a single newline loses the newline Jun 3, 2023
@Martin1887 Martin1887 added the bug label Jun 4, 2023
@Martin1887
Copy link
Collaborator

Martin1887 commented Jun 4, 2023

I will check this for the next release, thanks for reporting it.

@mgeisler
Copy link
Collaborator Author

mgeisler commented Jun 4, 2023

I will check this for the next release, thanks for reporting it.

Thanks for taking a look!

@Martin1887
Copy link
Collaborator

Check if fixed by #776.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants