— The VS Code Compatible Syntax Highlighting API.

CommonMark PHP Client

Tests Latest Stable Version Total Downloads License GitHub

The CommonMark PHP Client is an extension for the excellent League\Commonmark package.


To install, require the package from composer:

1composer require torchlight/torchlight-commonmark

This will install the Laravel Client as well.

Enabling the Extension

If you are using Graham Campbell's Laravel Markdown package, you can add the extension in your markdown.php file, under the "extensions" key.

1'extensions' => [
2 // Torchlight syntax highlighting
3 TorchlightExtension::class,

If you aren't using the Laravel Markdown package, you can add the extension manually:

1$environment = Environment::createCommonMarkEnvironment();
2$environment->addExtension(new TorchlightExtension);

That's all you need to do! All of your code fences will now be highlighted via Torchlight.


Once the package is downloaded, you can run the following command to publish your configuration file:

1php artisan torchlight:install

To read about all the configuration options available in your torchlight.php file, head over to the Laravel client documentation.

Language & Theme

To set the language of a code block, set the key of the language after the three backticks:

2echo "This is php!";
6console.log("This is javascript!")
1echo "This is php!";
1console.log("This is javascript!")

Your global theme is controlled by your torchlight.php file, but if you want to change a single block you can pass the key of a theme using the theme:key attribute after the language:

1```php theme:winter-is-coming-dark
2echo "Winter is coming, dark!";
5```js theme:winter-is-coming-blue
6console.log("Winter is coming, blue!")
1echo "Winter is coming, dark!";
1console.log("Winter is coming, blue!")
A Hammerstone, LLC Product.
Built with Love & Care by Aaron in Dallas, Texas.