Skip to content

feat: export escapeText for printing text content - #246

Merged
DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-prettier-marko-async-ulp3vg-escape-text
Sep 23, 2026
Merged

DylanPiercey merged 1 commit into
mainfrom
dpiercey-ws-prettier-marko-async-ulp3vg-escape-text

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

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 when next, 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, checkForPlaceholder stepped 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

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-bot

changeset-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c62ab41

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
htmljs-parser Minor

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

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (de21d68) to head (c62ab41).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DylanPiercey
DylanPiercey merged commit 402c94f into main Sep 23, 2026
11 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 23, 2026
@DylanPiercey
DylanPiercey deleted the dpiercey-ws-prettier-marko-async-ulp3vg-escape-text branch September 23, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant