Skip to content

Harden ignore ranges by moving them to the lexer/parser#147

Open
JohnathonKoster wants to merge 1 commit intomainfrom
improve/format-ignore
Open

Harden ignore ranges by moving them to the lexer/parser#147
JohnathonKoster wants to merge 1 commit intomainfrom
improve/format-ignore

Conversation

@JohnathonKoster
Copy link
Copy Markdown
Contributor

The Problem

format-ignore-start / format-ignore-end regions were still being modified by the formatter in whitespace-sensitive Blade templates. Spaces before echo tags, blank lines before directives, and even the closing ignore marker itself could be collapsed or merged. The previous behavior also relied too heavily on printer-side reconstruction, which made malformed or nested cases less predictable and made ignore ranges harder to keep idempotent across repeated formatting and wrapper-depth scenarios.

The Solution

Moved range-ignore handling to a parser/lexer-backed sentinel flow so ignore regions are treated as opaque slices of original source instead of being rebuilt child-by-child.

  • Added a shared ignore-marker parser for Blade and HTML comment variants, including mixed wrapper pairing.
  • Added a lexer prepass that collects ignore ranges and emits them as IgnoreRange tokens, preserving exact source slices through the matched end marker or EOF.
  • Materialized ignore ranges as opaque AST leaf nodes and printed them directly from source, so formatter whitespace logic no longer rewrites their contents.
  • Kept single-marker format-ignore / prettier-ignore behavior unchanged.
  • Tightened malformed recovery so marker counts stay stable and formatting resumes after the lexical end marker.
  • Expanded test coverage across lexer, parser, formatter, malformed recovery, and wrapper-depth/property suites.

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