alten/syntax-highlight-bundle
Pros:
Cons:
assets:install is documented).@pre("brush: cpp")).laravel-package-boilerplate) to mimic Symfony’s bundle structure.SyntaxHighlighter historically depended on it). Modern SPAs (React/Vue) may require polyfills or isolation.shCoreMidnight and shThemeMidnight provided).SyntaxHighlighter is vulnerable to XSS if user-provided code is rendered without sanitization (e.g., <pre class="brush: js">{malicious_code}</pre>).fideloper/prose (Laravel-focused).htmlspecialchars or a whitelist).| Component | Fit | Workarounds |
|---|---|---|
| Symfony 3.x+ | ✅ Native support (bundle system). | None needed. |
| Symfony 5/6/7 | ⚠️ Untested (risk of deprecations). | Test thoroughly or use a wrapper. |
| Laravel | ❌ No native support. | - Use Laravel Mix/Vite to bundle assets. |
- Replace Twig tags with Blade directives (e.g., @pre("brush: php")). |
||
| - Create a custom Laravel package. | ||
| JavaScript Stack | ⚠️ jQuery-dependent (may conflict with modern SPAs). | - Polyfill jQuery or isolate in an iframe. |
- Use a CDN for SyntaxHighlighter to avoid bundling. |
||
| CSS Frameworks | ❌ Limited theming (only Midnight theme). | - Override CSS manually or use a custom theme. |
| Headless/SSR | ❌ Client-side only. | - Pre-process code server-side (e.g., with PHP’s highlight_string). |
Symfony Integration:
composer.json ("alten/syntax-highlight-bundle": "dev-master").AppKernel.php.php bin/console assets:install --symlink.AssetComponent changes).Laravel Integration:
public/bundles/altensyntaxhighlight/ via Composer.<script src="{{ asset('bundles/altensyntaxhighlight/js/scripts/shCore.js') }}"></script>
<!-- ... other scripts ... -->
<script>SyntaxHighlighter.all();</script>
laravel-syntax-highlight, and adapt for Blade.laravel-package-boilerplate to scaffold.resources/js/ and resources/css/, then process via Mix/Vite.Modernization Steps:
SyntaxHighlighter build (if available).highlight_string() for SSR, then enhance client-side.AssetMapper or Laravel’s mix-manifest.json.composer update + asset rebuild.SyntaxHighlighter undefined).assets:install; may need adjustments for Symfony 5+.How can I help you explore Laravel packages today?