Skip to content

Handle CRLF line endings when trimming blocks - #1352

Open
alloutflo wants to merge 1 commit into
HubSpot:masterfrom
alloutflo:fix/1087-crlf-trim-blocks
Open

alloutflo wants to merge 1 commit into
HubSpot:masterfrom
alloutflo:fix/1087-crlf-trim-blocks

Conversation

@alloutflo

Copy link
Copy Markdown

With trimBlocks enabled, CRLF line endings after tags and comments are currently left in the output, producing the extra blank lines reported in #1087. Both token scanners only recognize LF in this path.

Consume exactly one immediately following LF or CRLF sequence in both scanners. Advance the line counter once and reset the column origin after the entire consumed sequence so subsequent token locations remain correct. Existing standalone-CR, ordinary text, and trailing-newline behavior is preserved. No API, configuration, or dependency changes.

Validation

  • The original issue's interpreter-rendering example fails before the fix and passes afterward, producing exactly the three expected configuration lines with their CRLF endings.
  • 10 new tests cover both scanners, tags/comments, LF/CRLF and mixed sequences, multiple newlines, EOF, standalone CR, intervening whitespace, expression tokens, disabled trimming, token locations, custom delimiters, and raw boundaries. The focused scanner/parser run passed all 104 tests.
  • Full Maven verify passed with Temurin 17, 21, and 25, with Maven running on Java 25: 2,248 tests per run, zero failures/errors, 23 skipped. Java 21 and 25 used clean verify to rebuild with their respective toolchains.
  • Spotless, Checkstyle, SpotBugs, PMD, independent diff review, and git diff --check passed.

The full runs use en_US for the previously reproduced, unrelated locale-sensitive number-format tests.

Implemented and independently reviewed with assistance from OpenAI Codex.

Fixes #1087

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.

render template that it is contains one '\r\n' string will return more than one

1 participant