HaxeFoundation / haxe-markdown

A Markdown parser in Haxe.
MIT License
63 stars 24 forks source link

BlockParser: update RE_CODE to match CommonMark spec better #39

Closed joshtynjala closed 11 months ago

joshtynjala commented 11 months ago

The info string following a code fence is allowed to contain any character except backtick (`)

Source: https://spec.commonmark.org/0.30/#fenced-code-blocks

Example that this fixes from the Haxe language server:

```haxe.type
TextField
Simn commented 11 months ago

Huh... This seems really strange to me from a parsing perspective, but if it's the spec then I guess we should adhere to it.

I don't understand how this related to your example though, that just looks like a normal code block to me.

joshtynjala commented 11 months ago

I don't understand how this related to your example though, that just looks like a normal code block to me.

In my example, it would not recognize the . character as a valid part of the info string. Besides letters and numbers \w allows only an underscore (_) as a special character.

I recall separately observing that it would not recognize an info string containing - character either.

joshtynjala commented 11 months ago

I see in the README that haxe-markdown is ported from dart-markdown. It's worth mentioning that dart-markdown is now using [^]*` too:

https://github.com/dart-lang/markdown/blob/3774ad02e812ceeb32ad0d98a987b0acffa63cf6/lib/src/patterns.dart#L26C52-L26C57

Simn commented 11 months ago

Makes sense, thanks!