commonmark / commonmark-spec

CommonMark spec, with reference implementations in C and JavaScript
http://commonmark.org
Other
4.89k stars 316 forks source link

HTML comment tags break Markdown list indentation. #741

Open RokeJulianLockhart opened 1 year ago

RokeJulianLockhart commented 1 year ago
  1. To reproduce

    0. placeholder
    
        text
    
    0. placeholder
    
        text
    
    0. placeholder
    
        text
    
        0. placeholder
    
            text
    
        0. placeholder
    
            text
    
        0. placeholder
    
            text
    
            0. placeholder
    
                text
    
            0. placeholder
    
                text
    
            0. placeholder
    
                text
    
    0. placeholder
    
        text
    
    <!--
    
    0. placeholder
    
        text
    
    -->
    
    0. placeholder
    
        text
    
        0. placeholder
    
            text
    
        <!--
    
        0. placeholder
    
            text
    
        -->
    
        0. placeholder
    
            text
    
            0. placeholder
    
                text
    
            <!--
    
            0. placeholder
    
                text
    
            -->
    
            0. placeholder
    
                text

    (scroll) produces

    image

    in https://github.com/microsoft/vscode/issues/186232#issue-1775755236, which is obviously wrong.

  2. Alternatives

    I can't use

    <!--- -->

    (per https://stackoverflow.com/a/4829998/9731176) since https://github.com/microsoft/vscode/ doesn't render them using whatever https://github.com/commonmark/commonmark-spec/ -compliant engine it uses.

  3. Origin

    Due to https://talk.commonmark.org/t/html-comment-tags-break-markdown-list-indentation/4459/2?u=rokejulianlockhart, reported here.

wooorm commented 1 year ago

This is something people depend on to break adjacent lists (with CM you can now also do that by using a different bullet, as in . or ), but not all other markdown flavors support that)

vassudanagunta commented 1 year ago

The current user expectation is that block-level HTML content participates in the container hierarchy like any other block element. For example, an unindented HTML table is expected to be placed in the document root container, interrupting any preceding list just as the unindented HTML comment above does.

The OP's requested behavior would require special-casing HTML comments.

Not to mention upgrading HTML's role in Markdown, which I don't think is a good idea and goes against both the original and current intent.