Skip to content

RegularParser now finds tags inside runs of opening tags - #133

Merged
thunderer merged 1 commit into
masterfrom
tk-regular-overlap
Nov 8, 2026
Merged

thunderer merged 1 commit into
masterfrom
tk-regular-overlap

Conversation

@thunderer

Copy link
Copy Markdown
Owner

With a syntax whose opening tag overlaps itself ([[, {{, <<), RegularParser missed tags that follow a run of opening-tag characters. Its lexer cut the run into opening tags from the left, so with [[ it found a in [[[[a]] but not in [[[a]], where the odd [ stuck to the name. HybridParser and RegexParser find a at offset 1, the same way every parser finds [a] in [[a] with the default syntax.

  • the lexer now reads a character as text when an opening tag starts on it and another one starts before it ends, so the opening tag token always sits right before the name,
  • the lexer regex stays byte-identical for the default syntax and every one-character opening tag, and opening tags that cannot overlap themselves ([!, <!--, {%) keep the same output,
  • a closing tag hidden in such a run is now found too, so [[a]]x[[[//a]] gives a with content x[, as HybridParser does,
  • RegularParser and HybridParser now give the same output on 13 syntaxes in a differential test of 20000-40000 random inputs each, and the new data-provider test checks both parsers on 8 cases,
  • verified PHPUnit on PHP 8.4, the new cases on PHP 5.5, 7.4 and 8.5, Mago and Infection; the 3 escaped mutants on the new lines do not change the output.

@thunderer
thunderer merged commit 8c3855b into master Nov 8, 2026
17 checks passed
@thunderer
thunderer deleted the tk-regular-overlap branch November 8, 2026 14:19
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