fix(generate): don't escape < in multiline code blocks#386
fix(generate): don't escape < in multiline code blocks#386
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #386 +/- ##
==========================================
+ Coverage 71.92% 73.26% +1.34%
==========================================
Files 45 45
Lines 4495 4855 +360
Branches 4495 4855 +360
==========================================
+ Hits 3233 3557 +324
- Misses 945 960 +15
- Partials 317 338 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request attempts to fix escaping of < characters inside fenced code blocks (delimited by ```) in the markdown renderer. The change adds state tracking to detect when processing lines within fenced code blocks, so that HTML escaping can be skipped for those lines.
Key changes:
- Adds
in_code_blockboolean state variable to track whether currently inside a fenced code block - Modifies the
escape_mdfilter to toggle the state when encountering```fences - Extends the early return condition to skip escaping when
in_code_blockis true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
bugbot run |
lib/src/docs/markdown/renderer.rs
Outdated
| if line.trim_start().starts_with("```") { | ||
| in_code_block = !in_code_block; | ||
| return line.to_string(); | ||
| } |
There was a problem hiding this comment.
Bug: Indented code content incorrectly detected as fence delimiter
The check line.trim_start().starts_with("```") incorrectly matches lines that are content within indented code blocks (4+ spaces of indentation). In Markdown, fenced code block markers can only have 0-3 spaces of indentation; lines with 4+ spaces are indented code block content. If such content happens to contain "```", the in_code_block state gets toggled incorrectly, causing subsequent non-code text to skip `<` escaping when it shouldn't. The fence detection should either check the indentation condition first or validate that there are fewer than 4 leading spaces.
There was a problem hiding this comment.
I didn't know this, should we support it?
There was a problem hiding this comment.
up to you, we could do it later if you want
95379e1 to
d258b14
Compare
7a55c5f to
2cb8402
Compare
Fixes jdx/mise#6949
Note
Update the markdown escape filter to detect fenced code blocks and avoid escaping within them.
lib/src/docs/markdown/renderer.rs):escape_md):in_code_blockstate.<to<) for lines inside fenced blocks; leaves fence lines unchanged.Written by Cursor Bugbot for commit e3ccc18. This will update automatically on new commits. Configure here.