Skip to content

fix: guard against false linting diagnostics with CRLF line endings#304

Merged
mcanouil merged 2 commits intomainfrom
fix/issue301
Mar 12, 2026
Merged

fix: guard against false linting diagnostics with CRLF line endings#304
mcanouil merged 2 commits intomainfrom
fix/issue301

Conversation

@mcanouil
Copy link
Copy Markdown
Owner

Fixes #301.

JavaScript's . regex metacharacter does not match \r.
The opening fence regex in getCodeBlockRanges failed on lines with trailing \r from CRLF endings, so no code blocks were detected.
This caused curly braces and = signs inside fenced code blocks to be flagged as attribute blocks, producing false spaces-around-equals diagnostics.

Strip trailing \r before regex matching while preserving the raw line length for offset calculations.
Add an overlapsCodeBlock helper that checks both endpoints of a match against code block ranges.
Eleven new CRLF-specific tests cover getCodeBlockRanges, isInCodeBlockRange, and extractBlocks.

…301)

JavaScript's `.` regex metacharacter does not match `\r`. The opening
fence regex in `getCodeBlockRanges` failed on lines with trailing `\r`
from CRLF endings, so no code blocks were detected. This caused curly
braces and `=` signs inside fenced code blocks to be flagged as
attribute blocks, producing false `spaces-around-equals` diagnostics.

Strip trailing `\r` before regex matching while preserving the raw line
length for offset calculations. Add `overlapsCodeBlock` helper that
checks both endpoints of a match against code block ranges.
@mcanouil mcanouil added the Type: Bug 🐛 Issues related to bugs, errors, or mistakes label Mar 12, 2026
@mcanouil mcanouil self-assigned this Mar 12, 2026
@mcanouil mcanouil merged commit 5a385ee into main Mar 12, 2026
7 checks passed
@mcanouil mcanouil deleted the fix/issue301 branch March 12, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug 🐛 Issues related to bugs, errors, or mistakes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected linting warnings coming from Quarto Wizard?

1 participant