JetBrains / markdown

Markdown parser written in kotlin
Apache License 2.0
706 stars 78 forks source link

CRLF line endings are not parsed correctly. #49

Open ajalt opened 4 years ago

ajalt commented 4 years ago

The CommmonMark spec requires CR and CRLF to be supported as line endings, but this library parses CRLF incorrectly. For example:

MarkdownParser(CommonMarkFlavourDescriptor()).buildMarkdownTreeFromString("a \r\nb")

parses as:

Markdown:PARAGRAPH
  Markdown:TEXT 'a'
  Markdown:BR '·␍'
  Markdown:EOL '␊'
  Markdown:TEXT 'b'

and renders as:

<body><p>a<br />
b</p></body>
altavir commented 2 years ago

Got the same problem. Because of this, paragraphs are parsed incorretly on Windows.

SPC-code commented 1 year ago

Could you please fix this? We use the library in https://github.com/SciProgCentre/snark site byuilder and incorrect render of Markdown produced on Windows is annoying.

tjpalmer commented 1 year ago

This is a huge failing of this library today. I can search and replace line endings in advance, but then the need to map source ranges back becomes a huge bother.