PHPackages                             tovic/parsedown-extra-plugin - 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. tovic/parsedown-extra-plugin

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

tovic/parsedown-extra-plugin
============================

Configurable Markdown to HTML converter with Parsedown Extra.

v1.3.11(2y ago)5933.7k—10%13[1 PRs](https://github.com/taufik-nurrohman/parsedown-extra-plugin/pulls)MITPHP

Since Jul 8Pushed 2y ago8 watchersCompare

[ Source](https://github.com/taufik-nurrohman/parsedown-extra-plugin)[ Packagist](https://packagist.org/packages/tovic/parsedown-extra-plugin)[ Docs](https://github.com/taufik-nurrohman/parsedown-extra-plugin)[ Fund](https://paypal.me/tatautaufik)[ RSS](/packages/tovic-parsedown-extra-plugin/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (18)Used By (0)

Extension for [Parsedown Extra](https://github.com/erusev/parsedown-extra)
==========================================================================

[](#extension-for-parsedown-extra)

> Configurable Markdown to HTML converter with Parsedown Extra.

**Update 2023/09/03:** I will be retiring this project due to the lack of activity on the Parsedown project to date. There is actually a draft for [Parsedown version 2.0](https://github.com/erusev/parsedown/tree/2.0.x), but it seems that there has been no progress. I will consider refactoring when Parsedown version 2.0 is released, but I may no longer actively maintain this project as I am now shifting my focus to [my own Markdown Extra parser](https://github.com/taufik-nurrohman/markdown). It consists of a single file and uses the same methods as Parsedown to separate blocks and inlines, so it should achieve similar (or even better) speed and efficiency.

[![Parsedown Logo](https://user-images.githubusercontent.com/1669261/109982015-10e2c300-7d34-11eb-93bd-5f103b9d5165.png)](https://user-images.githubusercontent.com/1669261/109982015-10e2c300-7d34-11eb-93bd-5f103b9d5165.png)

Usage
-----

[](#usage)

### Manual

[](#manual)

Include `ParsedownExtraPlugin.php` just after the `Parsedown.php` and `ParsedownExtra.php` file:

```
require 'Parsedown.php';
require 'ParsedownExtra.php';
require 'ParsedownExtraPlugin.php';

# Create
$Parsedown = new ParsedownExtraPlugin;

# Configure
$Parsedown->voidElementSuffix = '>'; // HTML5

# Use
echo $Parsedown->text('# Header {.sth}');
```

### Composer

[](#composer)

From the file manager interface, create a `composer.json` file in your project folder, then add this content:

```
{
  "minimum-stability": "dev"
}
```

From the command line interface, navigate to your project folder then run this command:

```
composer require taufik-nurrohman/parsedown-extra-plugin
```

From the file manager interface, create an `index.php` file in your project folder then require the auto-loader file:

```
require 'vendor/autoload.php';

# Create
$Parsedown = new ParsedownExtraPlugin;

# Configure
$Parsedown->voidElementSuffix = '>'; // HTML5

# Use
echo $Parsedown->text('# Header {.sth}');
```

Features
--------

[](#features)

### HTML or XHTML

[](#html-or-xhtml)

```
$Parsedown->voidElementSuffix = '>'; // HTML5
```

### Predefined Abbreviations

[](#predefined-abbreviations)

```
$Parsedown->abbreviationData = [
    'CSS' => 'Cascading Style Sheet',
    'HTML' => 'Hyper Text Markup Language',
    'JS' => 'JavaScript'
];
```

### Predefined Reference Links and Images

[](#predefined-reference-links-and-images)

```
$Parsedown->referenceData = [
    'mecha-cms' => [
        'url' => 'https://mecha-cms.com',
        'title' => 'Mecha CMS'
    ],
    'test-image' => [
        'url' => 'http://example.com/favicon.ico',
        'title' => 'Test Image'
    ]
);
```

### Automatic `rel="nofollow"` Attribute on External Links

[](#automatic-relnofollow-attribute-on-external-links)

```
$Parsedown->linkAttributes = function ($Text, $Attributes, &$Element, $Internal) {
    if (!$Internal) {
        return [
            'rel' => 'nofollow',
            'target' => '_blank';
        ];
    }
    return [];
};
```

### Automatic `id` Attribute on Headers

[](#automatic-id-attribute-on-headers)

```
$Parsedown->headerAttributes = function ($Text, $Attributes, &$Element, $Level) {
    $Id = $Attributes['id'] ?? trim(preg_replace('/[^a-z\d\x{4e00}-\x{9fa5}]+/u', '-', strtolower($Text)), '-');
    return ['id' => $Id];
};
```

### Automatic Figure Elements

[](#automatic-figure-elements)

Every image markup that appears alone in a paragraph will be converted into a figure element automatically.

```
$Parsedown->figuresEnabled = true;
$Parsedown->figureAttributes = ['class' => 'image'];

$Parsedown->imageAttributesOnParent = ['class', 'id'];
```

To add a caption below the image, prepend at least one space but less than four spaces to turn the paragraph sequence that comes after the image into an image caption.

```
This is a paragraph.

![Image](/path/to/image.jpg)
 Image caption.

This is a paragraph.

![Image](/path/to/image.jpg)

 Image caption in a paragraph tag.

This is a paragraph.

![Image](/path/to/image.jpg)

    This is a code block.

This is a paragraph.
```

FYI, this format is also valid for average Markdown files. And so, it will degraded gracefully when parsed by other Markdown converters.

### Custom Code Block Class Format

[](#custom-code-block-class-format)

```
$Parsedown->blockCodeClassFormat = 'language-%s';
```

### Custom Code Block Contents

[](#custom-code-block-contents)

```
$Parsedown->codeHtml = '%s';
$Parsedown->blockCodeHtml = '%s';
```

```
//
function doApplyHighlighter(string $Text, array $ClassList, &$Element) {
    $Highlight = new \Highlight\Highlighter;
    $Highlight->setAutodetectLanguages($ClassList);
    $Highlighted = $Highlight->highlightAuto($Text);
    $Element['attributes']['class'] = 'hljs ' . $Highlighted->language;
    return $Highlighted->value;
}

$Parsedown->codeHtml = function ($Text, $Attributes, &$Element) {
    return doApplyHighlighter($Text, [], $Element);
};

$Parsedown->blockCodeHtml = function ($Text, $Attributes, &$Element) {
    $ClassList = array_filter(explode(' ', $Attributes['class'] ?? ""));
    return doApplyHighlighter($Text, $ClassList, $Element);
};
```

### Put `` Attributes on `` Element

[](#put-code-attributes-on-pre-element)

```
$Parsedown->codeAttributesOnParent = true;
```

### Custom Quote Block Class

[](#custom-quote-block-class)

```
$Parsedown->blockQuoteAttributes = ['class' => 'quote'];
```

```
$Parsedown->blockQuoteAttributes = function ($Text, $Attributes, &$Element) {
    if (strpos($Text, '**Danger:** ') === 0) {
        return ['class' => 'alert alert-danger'];
    }
    if (strpos($Text, '**Info:** ') === 0) {
        return ['class' => 'alert alert-info'];
    }
    return [];
};
```

### Custom Table Attributes

[](#custom-table-attributes)

```
$Parsedown->tableAttributes = ['border' => 1];
```

### Custom Table Alignment Class

[](#custom-table-alignment-class)

```
$Parsedown->tableColumnAttributes = function ($Text, $Attributes, &$Element, $Align) {
    return [
        'class' => $Align ? 'text-' . $Align : null,
        'style' => null // Remove inline styles
    ];
};
```

### Custom Footnote ID Format

[](#custom-footnote-id-format)

```
$Parsedown->footnoteLinkAttributes = function ($Number, $Attributes, &$Element, $Name) {
    return ['href' => '#to:' . $Name];
};

$Parsedown->footnoteReferenceAttributes = function ($Number, $Attributes, &$Element, $Name, $Index) {
    return ['id' => 'from:' . $Name . '.' . $Index];
};

$Parsedown->footnoteBackLinkAttributes = function ($Number, $Attributes, &$Element, $Name, $Index) {
    return ['href' => '#from:' . $Name . '.' . $Index];
};

$Parsedown->footnoteBackReferenceAttributes = function ($Number, $Attributes, &$Element, $Name, $Total) {
    return ['id' => 'to:' . $Name];
};
```

### Custom Footnote Class

[](#custom-footnote-class)

```
$Parsedown->footnoteAttributes = ['class' => 'notes'];
```

### Custom Footnote Link Text

[](#custom-footnote-link-text)

```
$Parsedown->footnoteLinkHtml = '[%s]';
```

### Custom Footnote Back Link Text

[](#custom-footnote-back-link-text)

```
$Parsedown->footnoteBackLinkHtml = '';
```

### Advance Attribute Parser

[](#advance-attribute-parser)

- `{#foo}` → ``
- `{#foo#bar}` → ``
- `{.foo}` → ``
- `{.foo.bar}` → ``
- `{#foo.bar.baz}` → ``
- `{#foo .bar .baz}` → `` (white-space before `#` and `.` becomes optional in my extension)
- `{foo="bar"}` → ``
- `{foo="bar baz"}` → ``
- `{foo='bar'}` → ``
- `{foo='bar baz'}` → ``
- `{foo=bar}` → ``
- `{foo=}` → ``
- `{foo}` → ``
- `{foo=bar baz}` → ``
- `{#a#b.c.d e="f" g="h i" j='k' l='m n' o=p q= r s t="u#v.w.x y=z"}` → ``

### Code Block Class Without `language-` Prefix

[](#code-block-class-without-language--prefix)

Dot prefix in class name are now becomes optional, custom attributes syntax also acceptable:

- `php` → ``
- `php html` → ``
- `.php` → ``
- `.php.html` → ``
- `.php html` → ``
- `{.php #foo}` → ``

Property Aliases as Methods
---------------------------

[](#property-aliases-as-methods)

Property aliases are available as methods just to follow the way **Parsedown** set its configuration data. It uses PHP `__call()` method to generate the class methods automatically:

```
// This is …
$Parsedown->setBlockCodeHtml(function () { … });

// … equal to this
$Parsedown->blockCodeHtml = function () { … };
```

Support
-------

[](#support)

I’m looking for digital agencies and web designers who are interested in trying out my content management system, [Mecha](https://github.com/mecha-cms). Mecha is a minimalist content management system for building simple websites ranging from web company profile to web log for personal branding. It is a file-based content management system and does not take up too much web hosting space so:

1. From the client’s point of view, this can reduce their monthly hosting expenses.
2. From the web designer’s point of view, this will increase your company’s profits.

I prefer designers who don’t really understand programming languages but understand the basics of creating web themes. So that my JavaScript and PHP skills can help you to solve the problems related to the back-end side features of your web project. Then, I can get rewarded when you use the panel feature on your clients’ projects.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~94 days

Recently: every ~126 days

Total

17

Last Release

988d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8f3805cca9aeaeb2e2d6a3bc796f98cd9fa9e36d0a064559ffc716c8ce73f0b?d=identicon)[taufik-nurrohman](/maintainers/taufik-nurrohman)

---

Top Contributors

[![taufik-nurrohman](https://avatars.githubusercontent.com/u/1669261?v=4)](https://github.com/taufik-nurrohman "taufik-nurrohman (91 commits)")[![S1SYPHOS](https://avatars.githubusercontent.com/u/12161504?v=4)](https://github.com/S1SYPHOS "S1SYPHOS (5 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (1 commits)")

---

Tags

extensionextramarkdownparserphpextraparsermarkdownmarkdown-extraextensionparsedownparsedown-extramarkdown extra extensionparsedown extra extension

### Embed Badge

![Health badge](/badges/tovic-parsedown-extra-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/tovic-parsedown-extra-plugin/health.svg)](https://phpackages.com/packages/tovic-parsedown-extra-plugin)
```

###  Alternatives

[taufik-nurrohman/parsedown-extra-plugin

Configurable Markdown to HTML converter with Parsedown Extra.

5932.3k](/packages/taufik-nurrohman-parsedown-extra-plugin)[erusev/parsedown-extra

An extension of Parsedown that adds support for Markdown Extra.

84314.8M192](/packages/erusev-parsedown-extra)[alfredo-ramos/parsedown-extra-laravel

A Parsedown Extra package for Laravel

30155.1k1](/packages/alfredo-ramos-parsedown-extra-laravel)[pagerange/metaparsedown

Adds ability to have meta data in markdown files parsed by eursev/parsedown or eruseve/parsedown-extra

2637.2k2](/packages/pagerange-metaparsedown)[benjaminhoegh/parsedown-extended

An extension for Parsedown.

5022.6k1](/packages/benjaminhoegh-parsedown-extended)[leblanc-simon/parsedown-checkbox

An extension of Parsedown and ParsedownExtra that adds support for checkbox

181.4k1](/packages/leblanc-simon-parsedown-checkbox)

PHPackages © 2026

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