tempest/highlight
Fast, extensible server-side syntax highlighting for PHP. Tempest Highlight parses code with a simple Highlighter API and supports multiple languages for rendering highlighted output in apps, docs, and tooling—install via Composer and start highlighting in minutes.
Developer-First Documentation & Knowledge Bases
Code Collaboration & IDE-Like Features
Performance-Critical Static Sites & Blogs
Custom Theming & Branding
Multi-Language Support for Polyglot Teams
Terminal & CLI Tooling
Avoid if:
react-native-syntax-highlight).Consider if:
*"We’re proposing to replace our client-side syntax highlighter (Prism.js) with Tempest’s server-side solution to:
- Eliminate JS dependency risks (XSS, bundle size) and improve security for user-uploaded code snippets.
- Boost SEO and performance by pre-rendering code blocks during build time, reducing client-side processing.
- Future-proof our docs/platform with native support for modern languages (GraphQL, Svelte, Terraform) without third-party costs.
- Reduce maintenance overhead—no more fighting Prism.js updates or browser compatibility issues.
- Enable new features like terminal output highlighting and dynamic ‘Try it Online’ demos without heavy frontend work.
This aligns with our goal of [X initiative] by improving [developer experience/mobile performance/security]. The MIT license and active community ensure long-term viability, with a 697-star package and recent contributions from maintainers like @fabpot (Symfony creator)."*
*"Tempest/Highlight is a drop-in replacement for client-side highlighters, offering:
- Server-side parsing: Safe, consistent rendering for untrusted code (e.g., user submissions, API docs).
- Extensible architecture: Add custom languages/themes via PHP classes—no need for JS plugins.
- Performance: Optimized for production (benchmarked in the repo) with low memory footprint.
- Laravel-native: Integrates seamlessly with Blade, Livewire, or static site generators (e.g., Vapor).
- Terminal support: Highlight CLI output, logs, or shell scripts natively (unlike JS-based tools).
Migration Path:
- Replace
Prism.jsincludes with a Laravel service provider for centralized highlighting.- Use the
Highlighterclass in Blade/Livewire to render snippets server-side.- Leverage cached responses for static sites (e.g., Vapor @cached).
- Extend for custom needs (e.g., dark mode themes, line numbering).
Trade-offs:
- No real-time client-side editing (but we can pair with Monaco Editor for advanced use cases).
- Slightly higher server load for dynamic sites (mitigated by caching).
Prototype: I’ll spin up a test in our [docs repo] to validate performance vs. Prism.js—expect ~30% faster renders and no JS errors in edge cases."*
*"This change lets us:
- Improve accessibility: No reliance on JS means code blocks work for users with disabled scripts.
- Enhance branding: Custom themes (e.g., dark mode, corporate colors) without CSS hacks.
- Add interactive elements: ‘Run this code’ buttons with pre-highlighted output (e.g., for tutorials).
- Support terminal users: Highlight CLI logs/configs (e.g.,
nginx.conf) natively in our platform.- Future-proof: As we add languages (e.g., GraphQL for our API docs), we won’t need new JS dependencies.
Example: Our [API docs] could now include interactive GraphQL queries with syntax highlighting, improving onboarding."*
How can I help you explore Laravel packages today?