executablebooks / markdown-it-py

Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed. Now in Python!
https://markdown-it-py.readthedocs.io
MIT License
662 stars 68 forks source link

`_https://example.com/a_` not parsed correctly #317

Open nschloe opened 7 months ago

nschloe commented 7 months ago

Describe the bug

MWE:

from markdown_it import MarkdownIt
from markdown_it.tree import SyntaxTreeNode

md = MarkdownIt("gfm-like")

# okay:
tokens = md.parse("_https://example.com_")
print(SyntaxTreeNode(tokens).pretty())

# bug:
tokens = md.parse("_https://example.com/a_")
print(SyntaxTreeNode(tokens).pretty())

Output:

<root>
  <paragraph>
    <inline>
      <em>
        <link href='https://example.com'>
          <text>
<root>
  <paragraph>
    <inline>
      <text>
      <link href='https://example.com/a_'>
        <text>

Note how the underscore is incorrectly included in the last link.

Reproduce the bug

See above.

List your environment

No response

chrisjsewell commented 7 months ago

See https://github.com/executablebooks/markdown-it-py/issues/316#issuecomment-1862367930

tsutsu3 commented 6 months ago

https://github.com/markdown-it/markdown-it/issues/518 https://github.com/markdown-it/markdown-it/issues/38

tsutsu3 commented 6 months ago

linkify-it-py works the same as linkify-it as specified. This is not a bug.

The solution is to enclose it in <>. For example, _<https://example.com>_, _<https://example.com/a>_.

See markdown-it demo