tools icon indicating copy to clipboard operation
tools copied to clipboard

`ExtensionSet.gitHubFlavored` leads to incorrect parsing of `"a\n-"`

Open w568w opened this issue 6 months ago • 2 comments

(This issue is a copy of #1953, which was created when package:markdown label was unavailable.)

Problem

If UnorderedListWithCheckboxSyntax precedes SetextHeaderSyntax in BlockParser's blockSyntaxes (as is the case when ExtensionSet.gitHubFlavored is enabled, due to its inclusion of UnorderedListWithCheckboxSyntax), the following text will be rendered as an empty list item:

I am paragraph
-

Actual Output

I am paragraph is ignored, producing an empty list item, as follows:

Expected Output

I am paragraph should be rendered as a SETEXT-style heading. Check:

https://spec.commonmark.org/dingus/?text=I%20am%20paragraph%0A-

Minimal Reproducible Example

import 'package:markdown/markdown.dart' as md;

void main() {
  final md.Document document = md.Document(
    blockSyntaxes: [
      const md.UnorderedListSyntax(), // <-- This line breaks the case
    ],
  );
  final List<md.Node> astNodes = document.parse("I am paragraph\n-");
  print((astNodes[0] as md.Element).tag); // should print: h2; actual print: ul
}

w568w avatar Jun 07 '25 05:06 w568w

Concur, making it a header is what GitHub does.

Banana Banana

Apricot Apricot

Multiple unindented lines followed by a line of only =s for H1 or -s for H2. including just one - or =.

lrhn avatar Jun 10 '25 07:06 lrhn

Is there anyone working on this? If not, I'll try to figure out some workaround…

w568w avatar Oct 11 '25 08:10 w568w