markdownfmt icon indicating copy to clipboard operation
markdownfmt copied to clipboard

Paragraphs in nested items are not formatted correctly

Open karelbilek opened this issue 4 years ago • 6 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

karelbilek avatar Feb 26 '20 05:02 karelbilek

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

karelbilek avatar Feb 26 '20 05:02 karelbilek

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

karelbilek avatar Feb 26 '20 05:02 karelbilek

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?

karelbilek avatar Feb 26 '20 05:02 karelbilek

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)

karelbilek avatar Feb 26 '20 05:02 karelbilek

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

karelbilek avatar Feb 26 '20 06:02 karelbilek

I think it's the same issue as https://github.com/shurcooL/markdownfmt/issues/54 - that is, it behaves correctly and predictably if I use tabs and not spaces. But it does weird things when I use spaces.

karelbilek avatar Feb 26 '20 09:02 karelbilek

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

karelbilek avatar May 02 '24 11:05 karelbilek