miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
841 stars 119 forks source link

Inline code for tilde invalidly parsed as code block start #91

Closed liushilive closed 3 years ago

liushilive commented 5 years ago

The sample code

* `~` home

analytical result

image

pbodnar commented 3 years ago

This seems easy to fix - the regex pattern needs to accept either just backticks, or just tildes. The linked fix seems a little bit more complicated though...

pbodnar commented 3 years ago

OK, so I fixed this in the master.

Note that there is still another bug, possibly also in the linked patch from @chrisjsewell, which incorrectly rejects a fenced code block like this:

~~~ lang myextra_params_containing_~
code block
~~~

GitHub renders this correctly:

code block

... because https://spec.commonmark.org/0.30/#info-string clearly states that:

Info strings for tilde code blocks can contain backticks and tildes

chrisjsewell commented 3 years ago

Heya, I would just note that I moved on from mistletoe, since it didn't quite have the features I needed, and went on to create https://github.com/executablebooks/markdown-it-py (and port for the widely used markdown-it)

pbodnar commented 3 years ago

Hi Chris, yeah, I've already noticed very well when doing triage of opened issues and PRs here, and I wish you good luck with your project. :)