fix(parser): preserve markdown fences and comments inside strings#605
Merged
Aditya-thesys merged 3 commits intoJun 8, 2026
Merged
Conversation
Aditya-thesys
left a comment
Contributor
There was a problem hiding this comment.
All looks good, could you fix those two small changes. Also maybe update the tests for single quote.
| // Not in string | ||
| if (c === '"') { | ||
| inStr = true; | ||
| if (c === '"' || c === "'") { |
Contributor
There was a problem hiding this comment.
Adding single quote tracking will cause issues with Apostrophes.
LLMs many times generates at the start
Here's the code:
Which now will not strip the following fences.
Could you for now scope it to double quotes only.
Contributor
Author
There was a problem hiding this comment.
Nice catch!|
I'll do this right away.
Comment on lines
+257
to
+269
| let inStr: false | '"' | "'" = false; | ||
| let fenceStart = -1; | ||
| while (i < input.length) { | ||
| const c = input[i]; | ||
| if (inStr) { | ||
| if (c === "\\" && i + 1 < input.length) { | ||
| i += 2; // skip escaped character | ||
| continue; | ||
| } | ||
| if (c === inStr) { | ||
| inStr = false; | ||
| } | ||
| i++; |
Contributor
There was a problem hiding this comment.
nit: the inStr and closeStr tracking code is almost identical, we can deduplicate them
Contributor
Author
There was a problem hiding this comment.
yeah i will use a helper here.
Contributor
Author
|
Done!
|
Aditya-thesys
approved these changes
Jun 8, 2026
Contributor
|
Thanks! for the fix, merging it. |
3 tasks
ankit-thesys
added a commit
that referenced
this pull request
Jun 10, 2026
….0.8 Version bumps for the first publish since 2026-05-20 (4b663b9): - @openuidev/react-ui 0.11.8 -> 0.12.0 (minor): component CSS now ships in `@layer openui` (#589/#621) and react-syntax-highlighter moved to ^16.1.1 (#577, fixes prismjs CVE-2024-53382) - @openuidev/lang-core 0.2.5 -> 0.2.6 (patch): parser preserves markdown fences and comments inside string props (#605) - @openuidev/cli 0.0.7 -> 0.0.8 (patch): cross-platform template build (#601, #627); no functional changes to the published CLI Remaining packages have no consumer-visible changes since the last publish and are not republished; the lang wrappers pick up lang-core 0.2.6 transitively via their ^0.2.5 ranges. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
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.
What
This PR fixes two parser preprocessing issues where markdown content inside string literals could be incorrectly modified before parsing.
Changes
stripFencesstring-aware so fenced code blocks inside string literals are preserved.stripComments.Test Plan
pnpm --filter @openuidev/lang-core testChecklist
Closes #581
Closes #596