Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gfm-like is too greedy when it comes to links #316

Open
nschloe opened this issue Nov 28, 2023 · 3 comments
Open

gfm-like is too greedy when it comes to links #316

nschloe opened this issue Nov 28, 2023 · 3 comments
Labels
bug Something isn't working plugins Plugin specific issues

Comments

@nschloe
Copy link

nschloe commented Nov 28, 2023

Describe the bug

MWE:

from markdown_it import MarkdownIt
from markdown_it.tree import SyntaxTreeNode

md = MarkdownIt("gfm-like")
tokens = md.parse("74.78.Fk")

print(SyntaxTreeNode(tokens).pretty())

Output:

<root>
  <paragraph>
    <inline>
      <link href='http://74.78.Fk'>
        <text>

Problem: "74.78.Fk" is not a link.

This problem doesn't occur with md = MarkdownIt()

Reproduce the bug

See above.

List your environment

markdown-it --version
markdown-it-py [version 3.0.0]

This is on Python 3.11.

Tip for devs: Add a --show-env parameter to markdown-it which shows all relevant packages and versions in one go.

@nschloe nschloe added the bug Something isn't working label Nov 28, 2023
Copy link

welcome bot commented Nov 28, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@chrisjsewell
Copy link
Member

Heya, yeh for this and #317 I would note that the parsing is using https://github.com/tsutsu3/linkify-it-py, and perhaps bugs that should be reported there, but also maybe just a difference with the parsing logic of GFM.

In https://github.com/markdown-it-rust/markdown-it-plugins.rs, which is then utilised in https://github.com/chrisjsewell/markdown-it-pyrs, I actually implemented parsing logic "faithful" to GFM.
So, if someone wants to port that here 😅

@tsutsu3
Copy link
Contributor

tsutsu3 commented Dec 23, 2023

linkify-it-py behaves the same as linkify-it as per the specification.
It is not a bug that it is linked.

.fk is the country code top-level domain (ccTLD) for the Falkland Islands.
Therefore, it is automatically linked.
If you do not want it to be linked, escape it as 74.78\.Fk.

See markdown-it demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugins Plugin specific issues
Projects
None yet
Development

No branches or pull requests

3 participants