Skip to content

feat: trim whitespace from concise mode fences#199

Merged
DylanPiercey merged 1 commit intomainfrom
trim-fence-whitespace
Feb 12, 2026
Merged

feat: trim whitespace from concise mode fences#199
DylanPiercey merged 1 commit intomainfrom
trim-fence-whitespace

Conversation

@LuLaValva
Copy link
Member

In previous versions of this parser, concise mode code fences preserved their leading and trailing whitespace

--
Hello World
--
// `\nHello World\n`

These changes trim that whitespace, and also whitespace from leading tabs

@changeset-bot
Copy link

changeset-bot bot commented Sep 19, 2025

🦋 Changeset detected

Latest commit: 58bf756

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
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #199      +/-   ##
==========================================
+ Coverage   91.87%   91.96%   +0.09%     
==========================================
  Files          28       28              
  Lines        1427     1443      +16     
  Branches      323      327       +4     
==========================================
+ Hits         1311     1327      +16     
  Misses         54       54              
  Partials       62       62              

☔ View full report in Codecov by Sentry.
📢 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.

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

Walkthrough

Adds a changeset for htmljs-parser documenting concise-mode trimming of boundary newlines and leading indentation. Parser.ts now avoids emitting empty text events at EndText. BEGIN_DELIMITED_HTML_BLOCK refactors delimited HTML block end-of-line and indentation handling, adjusts cursor advancement, whitespace trimming, and text-boundary start/end logic via a new first parameter. util.htmlEOF conditionally trims trailing whitespace before ending text when there is no active tag or the active tag is concise. A test fixture file was expanded with additional blocks and a trailing newline.

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: trim whitespace from concise mode fences' clearly and accurately describes the main objective of the pull request.
Description check ✅ Passed The description explains the previous behavior and the new behavior, providing a concrete example of what changed regarding whitespace handling in concise mode fences.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch trim-fence-whitespace

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/states/BEGIN_DELIMITED_HTML_BLOCK.ts`:
- Around line 98-102: The close-delimiter branch currently calls
parser.endText() while leaving any trailing spaces before the newline untouched;
update the delimiter-close path (the block that checks
parser.lookAheadFor(endHtmlBlockLookahead, parser.pos + newLineLength)) to trim
trailing whitespace before ending the text, mirroring the dedent path behavior:
scan backwards from parser.pos to remove spaces/tabs (or adjust parser.pos) so
trailing boundary whitespace is excluded, then call parser.endText(), update
parser.pos by newLineLength + endHtmlBlockLookahead.length, and set
parser.forward = 0; ensure you use the same trimming logic used by the dedent
path to keep behavior consistent.

@DylanPiercey DylanPiercey merged commit d647d74 into main Feb 12, 2026
11 checks passed
@DylanPiercey DylanPiercey deleted the trim-fence-whitespace branch February 12, 2026 20:34
@github-actions github-actions bot mentioned this pull request Feb 12, 2026
@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Feb 27, 2026
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants