Skip to content

Add TOML syntax highlighting - #235

Open
eas4ai wants to merge 2 commits into
tempestphp:mainfrom
eas4ai:add-toml-highlighting
Open

eas4ai wants to merge 2 commits into
tempestphp:mainfrom
eas4ai:add-toml-highlighting

Conversation

@eas4ai

@eas4ai eas4ai commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Register toml
  • Highlight comments, bare, quoted, and dotted keys, standard and array-of-tables headers, basic, literal, and multiline strings, integers in supported bases, floats and special float values, booleans, offset and local date-time values, arrays, inline tables, separators, and delimiters
  • Add focused tests and a benchmark fixture

This is a clean resubmission of the closed #227, based directly on main: no core changes and no visual test harness.

Verification

  • vendor/bin/php-cs-fixer fix --allow-risky=yes — no remaining changes
  • vendor/bin/phpstan analyse src tests — no errors
  • vendor/bin/phpunit — 865 tests, 1,170 assertions
  • vendor/bin/phpbench run tests/Bench/HighlighterBench.php --variant='^toml$' --report=aggregate — 100.64 μs (±0.54%)

Screenshot

TOML highlighting

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Benchmark Results

Comparison of add-toml-highlighting against main (3d96482ee77208c8e445d4f68667918c7f440f62).

Open to see the benchmark results
benchmark subject set revs its mem_peak mode rstdev
HighlighterBench benchParse apache 100 5 2.105mb +0.22% 39.075890μs -1.29% ±1.41% -0.59%
HighlighterBench benchParse bash 100 5 2.136mb +0.21% 111.750959μs -1.64% ±0.82% +35.22%
HighlighterBench benchParse bbcode 100 5 2.092mb +0.22% 40.008219μs +4.21% ±0.52% -59.52%
HighlighterBench benchParse blade 100 5 2.775mb +0.16% 553.075793μs -1.15% ±0.80% -34.62%
HighlighterBench benchParse css 100 5 2.123mb +0.21% 75.382642μs -1.38% ±1.32% +41.87%
HighlighterBench benchParse diff 100 5 2.127mb +0.21% 49.779589μs +0.38% ±0.91% -9.35%
HighlighterBench benchParse dockerfile 100 5 2.097mb +0.22% 48.110196μs -0.34% ±0.68% -38.10%
HighlighterBench benchParse dotenv 100 5 2.108mb +0.22% 41.061370μs -1.37% ±1.06% +95.81%
HighlighterBench benchParse gdscript 100 5 2.203mb +0.21% 176.654775μs -3.16% ±1.12% -54.91%
HighlighterBench benchParse graphql 100 5 2.123mb +0.21% 80.916908μs -1.15% ±2.07% +19.32%
HighlighterBench benchParse html 100 5 2.127mb +0.21% 61.799119μs -0.73% ±0.73% -24.50%
HighlighterBench benchParse http 100 5 2.096mb +0.22% 13.189374μs +0.36% ±1.10% -32.76%
HighlighterBench benchParse ini 100 5 2.112mb +0.21% 46.323620μs -0.17% ±0.95% -5.13%
HighlighterBench benchParse javascript 100 5 2.191mb +0.21% 144.236849μs -0.07% ±0.96% -56.10%
HighlighterBench benchParse json 100 5 2.166mb +0.21% 127.466008μs +1.02% ±0.72% -69.82%
HighlighterBench benchParse markdown 100 5 2.114mb +0.21% 40.437945μs -0.78% ±1.09% +25.99%
HighlighterBench benchParse nginx 100 5 2.178mb +0.21% 139.815910μs -2.51% ±1.01% -24.76%
HighlighterBench benchParse php 100 5 2.469mb +0.18% 360.168434μs -3.66% ±1.70% +14.93%
HighlighterBench benchParse python 100 5 2.367mb +0.19% 213.093346μs -0.08% ±1.40% +47.63%
HighlighterBench benchParse ruby 100 5 2.413mb +0.19% 126.882994μs -0.49% ±1.55% +135.34%
HighlighterBench benchParse scss 100 5 2.139mb +0.21% 95.225382μs -3.15% ±2.35% +126.61%
HighlighterBench benchParse sema 100 5 2.307mb +0.20% 113.781155μs +2.24% ±1.15% -21.88%
HighlighterBench benchParse sql 100 5 2.138mb +0.21% 82.827593μs -2.45% ±2.12% -6.40%
HighlighterBench benchParse svelte 100 5 2.412mb +0.19% 549.364736μs -0.78% ±0.67% -55.68%
HighlighterBench benchParse swift 100 5 2.185mb +0.21% 134.745205μs -0.56% ±0.91% +6.44%
HighlighterBench benchParse terminal 100 5 2.133mb +0.21% 100.973444μs +2.35% ±2.15% +298.14%
HighlighterBench benchParse terraform 100 5 2.138mb +0.21% 93.699119μs -0.08% ±0.72% +149.51%
HighlighterBench benchParse toml 100 5 ERR 69.809041μs +0.00% ±1.05% +0.00%
HighlighterBench benchParse typescript 100 5 2.563mb +0.18% 127.008493μs -4.07% ±2.05% +113.12%
HighlighterBench benchParse txt 100 5 2.067mb +0.22% 4.829080μs +0.18% ±2.54% +34.01%
HighlighterBench benchParse twig 100 5 19.245mb +0.02% 840.199628μs +3.06% ±1.97% +27.31%
HighlighterBench benchParse vue 100 5 2.420mb +0.19% 208.824423μs +0.13% ±0.67% -15.15%
HighlighterBench benchParse xml 100 5 2.141mb +0.21% 95.668963μs +0.66% ±0.53% -57.48%
HighlighterBench benchParse yaml 100 5 2.199mb +0.21% 171.705714μs -0.93% ±0.86% -45.64%
HighlighterBench benchParse jsx 100 5 2.135mb +0.21% 28.072740μs +0.44% ±0.61% -67.52%
HighlighterBench benchParse tsx 100 5 2.219mb +0.20% 40.424110μs -0.43% ±1.56% +6.70%

Generated by phpbench against commit ed0db06

@brendt brendt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add pattern tests please? Look at any other language pattern to see how they work.

@brendt brendt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add pattern tests please? Look at any other language pattern to see how they work.

@brendt

brendt commented Oct 20, 2026

Copy link
Copy Markdown
Member

Sorry for the double review

@eas4ai

eas4ai commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Added #[PatternTest] attributes to all 8 TOML pattern classes.

Verified locally before pushing: vendor/bin/phpunit — 881 tests, 1,186 assertions; vendor/bin/phpstan analyse src tests — no errors; PHP-CS-Fixer clean.

@eas4ai
eas4ai force-pushed the add-toml-highlighting branch from bbc00d9 to aec9b0b Compare October 20, 2026 10:36
@eas4ai

eas4ai commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main to resolve the conflicts in src/Highlighter.php and tests/Bench/HighlighterBench.php after the recent language merges. The TOML changes and pattern tests are unchanged apart from fitting the updated registration and benchmark lists.

Verified locally after the rebase: vendor/bin/phpunit — 1177 tests, 1739 assertions; PHPStan reports no errors. GitHub now reports this PR as mergeable with all checks passing.

@eas4ai
eas4ai force-pushed the add-toml-highlighting branch from aec9b0b to ed0db06 Compare October 20, 2026 10:39
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.

2 participants