-
Notifications
You must be signed in to change notification settings - Fork 76
feat: false positives and negatives for consecutive backslashes #490
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
Open
lumirlumir
wants to merge
13
commits into
main
Choose a base branch
from
fix-false-positives-for-consecutive-backslashes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…lse-positives-for-consecutive-backslashes
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
lumirlumir
commented
Aug 27, 2025
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request?
Which language are you using?
CommonMark and GFM.
What did you do?
I've tried using consecutive backslashes in the
no-missing-atx-heading-space
,no-missing-label-refs
, andno-reversed-media-syntax
rules, but they reported false positives and false negatives as shown below:What did you expect to happen?
no-missing-atx-heading-space
Only an even number of backslashes should be reported, as
\\\\
is not interpreted as an escape backslash character in Markdown. However, it also reports odd numbers of backslashes greater than three.no-missing-label-refs
When consecutive backslashes appear, it fails to report them, resulting in false negatives:
According to the AST, the
foo\\
is a valid label reference.no-reversed-media-syntax
When consecutive backslashes appear, it fails to report them, resulting in false negatives:
What actually happened?
It's also mentioned in the "What did you expect to happen?" section.
Link to minimal reproducible Example
What changes did you make? (Give an overview)
In this PR, I've addressed false positives and negatives in
no-missing-atx-heading-space
,no-missing-label-refs
, andno-reversed-media-syntax
rules that were caused by consecutive backslash handling.Previously, we used the following regex patterns to avoid matching backslash escapes:
(?<!\\)
and(?<!(?<!\\)\\)
However, these patterns are incorrect because they don't properly handle consecutive backslash escapes metioned above.
So, I've updated them to use the following regex correctly:
(?<=(?<!\\)(?:\\{2})*)
Related Issues
Ref: #452 (comment)
Is there anything you'd like reviewers to focus on?
In JavaScript,
\\\\\\\\
(8 backslashes) is interpreted as\\\\
(4 backslashes) in Markdown, and is ultimately recognized as\\
(2 backslashes). In this case, an even number of backslashes is not treated as an escape character and is recognized as a normal backslash.