torchlight/torchlight-commonmark
Laravel extension for league/commonmark that highlights Markdown code fences with Torchlight. Works with CommonMark v1 and v2, integrates with GrahamCampbell/Laravel-Markdown or manual environments, and uses the Torchlight Laravel client for fast, JS-free highlighting.
Architecture fit: This package seamlessly integrates with Laravel's ecosystem as a dedicated CommonMark extension. It works natively with Graham Campbell's Laravel Markdown package or raw CommonMark environments, leveraging Laravel's config and caching system. The server-side highlighting eliminates client-side JS dependencies, aligning with modern performance and SEO best practices. The dependency on torchlight/torchlight-laravel ensures consistent API client behavior within Laravel's structure.
Integration feasibility: High feasibility for Laravel projects using CommonMark. Installation is trivial via Composer and artisan commands. Configuration requires minimal setup (token, theme, cache driver) with clear documentation. For existing Markdown implementations, adding the extension is a single-line change. Non-Laravel projects would require significant refactoring to adopt this package.
Technical risk: Moderate. Primary risks include external API dependency (Torchlight API downtime affects rendering), potential rate limiting on the free tier, and version compatibility issues (e.g., deprecated TorchlightExtension in favor of versioned classes). The "0 dependents" metric suggests limited real-world validation, though recent releases (up to v0.6.0 in 2022) indicate active maintenance. Cache misconfiguration could cause stale content or performance issues in distributed environments.
Key questions: What are Torchlight's API rate limits for free/pro tiers? How does cache invalidation handle theme/token changes in multi-server deployments? Are there fallback mechanisms if the API is unavailable? What Laravel versions are fully supported (current v0.6.0 targets Laravel 8+)? How does the package handle large-scale code blocks (e.g., 10k+ lines)?
Stack fit: Ideal for Laravel projects using CommonMark (via Laravel Markdown or direct implementation). Works with PHP 8.0+ and CommonMark v1/v2. Does not support non-Laravel PHP frameworks or other Markdown parsers (e.g., Parsedown). Best suited for documentation-heavy sites where server-side rendering is preferred over client-side JS.
Migration path: For existing Laravel Markdown users: 1) Install package, 2) Add TorchlightExtension to markdown.php extensions array, 3) Publish config. For raw CommonMark: Replace existing parser initialization with version-specific extensions (V1/V2). If migrating from client-side highlighters (e.g., Prism), remove JS dependencies and validate rendered HTML structure matches Torchlight's output.
Compatibility: Fully compatible with Laravel 8-10 (based on dependency constraints). Requires CommonMark v1 or v2. Conflicts may arise if using other CommonMark extensions that modify code block handling. The package explicitly supports per-block theming and file loading (<<< syntax), but older Markdown parsers may need adjustments for these features
How can I help you explore Laravel packages today?