PHPackages                             ousid/torchlight-commonmark - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ousid/torchlight-commonmark

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ousid/torchlight-commonmark
===========================

A Commonmark extension for Torchlight, the syntax highlighting API.

v1.0.0(11mo ago)02MITPHPPHP ^7.2|^8.0|^8.2CI failing

Since May 31Pushed 11mo agoCompare

[ Source](https://github.com/ousid/torchlight-commonmark-php)[ Packagist](https://packagist.org/packages/ousid/torchlight-commonmark)[ Docs](https://torchlight.dev)[ RSS](/packages/ousid-torchlight-commonmark/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (4)Used By (0)

Laravel Torchlight Extension for Commonmark
===========================================

[](#laravel-torchlight-extension-for-commonmark)

[![Tests](https://github.com/ousid/torchlight-commonmark-php/actions/workflows/tests.yml/badge.svg)](https://github.com/ousid/torchlight-commonmark-php/actions/workflows/tests.yml) [![Latest Stable Version](https://camo.githubusercontent.com/c5cca76572ef9d3949a999502e6f7034b37ff9b8b3966124fc3fe63201cbcc15/68747470733a2f2f706f7365722e707567782e6f72672f6f757369642f746f7263686c696768742d636f6d6d6f6e6d61726b2f76)](//packagist.org/packages/ousid/torchlight-commonmark) [![Total Downloads](https://camo.githubusercontent.com/b5c0e820be1ede61b5ec2c2dd9c1e847642be6f76cd73901ae7dac390a81e499/68747470733a2f2f706f7365722e707567782e6f72672f6f757369642f746f7263686c696768742d636f6d6d6f6e6d61726b2f646f776e6c6f616473)](//packagist.org/packages/ousid/torchlight-commonmark) [![License](https://camo.githubusercontent.com/8d503306d699aba34cd2a4a00b3ee07942ba3902b155fe0bc5a8abc185f0792f/68747470733a2f2f706f7365722e707567782e6f72672f6f757369642f746f7263686c696768742d636f6d6d6f6e6d61726b2f6c6963656e7365)](//packagist.org/packages/ousid/torchlight-commonmark)

> 📚 The full docs can be found at [torchlight.dev/docs/clients/commonmark-php](https://torchlight.dev/docs/clients/commonmark-php).

A [Torchlight](https://torchlight.dev) syntax highlighting extension for the PHP League's [Commonmark Markdown Parser](https://commonmark.thephpleague.com/) in a Laravel application.

Supports both CommonMark version 1 and version 2.

Torchlight is a VS Code-compatible syntax highlighter that requires no JavaScript, supports every language, every VS Code theme, line highlighting, git diffing, and more.

Installation
------------

[](#installation)

To install, require the package from composer:

```
composer require ousid/torchlight-commonmark
```

This will install the [Laravel Client](https://github.com/torchlight-api/torchlight-laravel) as well.

Adding the Extension
--------------------

[](#adding-the-extension)

If you are using Graham Campbell's [Laravel Markdown](https://github.com/GrahamCampbell/Laravel-Markdown) package, you can add the extension in your `markdown.php` file, under the "extensions" key.

```
'extensions' => [
    // Torchlight syntax highlighting
    TorchlightExtension::class,
],
```

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

```
// CommonMark V1
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new TorchlightExtension);

// CommonMark V2
$environment = new Environment();
$environment->addExtension(new CommonMarkCoreExtension);
$environment->addExtension(new TorchlightExtension);
```

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

Configuration
-------------

[](#configuration)

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

```
php artisan torchlight:install
```

Once run, you should see a new file `torchlight.php` in you `config` folder, with contents that look like this:

```
