shurcooL/markdownfmt

Paragraphs in nested items are not formatted correctly

karelbilek opened this issue · 7 comments

Input:

1. foo
    1.  A paragraph
        with two lines.

        Continues
    2.           Second
    3. Third

Expected:

1.      foo

        1.      A paragraph with two lines.

                Continues
        2.      Second
        3.      Third

Actual behaviour:

1.      foo

        1.      A paragraph with two lines.

        Continues

        1.      Second
        2.      Third

This might be actually a parser (blackfriday) error, not sure.

I am taking CommonMark as the standard, with CommonMark, the input and expected are equivalent, the actual obviously not

Oh, now I realized the "continues" is interpreted as a code block, NOT as paragraph. That's different from CommonMark, that interprets it as a paragraph.

...I think

I really don't understand how is markdownfmt handling paragraphs inside lists. It makes no sense to me.

This does not format as a paragraph inside list

1. A paragraph

   is not

This does format as a paragraph inside list, even when the only difference is one more space.

1.   A paragraph

     is? Maybe?

The previous comment seems to be a blackfriday issue (blackfriday does not parse correctly)

The first issue seems to be markdownfmt issue (blackfriday parses the AST correctly, but markdownfmt does not print correctly)

But maybe not. Hard to debug, either way it's confusing

I think it's the same issue as #54 - that is, it behaves correctly and predictably if I use tabs and not spaces. But it does weird things when I use spaces.

I have "solved" this by forking the repo here (I'm not in the committer list as I used work email or something back then) and rewriting it to a different markdown parser (blackfriday -> goldmark)

https://github.com/Kunde21/markdownfmt

which now died too. Closing this though; the real solution is to use a different markdown parser, as I did in the forked repo