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

Wiki links recognized as markdown links in todo tasks #774

Closed
jayemar opened this issue Jul 13, 2023 · 3 comments
Closed

Wiki links recognized as markdown links in todo tasks #774

jayemar opened this issue Jul 13, 2023 · 3 comments

Comments

@jayemar
Copy link

jayemar commented Jul 13, 2023

When using a wiki link in a todo list, the function markdown-link-p will recognize the link as a markdown reference link.

- [ ] [[myfile]] will be recognized as a markdown link by markdwon-link-p

The regex specified by markdown-regex-link-reference allows for a space between the link and d

Expected Behavior

As there is a space between the empty todo closing bracket and the link opening bracket, I would not expect this to be recognized as a markdown link. I would therefore expect markdown-link-p to return nil.

Actual Behavior

The function markdown-link-p indicates that this link is a markdown link.

I dug into the code a bit and saw that the regex specified in markdown-regex-link-reference allows for a single space between the two sets of brackets in a markdown reference link via the syntax [ ]?. I didn't realize spaces were allowed between the two sets of brackets, so I'm unsure why this is there, but removing this from the center of the regex expression seems to fix the issue.

Steps to Reproduce

  1. On a new line in any buffer, add the following to create a simple todo item with a wiki link:
    - [ ] [[mylink]]
  2. With the cursor on the link, run the command markdown-link-p, which will return t

Software Versions

  • Markdown Mode: 2.6-alpha
  • Emacs: 28.2
  • OS: Fedora 38 (Linux 6.3.11)
@syohex
Copy link
Collaborator

syohex commented Jul 14, 2023

I didn't realize spaces were allowed between the two sets of brackets, so I'm unsure why this is there, but removing this from the center of the regex expression seems to fix the issue.

Original markdown specification allows one space between link text and link label. So the original author wrote such regular expression. While CommonMark does not allow spaces between them

BTW removing space from its regular expression doesn't break any tests. So I think we can remove a space from it. And I think few people or no one put space between them.

Reference

@syohex
Copy link
Collaborator

syohex commented Jul 15, 2023

I've sent PR #776

@syohex syohex closed this as completed Jul 16, 2023
@jayemar
Copy link
Author

jayemar commented Jul 16, 2023

Thanks for resolving this so quickly, I really appreciate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants