Skip to content

fix: trailing whitespace concise blocks#218

Merged
DylanPiercey merged 1 commit intomainfrom
concise-trailing-whitespace
Mar 2, 2026
Merged

fix: trailing whitespace concise blocks#218
DylanPiercey merged 1 commit intomainfrom
concise-trailing-whitespace

Conversation

@DylanPiercey
Copy link
Contributor

Fixes a regression from #199 which incorrectly removed non newline whitespaces at the end of concise text blocks.

---
Hello 
---

The " " after Hello was being incorrectly removed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 2, 2026

🦋 Changeset detected

Latest commit: c63e244

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 Patch

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

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

Walkthrough

This pull request fixes a bug in the htmljs-parser where trailing literal whitespace in concise blocks was incorrectly skipped. The fix introduces a new utility function isLineCode() that distinguishes between line-breaking characters (newline, carriage return) and all whitespace characters. The delimiter whitespace check in BEGIN_DELIMITED_HTML_BLOCK.ts is updated to use this new function. Two test fixture files are added to validate the whitespace handling behavior in concise blocks and lines.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: addressing trailing whitespace handling in concise blocks, which is the primary focus of all changes.
Description check ✅ Passed The description is directly related to the changeset, explaining the regression being fixed and providing a concrete example of the issue with trailing whitespace in concise blocks.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch concise-trailing-whitespace

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
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.

🧹 Nitpick comments (1)
src/__tests__/fixtures/concise-line-whitespace-ending/input.marko (1)

1-1: Consider adding a CRLF variant of this fixture.

Optional, but useful to lock behavior for Windows-style line endings (\r\n) alongside the current EOF-trailing-space case.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/__tests__/fixtures/concise-line-whitespace-ending/input.marko` at line 1,
Add a Windows CRLF variant of the trailing-space fixture: create a new fixture
file containing the exact same text "-- ${value} " but with a CRLF ("\r\n") line
ending (use the same basename with a .crlf or .windows suffix so it sits
alongside the existing fixture), ensuring the test harness will pick up both the
original EOF-trailing-space case and this Windows-style line-ending case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/__tests__/fixtures/concise-line-whitespace-ending/input.marko`:
- Line 1: Add a Windows CRLF variant of the trailing-space fixture: create a new
fixture file containing the exact same text "-- ${value} " but with a CRLF
("\r\n") line ending (use the same basename with a .crlf or .windows suffix so
it sits alongside the existing fixture), ensuring the test harness will pick up
both the original EOF-trailing-space case and this Windows-style line-ending
case.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9b1008 and c63e244.

⛔ Files ignored due to path filters (2)
  • src/__tests__/fixtures/concise-block-whitespace-leading/__snapshots__/concise-block-whitespace-leading.expected.txt is excluded by !**/__snapshots__/** and included by **
  • src/__tests__/fixtures/concise-line-whitespace-ending/__snapshots__/concise-line-whitespace-ending.expected.txt is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (5)
  • .changeset/tricky-aliens-cut.md
  • src/__tests__/fixtures/concise-block-whitespace-leading/input.marko
  • src/__tests__/fixtures/concise-line-whitespace-ending/input.marko
  • src/states/BEGIN_DELIMITED_HTML_BLOCK.ts
  • src/util/util.ts

@DylanPiercey DylanPiercey merged commit ca9ae8f into main Mar 2, 2026
9 checks passed
@DylanPiercey DylanPiercey deleted the concise-trailing-whitespace branch March 2, 2026 16:27
@github-actions github-actions bot mentioned this pull request Mar 2, 2026
@github-project-automation github-project-automation bot moved this to Done in Roadmap Mar 2, 2026
@DylanPiercey DylanPiercey self-assigned this Mar 2, 2026
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.02%. Comparing base (c9b1008) to head (c63e244).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #218      +/-   ##
==========================================
+ Coverage   92.00%   92.02%   +0.02%     
==========================================
  Files          28       28              
  Lines        1450     1454       +4     
  Branches      328      329       +1     
==========================================
+ Hits         1334     1338       +4     
  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.

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.

1 participant