PHPackages                             kaoken/markdown-it-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. kaoken/markdown-it-php

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

kaoken/markdown-it-php
======================

PHP version makdown-it

14.3.0.0(3w ago)3137.1k↓43.8%102MITPHPPHP &gt;=7.4.0CI failing

Since Mar 7Pushed 3w ago4 watchersCompare

[ Source](https://github.com/yasuken2013/markdown-it-php)[ Packagist](https://packagist.org/packages/kaoken/markdown-it-php)[ RSS](/packages/kaoken-markdown-it-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (2)Versions (36)Used By (2)

markdown-it-php
===============

[](#markdown-it-php)

[![Build Status](https://camo.githubusercontent.com/b0c6c6845a74cb65a7f0a32bdcfd8fbf80eeb40026c4029af424ab371c94b8bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e)](https://github.com/kaoken/markdown-it-php)[![composer version](https://camo.githubusercontent.com/a62fec39f9bdb65867f8f0cfc7ffc846d2d9b633a6633b374cd3b57a1bd68c66/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d31342e332e302e302d626c75652e737667)](https://github.com/kaoken/markdown-it-php)[![licence](https://camo.githubusercontent.com/84ba0b50ad44e854f0382b3a99afaef96f3d4db9e861686a3297ccd3bd397de7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4d49542d626c75652e737667)](https://github.com/kaoken/markdown-it-php)[![php version](https://camo.githubusercontent.com/eac1dcefafd5a94f5b6a96aa9a30de2b3fb7aa2e1397b0f2e34b0e293a5bd28a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70687025323076657273696f6e2d254532253839254137372e342e302d7265642e737667)](https://github.com/kaoken/markdown-it-php)

This gem is a port of the [markdown-it Javascript package](https://github.com/markdown-it/markdown-it) by Vitaly Puzrin and Alex Kocharin. Currently synced with markdown-it 14.3.0

**[Javascript Live demo](https://markdown-it.github.io)**

- Follows the **[CommonMark spec](http://spec.commonmark.org/)** + adds syntax extensions &amp; sugar (URL autolinking, typographer).
- Configurable syntax! You can add new rules and even replace existing ones.
- [Safe](https://github.com/markdown-it/markdown-it/tree/master/docs/security.md) by default.

**Table of content**

- [Install](#install)
- [Syntax extensions](#syntax-extensions)
- [References / Thanks](#references--thanks)
- [License](#license)

Install
-------

[](#install)

**composer**:

```
composer require kaoken/markdown-it-php
```

### Simple

[](#simple)

```
$md = new MarkdownIt();
$result = $md->render('# markdown-it rulezz!');
```

Single line rendering, without paragraph wrap:

```
$md = new MarkdownIt();
$result = $md->renderInline('__markdown-it__ rulezz!');
```

### Init with presets and options

[](#init-with-presets-and-options)

(\*) presets define combinations of active rules and options. Can be `"commonmark"`, `"zero"` or `"default"` (if skipped).

```
// commonmark mode
$md = new MarkdownIt('commonmark');

// default mode
$md = new MarkdownIt();

// enable everything
$md = new MarkdownIt([
  "html"=>        true,
  "linkify"=>     true,
  "typographer"=> true
]);

// full options list (defaults)
$md = new MarkdownIt([
  "html"=>         false,        // Enable HTML tags in source
  "xhtmlOut"=>     false,        // Use '/' to close single tags ().
                                 // This is only for full CommonMark compatibility.
  "breaks"=>       false,        // Convert '\n' in paragraphs into
  "langPrefix"=>   'language-',  // CSS language prefix for fenced blocks. Can be
                                 // useful for external highlighters.
  "linkify"=>      false,        // Autoconvert URL-like text to links

  // Enable some language-neutral replacement + quotes beautification
  // For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js
  "typographer"=>  false,

  // Double + single quotes replacement pairs, when typographer enabled,
  // and smartquotes on. Could be either a String or an Array.
  //
  // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  "quotes"=> '“”‘’',

  // Highlighter function. Should return escaped HTML,
  // or '' if the source string is not changed and should be escaped externaly.
  // If $result starts with
  "highlight"=> function (/*str, lang*/) { return ''; }
]);
```

### Plugins load

[](#plugins-load)

```
$md = new MarkdownIt()
            ->plugin(plugin1)
            ->plugin(plugin2, opts, ...)
            ->plugin(plugin3);
```

### Syntax highlighting

[](#syntax-highlighting)

Apply syntax highlighting to fenced code blocks with the `highlight` option:
**The sample here is only the highlight of the PHP language.**

```
// Actual default values
$md = new MarkdownIt([
  "highlight"=> function ($str, $lang) {
    if ( $lang ) {
      try {
        return highlight_string($str);
      } catch (Exception $e) {}
    }

    return ''; // use external default escaping
  }
]);
```

Or with full wrapper override (if you need assign class to ``):

```
// Actual default values
$md = new MarkdownIt([
  "highlight"=> function ($str, $lang) {
    if ( $lang ) {
      try {
        return '' .
               highlight_string($str) .
               '';
      } catch (Exception $e) {}
    }

    return '' . $md->utils->escapeHtml($str) . '';
  }
]);
```

### Linkify

[](#linkify)

`linkify: true` uses [linkify-it](https://github.com/markdown-it/linkify-it). To configure linkify-it, access the linkify instance through `$md->linkify`:

```
$md->linkify->set(['fuzzyEmail'=>false]);  // disables .py as top level domain
```

Syntax extensions
-----------------

[](#syntax-extensions)

Embedded (enabled by default):

- [Tables](https://help.github.com/articles/organizing-information-with-tables/) (GFM)
- [Strikethrough](https://help.github.com/articles/basic-writing-and-formatting-syntax/#styling-text) (GFM)

The following plugins are in the **kaoken\\markdown-it-php\\MarkdownIt\\Plugins** directory:

- [subscript](https://github.com/markdown-it/markdown-it-sub) `\MarkdownItSub`
- [superscript](https://github.com/markdown-it/markdown-it-sup) `\MarkdownItSup`
- [footnote](https://github.com/markdown-it/markdown-it-footnote) `\MarkdownItFootnote`
- [definition list](https://github.com/markdown-it/markdown-it-deflist) `\MarkdownItDeflist`
- [abbreviation](https://github.com/markdown-it/markdown-it-abbr) `\MarkdownItAbbr`
- [emoji](https://github.com/markdown-it/markdown-it-emoji) `\MarkdownItEmoji`
- [custom container](https://github.com/markdown-it/markdown-it-container) `\MarkdownItContainer`
- [insert](https://github.com/markdown-it/markdown-it-ins) `\MarkdownItIns`
- [mark](https://github.com/markdown-it/markdown-it-mark) `\MarkdownItMark`

### Manage rules

[](#manage-rules)

By default all rules are enabled, but can be restricted by options. On plugin load all its rules are enabled automatically.

```
// Activate/deactivate rules, with currying
$md = (new MarkdownIt())
            ->disable([ 'link', 'image' ])
            ->enable([ 'link' ])
            ->enable('image');

// Enable everything
$md = new MarkdownIt([
  "html"        => true,
  "linkify"     => true,
  "typographer" => true,
]);
```

You can find all rules in sources: [ParserCore](src/MarkdownIt/ParserCore.php), [ParserBlock](src/MarkdownIt/ParserBlock.php), [ParserInline](src/MarkdownIt/ParserInline.php).

References / Thanks
-------------------

[](#references--thanks)

Thanks to the authors of the original implementation in Javascript, [markdown-it](https://github.com/markdown-it/markdown-it):

- Alex Kocharin [github/rlidwka](https://github.com/rlidwka)
- Vitaly Puzrin [github/puzrin](https://github.com/puzrin)

and to [John MacFarlane](https://github.com/jgm) for his work on the CommonMark spec and reference implementations.

**Related Links:**

-  - reference CommonMark implementations in C &amp; JS, also contains latest spec &amp; online demo.
-  - CommonMark forum, good place to collaborate developers' efforts.

License
-------

[](#license)

[MIT](https://github.com/markdown-it/markdown-it/blob/master/LICENSE)

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance95

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~100 days

Recently: every ~255 days

Total

35

Last Release

26d ago

Major Versions

9.1.0.0 → 10.0.0.02019-09-15

10.0.0.0 → 11.0.0.02020-05-21

11.0.1.1 → 12.0.0.02020-10-17

12.3.2.0 → 13.0.0.02022-04-24

13.0.2.0 → 14.0.0.02023-12-17

PHP version history (3 changes)8.3.101PHP &gt;=5.6.4

9.0.0.0PHP &gt;=7.3.6

11.0.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6100263?v=4)[kaoken(kenji yasuda)](/maintainers/kaoken)[@kaoken](https://github.com/kaoken)

---

Top Contributors

[![kaoken](https://avatars.githubusercontent.com/u/6100263?v=4)](https://github.com/kaoken "kaoken (7 commits)")[![MadCat34](https://avatars.githubusercontent.com/u/2991965?v=4)](https://github.com/MadCat34 "MadCat34 (3 commits)")[![Stancobridge](https://avatars.githubusercontent.com/u/22870440?v=4)](https://github.com/Stancobridge "Stancobridge (1 commits)")

---

Tags

commonmarkmarkdownmarkdown-itphpmarkdownmarkdown-it

### Embed Badge

![Health badge](/badges/kaoken-markdown-it-php/health.svg)

```
[![Health](https://phpackages.com/badges/kaoken-markdown-it-php/health.svg)](https://phpackages.com/packages/kaoken-markdown-it-php)
```

###  Alternatives

[erusev/parsedown

Parser for Markdown.

15.1k158.5M922](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k450.4M1.2k](/packages/league-commonmark)[michelf/php-markdown

PHP Markdown

3.5k55.2M397](/packages/michelf-php-markdown)[league/html-to-markdown

An HTML-to-markdown conversion helper for PHP

1.9k33.5M370](/packages/league-html-to-markdown)[cebe/markdown

A super fast, highly extensible markdown parser for PHP

1.0k34.6M156](/packages/cebe-markdown)[erusev/parsedown-extra

An extension of Parsedown that adds support for Markdown Extra.

84515.5M232](/packages/erusev-parsedown-extra)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
