-
Notifications
You must be signed in to change notification settings - Fork 71
feat: add no-reversed-media-syntax rule #398
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: main
Are you sure you want to change the base?
Conversation
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.
Thanks for your work on this PR.
I've left some comments about false negatives and test cases.
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.
Could you take a look at the false negatives in nested text
nodes?
Currently, nested text
nodes using emphasis (*
), strong (**
), strikethrough (~
), and inline code blocks using backticks result in false negatives.
(*foo*)[]
(**foo**)[]
(~~foo~~)[]
(`foo`)[]
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.
Hmm these produce 3 text nodes. This should complicate things 😅
// Helpers | ||
//----------------------------------------------------------------------------- | ||
|
||
const reversedPattern = /(?<!\\)\(((?:\\.|[^()\\])*)\)\[((?:\\.|[^\]\\])*)\]/gu; |
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.
Can you add a comment showing what this regex is meant to match?
const { | ||
lineOffset: endLineOffset, | ||
columnOffset: endColumnOffset, | ||
} = findOffsets(text, matchIndex + matchLength); |
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.
Because the regex only matches single lines, you can just add matchLength
to startColumnOffset
to get this location instead of calculating it from scratch.
Prerequisites checklist
What is the purpose of this pull request?
This PR adds a new rule
no-reversed-media-syntax
to enforce correct link and image syntax in Markdown.What changes did you make? (Give an overview)
Added the
no-reversed-media-syntax
rule, along with documentation and tests.Related Issues
Fixes #386
Is there anything you'd like reviewers to focus on?