Torchlight.dev — 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.

Installation

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,
4],

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.

Configuration

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:

1```php
2echo "This is php!";
3```
4
5```js
6console.log("This is javascript!")
7```
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!";
3```
4
5```js theme:winter-is-coming-blue
6console.log("Winter is coming, blue!")
7```
1echo "Winter is coming, dark!";
1console.log("Winter is coming, blue!")
A Hammerstone, LLC Product.
Built with Love & Care by Aaron in Dallas, Texas.