RobertDober / earmark_parser

The Markdown to AST part of Earmark.
Apache License 2.0
68 stars 26 forks source link

Inconsistent `li` output when list item contains a `|` inside of a code block #147

Open zachallaun opened 7 months ago

zachallaun commented 7 months ago
example = """
* `1 2`
* `3 | 4`
* `5 6`
"""

EarmarkParser.as_ast(example)
#=>
{:ok,
 [
   {"ul", [],
    [
      {"li", [], [{"code", [{"class", "inline"}], ["1 2"], %{line: 1}}], %{}},
      {"li", [],
       [
         {"p", [], [{"code", [{"class", "inline"}], ["3 | 4"], %{line: 3}}],
          %{}}
       ], %{}},
      {"li", [], [{"code", [{"class", "inline"}], ["5 6"], %{line: 3}}], %{}}
    ], %{}}
 ], []}

I noticed this while browsing the docs for Erlang's new json module here; some list items were wrapped in a <p>, while others weren't. I was able to shrink the test case down enough to find that the | was the culprit.

RobertDober commented 7 months ago

Thank you for this report

RobertDober commented 6 months ago

Thank you again for this report, unfortunately the easy fix is not backwards compatible, as we resolve inline code later when joining lines together.

So this will need to wait for 1.5 and the peg parser I am afraid.

Keeping this open, but ETA is very uncertain.