-
Notifications
You must be signed in to change notification settings - Fork 740
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
Fix brackets in links in markdown lexer #1445
Fix brackets in links in markdown lexer #1445
Conversation
@pyrmont I see your lookahead suggestion, but it wasn't working when I tested. I'll give it another go and see if I can figure it out, and I'll update this PR if I can get it to work. It might just be the regex tester I'm using doesn't like the lookahead formatting. I understand the logic now. Also, does this need to add an example to the spec, like you did in #1442? |
When hiding brackets inside links (with backticks), coloring was breaking. This makes the lexer search for the open bracket or paren that starts the url or reference link
1d146ae
to
a59a5f9
Compare
@pyrmont OK, sorry about that, I think it's good to go now. 🙏 |
@pyrmont Thanks a lot for the fixes! Feel free to point them out to me next time, and I'll fix them myself so you don't have to go through all the effort. It also means I can fix my commit, so I'm not pushing broken regex to the project, even if it is fixed right after. 🙇 I've also cloned locally and am able to test, (super simple, works great), so I'll test locally myself before submitting next time. 🙇 |
@pyrmont I don't think the regex you pushed was correct, as there shouldn't be any spaces between the link text and the URL/Reference: [This is a link `with backticks`](example.com)
[This is not a link `with backticks`] (example.com) By adding spaces/tabs to be allowed between the I removed that in the latest commit, and now it seems correct: I also added that example to the markdown sample spec. What do you think? |
A couple of things:
What do you think? |
@pyrmont In this case, I'm trying to match the behavior I see most commonly. Testing this markdown: ### Try links
- [This is a link](https://www.google.com)
- [This is not a link] (https://www.google.com)
- [This is a link][example]
- [This is a link?] [example]
[example]: https://www.google.com Testing with CommonMark dingusTesting with GitHub:Try links
Testing with GitLabTesting with VS CodeIt seems like the majority of renderers do not accept this, including commonmark. It's not surprising because I can see how it would cause ambiguity or confusion when mixing references. WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that not putting a space between the link and the reference is the approach everyone else is taking. Let's do that.
@Ravlen Thanks for everything with this PR! I hope this improves the link highlighting behaviour on your end :) |
When hiding brackets inside links with backticks, rendering
was breaking. This makes the lexer search for
][
or](
to find the end delimiting the link text.
This fixes #1444.