-
Notifications
You must be signed in to change notification settings - Fork 58
Fix: Jump to link in checkbox #267
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
base: master
Are you sure you want to change the base?
Fix: Jump to link in checkbox #267
Conversation
@@ -0,0 +1,19 @@ | |||
{ | |||
"cSpell.words": [ |
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.
Just getting rid of a bunch of spellcheck warnings in main.ts
"scripthost", | ||
"ES2020" | ||
] | ||
"lib": ["dom", "scripthost", "ES2020"] |
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.
Just prettier
doing some auto formatting
const WIKILINK_REGEX_STRING = "\\[\\[.*?\\]\\]"; | ||
const MARKDOWN_LINK_REGEX_STRING = "\\[.*?\\]\\(.*?\\)"; | ||
const URL_REGEX_STRING = "\\w+://\\S+"; |
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.
The new regexes are now built as actual regexes from the start (instead of just strings) so that they only need half as many backslashes
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.
Thank you, this is a great contribution!
For sure, I was meaning to get around to this fix at some point :) Thanks to you for making the plugin in the first place! It's been great |
Fixes: #242
This PR adjusts the existing link patterns to be more precise and accurate (e.g. take backslashes into account when interpreting brackets as part of link syntax) - and in the context of #242, we now disallow unescaped square brackets inside the
[display text]
part of a[display text](url)
markdown link.This fixes the issue of a checkbox's square brackets (e.g.
- [ ]
/- [x]
) being considered as the start of a markdown link when a markdown link is part of the checkbox item (e.g.- [ ] This is a [markdown link](https://some-url.com)
).Detailed docstrings have been added to the regexes now that they're even more complex than they were before and some intentional tradeoffs were taken (particularly for
MARKDOWN_LINK_REGEX
).This PR also along the way:
vitest
test framework and adds unit tests for the link regexes (jumpToLink.test.ts
)package-lock.json
from.gitignore
and adds it to the repo's git tracking (generally considered good practice to commitpackage-lock.json
)