Kryptos-FR / markdig.wpf

A WPF library for xoofx/markdig https://github.com/xoofx/markdig
MIT License
160 stars 52 forks source link

[Bug] (MarkdownViewer Control) Markdown content cannot have 0 as starting index for numbered lists #34

Closed chaojian-zhang closed 5 years ago

chaojian-zhang commented 5 years ago

The Markdown property of MarkdownViewer control seem not able to have 0 in a numbered list. An ArgumentException will be thrown saying 0 is not a valid StartIndex.

I am not sure whether this is related to MarkdownPipelineBuilder or I need to enable some UseSupportedExtensions()?

Exception

VS Setup: MarkdigWPFNumberList.zip

Kryptos-FR commented 5 years ago

As far as the commonmark specification goes, ordered list must start with 1.

Source: https://spec.commonmark.org/0.29/#ordered-list-marker

chaojian-zhang commented 5 years ago

I checked the spec and think the line "An ordered list marker is a sequence of 1–9 arabic digits (0-9), followed by either a . character or a ) character." clearly allows it.

Also see this discussion.

Thanks.

Kryptos-FR commented 5 years ago

I guess you misunderstand the spec. It clearly states that it must start with 1. That's what sequence 1-9 means. And later in the paragraph it is even more explicit: the start number must be 1.

In any case, markdig.wpf relies on what the markdig library parses. So if you think it is a bug, you should open an issue there.

But as can be seen in the babelmark benchmark, all commonmark-complying implementations don't support 0 as a starting index.

Final note, this exception happens in WPF (PresentationFramework) implementation of List (in namespace System.Windows.Documents), so there is nothing I can do about it unfortunately: