tempest/highlight
Fast, extensible server-side syntax highlighting for PHP and other languages. Install via Composer and use the Highlighter to parse code into highlighted output for rendering in docs, blogs, or apps, with a focus on performance and customization.
<script>, <style>, {#if} blocks) complements Laravel’s Blade + Inertia.js workflows, enabling seamless highlighting in SvelteKit or Svelte + Laravel API setups.spatie/laravel-api-docs) to show frontend-backend interactions.composer update tempest/highlight.@svelteHighlight directives for Svelte blocks in Blade templates:
Blade::directive('svelteHighlight', function ($expression) {
return "<?php echo \\Tempest\\Highlight\\Highlighter::parse($expression, 'svelte'); ?>";
});
@svelteHighlight($svelteComponent)
| Risk Area | Mitigation Strategy | Update for 2.25.0 |
|---|---|---|
| Svelte Syntax Variants | Test against Svelte 4+ and SvelteKit syntax, including custom elements and actions. | Monitor for edge cases (e.g., Svelte preprocessors like +page.svelte). |
| Inertia.js/Svelte Tooling | Validate compatibility with inertiajs/inertia-laravel and sveltejs/svelte. |
No known conflicts; Svelte is a stable, standardized language. |
| Performance | Benchmark Svelte parsing vs. other languages (e.g., Blade, JavaScript). | TempestPHP’s benchmarks show <3% overhead for Svelte. |
| Deprecation Risk | Svelte support is now part of the core package; lower risk of removal. | N/A |
| Svelte Preprocessors | Plan for Svelte extensions (e.g., svelte-preprocess) or custom syntax. |
Add support via preprocess: true flag or custom lexers. |
+layout.svelte, +page.server.ts) or custom Svelte actions?spatie/laravel-markdown).+page.svelte)./docs/components/Button.svelte).artisan svelte:highlight for component validation).| Component | Compatibility Notes | Update for 2.25.0 |
|---|---|---|
| Svelte Libraries | Tested with svelte@4+ and svelte-preprocess. |
No breaking changes reported. |
| Inertia.js | Compatible with inertiajs/inertia-laravel for Svelte component highlighting. |
Validate against latest Inertia.js + Svelte versions. |
| Markdown Parsers | Works with spatie/laravel-markdown or root/awesome-markdown. |
No conflicts; Svelte is treated as a code block. |
| Blade/Twig | Use @svelteHighlight directive to avoid template conflicts. |
N/A |
| SvelteKit | Parse SvelteKit-specific files (e.g., +layout.svelte, +page.server.ts). |
Add support for SvelteKit file conventions. |
composer require tempest/highlight:^2.25.0
Blade::directive('svelteHighlight', function ($expression) {
return "<?php echo \\Tempest\\Highlight\\Highlighter::parse($expression, 'svelte'); ?>";
});
Route::post('/highlight/svelte', function (Request $request) {
return response()->json([
'html' => app(\Tempest\Highlight\Highlighter::class)
->parse($request->svelte, 'svelte')
]);
});
Cache::remember("svelte_{$component}", now()->addHours(1), fn() =>
$highlighter->parse($component, 'svelte')
);
Artisan::command('svelte:highlight', function () {
$svelte = file_get_contents('resources/js/components/Button.svelte');
echo $this->highlighter->parse($svelte, 'svelte');
});
tempest/highlight:^2.25.0 in composer.json to avoid unintended major updates.try {
$highlighted = $highlighter->parse($s
How can I help you explore Laravel packages today?