PHPackages                             danielescherzer/commonmark-ext-pygments-highlighter - 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. [Templating &amp; Views](/categories/templating)
4. /
5. danielescherzer/commonmark-ext-pygments-highlighter

ActiveCommonmark-extension[Templating &amp; Views](/categories/templating)

danielescherzer/commonmark-ext-pygments-highlighter
===================================================

CommonMark extension for code highlighting with Pygments

v0.2.0(8mo ago)3377MITPHPPHP ^8.3 || ^8.4CI passing

Since Jul 16Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/DanielEScherzer/commonmark-ext-pygments-highlighter)[ Packagist](https://packagist.org/packages/danielescherzer/commonmark-ext-pygments-highlighter)[ RSS](/packages/danielescherzer-commonmark-ext-pygments-highlighter/feed)WikiDiscussions main Synced 1mo ago

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

CommonMark Extension Pygments Highlighter
=========================================

[](#commonmark-extension-pygments-highlighter)

The `PygmentsHighlighter` extension adds support for using pygments to style blocks of code in Markdown documents.

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

[](#installation)

This extension can be installed from packagist via composer:

```
composer require danielescherzer/commonmark-ext-pygments-highlighter
```

It depends on

- `league/commonmark` (version 2.7 or above; all lower versions have security issues)
- `ramsey/pygments` (version 3.0 or above)

Separately (not enforced via composer) you need to have python and the pygments python library installed. The extension is currently tested against

- Python 3.11, 3.12, and 3.13
- Pygments 2.17, 2.18, and 2.19

The pygments command is assumed to be at `pygmentize` (in the PATH); if this is not the case configure the correct path in the extension setup, see the configuration section below.

Syntax and results
------------------

[](#syntax-and-results)

Sample Markdown input:

```
```php
