Skip to content

fix: independant HTML implementation#194

Merged
brendt merged 8 commits intotempestphp:mainfrom
afu-dev:fix-xml-and-html-bugs
Feb 13, 2026
Merged

fix: independant HTML implementation#194
brendt merged 8 commits intotempestphp:mainfrom
afu-dev:fix-xml-and-html-bugs

Conversation

@afu-dev
Copy link
Contributor

@afu-dev afu-dev commented Feb 12, 2026

This PR fixes bugs with the XML implementation, regarding tags and attributes. It also add an independant interpreter for the HTML implementation.

Here's a before/after:

XML

image image

Note: tags, XML or HTML, cannot start with a digit or an hyphen.

HTML

image image

Notes:

Current known bugs / regressions

image image

Note: boolean attributes don't work (cannot work?) with the current regex implementation. Also if the string value contains an equal sign, the word before get highlighted (thanks to unquoted attributes).

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Benchmark Results

Comparison of fix-xml-and-html-bugs against main (34249c4c29c9a278f3e736c310a42da65d3af891).

Open to see the benchmark results
benchmark subject set revs its mem_peak mode rstdev
HighlighterBench benchParse blade 100 5 2.582mb +0.30% 1,059.395538μs +0.99% ±0.48% +6.16%
HighlighterBench benchParse css 100 5 2.032mb 0.00% 141.693659μs +1.07% ±0.38% -50.67%
HighlighterBench benchParse diff 100 5 2.032mb 0.00% 26.628063μs -0.02% ±0.71% -25.48%
HighlighterBench benchParse dockerfile 100 5 2.031mb 0.00% 81.073112μs +0.49% ±0.80% +14.83%
HighlighterBench benchParse dotenv 100 5 2.031mb 0.00% 76.749491μs -0.60% ±1.16% +168.43%
HighlighterBench benchParse ellison 100 5 2.090mb +0.03% 336.664110μs -1.58% ±0.79% +36.23%
HighlighterBench benchParse gdscript 100 5 2.084mb +0.03% 329.264266μs -0.96% ±1.10% +23.23%
HighlighterBench benchParse html 100 5 2.031mb 0.00% 116.770607μs +3.42% ±0.76% +36.80%
HighlighterBench benchParse ini 100 5 2.030mb 0.00% 86.763640μs -0.31% ±0.43% -37.96%
HighlighterBench benchParse javascript 100 5 2.072mb +0.03% 273.151937μs -0.15% ±2.16% +251.47%
HighlighterBench benchParse json 100 5 2.047mb +0.03% 237.639002μs -0.29% ±0.34% -11.37%
HighlighterBench benchParse markdown 100 5 2.032mb 0.00% 75.095205μs +0.65% ±0.73% -48.06%
HighlighterBench benchParse php 100 5 2.351mb +0.03% 744.846849μs -0.70% ±0.17% -39.59%
HighlighterBench benchParse python 100 5 2.248mb +0.03% 421.425930μs -0.05% ±0.53% +75.01%
HighlighterBench benchParse sql 100 5 2.030mb 0.00% 158.182994μs +0.07% ±0.60% +5.96%
HighlighterBench benchParse twig 100 5 19.119mb +0.04% 1,429.551507μs +0.68% ±1.45% +205.25%
HighlighterBench benchParse xml 100 5 2.037mb 0.00% 179.252524μs -0.44% ±0.22% -83.44%
HighlighterBench benchParse yaml 100 5 2.080mb +0.03% 321.746595μs +0.52% ±0.86% +173.04%

Generated by phpbench against commit 246acac

@coveralls
Copy link

coveralls commented Feb 12, 2026

Pull Request Test Coverage Report for Build 21981887625

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 13 of 13 (100.0%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 93.606%

Totals Coverage Status
Change from base Build 21943678429: 0.4%
Covered Lines: 1581
Relevant Lines: 1689

💛 - Coveralls

@brendt
Copy link
Member

brendt commented Feb 13, 2026

With the HTML changes, does that mean custom tags won't be highlighted anymore? I think we want to keep that, even though they aren't official HTML tags (like, for example, for React or Tempest view components).

@afu-dev
Copy link
Contributor Author

afu-dev commented Feb 13, 2026

Custom HTML tags are still highlighted. From the spec, a custom HTML tag must be a valid HTML tag with a hyphen. Here's a tempest view rendered on main and on my branch:

image image

(insert "they're the same picture" meme)

I've just added 3 markdown files for the test-server to see a render of blade, tempest and twig views. I've also added a missing test for custom attributes (like <x-post :foreach="...">).

One side note, HTML tags name, after the first char, can use any unicode char like emojis and so on. The spec even gives us a JS-compatible RegEx. I'll open up an issue to keep track of it.

Ref:

@brendt brendt merged commit 5b5ef68 into tempestphp:main Feb 13, 2026
5 checks passed
@brendt
Copy link
Member

brendt commented Feb 13, 2026

Ok, awesome!

@brendt
Copy link
Member

brendt commented Feb 13, 2026

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.

HTML attributes not highlighted if unquoted

3 participants