feat: export escapeText for printing text content - #246
Merged
DylanPiercey merged 1 commit intoSep 23, 2026
Merged
Conversation
The parser reads a backslash run before `${` or `$!{` as escapes and every
other backslash as text, and both prettier-plugin-marko and the compiler's
source printer need the inverse to print text that reads back the same.
`escapeText(text, next)` owns that rule next to the grammar it inverts,
taking the content printed after the text since a backslash run ending the
text joins any that starts it.
Its tests exposed that `checkForPlaceholder` stepped past only two more
characters after keeping half of an odd backslash run, the length of `${`,
so from five backslashes on the `${` was left unread and parsed as a
placeholder. Every odd run is now read as escapes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: c62ab41 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #246 +/- ##
=======================================
Coverage 99.95% 99.95%
=======================================
Files 34 35 +1
Lines 4576 4604 +28
Branches 879 882 +3
=======================================
+ Hits 4574 4602 +28
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
DylanPiercey
deleted the
dpiercey-ws-prettier-marko-async-ulp3vg-escape-text
branch
September 23, 2026 18:01
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.
Adds
escapeText(text, next), the inverse of how the parser reads text content: only a backslash run before${or$!{is an escape, so only those runs are doubled, and a run ending the text is doubled whennext, the content printed after it, leads into a placeholder. prettier-plugin-marko and the compiler's source printer both need this to print text that reads back the same, and it belongs next to the grammar it inverts.Its round-trip tests exposed a parser bug, also fixed here: after keeping half of an odd backslash run,
checkForPlaceholderstepped past only the two characters of${, so from five backslashes on the${was left unread and parsed as a placeholder. A new fixture pins runs of one to seven.🤖 Generated with Claude Code