pragdave / earmark

Markdown parser for Elixir
Other
859 stars 135 forks source link

Failed to find closing tag when it's trailing after text in another line #465

Closed lobo-tuerto closed 1 year ago

lobo-tuerto commented 1 year ago

Hello,

I have tried parsing this Markdown:

# Some title

<small>Some text  
**Hello**  
From some date – Current</small>

Which is loaded by Elixir as:

"# Some title\n\n<small>Some text  \n**Hello**  \nFrom some date – Current</small>\n"

But, when passed to Earmark it complains with:

{:error,
 "<h1>\nSome title</h1>\n<small>\n  Some text    **Hello**  \nFrom some date – Current</small></small>\n",
 [{:warning, 3, "Failed to find closing <small>"}]}

I'm migrating this code from an old JavaScript app into Elixir.
Used markdown-it to parse the file back there with no issues.

The problem goes away if I pull the closing tag to the next line, but wonder why that is needed in the first place. :thinking:

Is this expected?

RobertDober commented 1 year ago

This is expected behavior you need to close tags in a new line https://github.com/RobertDober/earmark_parser#html-blocks I guess it might not be clear from the docs that the parsing is documented in the EarmarkParser

PRs welcome ;)

RobertDober commented 1 year ago

BTW if I ever get the time to work on 1.5 HTML will be parsed recursevily but that is a big if

lobo-tuerto commented 1 year ago

Fair enough, thanks for explanation. :)