PHPackages                             go2digit-al/torchlight-commonmark-php - 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. go2digit-al/torchlight-commonmark-php

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

go2digit-al/torchlight-commonmark-php
=====================================

A Commonmark extension for Torchlight, the syntax highlighting API.

0.6.2(10mo ago)083MITPHPPHP ^8.2

Since Jun 17Pushed 10mo agoCompare

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

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

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

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

[![Tests](https://github.com/torchlight-api/torchlight-commonmark-php/actions/workflows/tests.yml/badge.svg)](https://github.com/torchlight-api/torchlight-commonmark-php/actions/workflows/tests.yml) [![Latest Stable Version](https://camo.githubusercontent.com/3ffb6d77020940ec91f97639d8354b4b00213de0345b06fc3a0e4ebb91aa84e6/68747470733a2f2f706f7365722e707567782e6f72672f746f7263686c696768742f746f7263686c696768742d636f6d6d6f6e6d61726b2f76)](//packagist.org/packages/torchlight/torchlight-commonmark) [![Total Downloads](https://camo.githubusercontent.com/4ad84100dfeaeaacc871bac89e6756dd7c355722bd59a8768a9f25df7f492196/68747470733a2f2f706f7365722e707567782e6f72672f746f7263686c696768742f746f7263686c696768742d636f6d6d6f6e6d61726b2f646f776e6c6f616473)](//packagist.org/packages/torchlight/torchlight-commonmark) [![License](https://camo.githubusercontent.com/f6ee62c80446a04ffceef177d18e6109851c9eccd5609c980acd16b16e527ea0/68747470733a2f2f706f7365722e707567782e6f72672f746f7263686c696768742f746f7263686c696768742d636f6d6d6f6e6d61726b2f6c6963656e7365)](//packagist.org/packages/torchlight/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 webkleur/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:

```
