benjaminhoegh / parsedown-extended
An extension for Parsedown.
Package info
github.com/BenjaminHoegh/ParsedownExtended
pkg:composer/benjaminhoegh/parsedown-extended
Requires
- php: ^7.4 || ^8.0
- ext-mbstring: *
- erusev/parsedown: ^2.0.0-beta-1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpcompatibility/php-compatibility: ^9.3
- phpunit/phpunit: ^9.6
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2026-07-22 09:22:28 UTC
README
ParsedownExtended
A lightweight Parsedown extension with practical Markdown features and configurable output.
Documentation · Report an issue · Discussions
About
ParsedownExtended builds on Parsedown and adds commonly requested Markdown features such as task lists, alerts, heading anchors, table of contents generation, math notation detection, emoji shortcodes, typographic replacements, and more.
Standalone versions of some extended features are also available as separate libraries:
Requirements
- PHP 7.4 or newer
- Parsedown 1.8 or newer
- Parsedown Extra 0.9 or newer when using Composer-installed dependencies
Getting started
Install with Composer:
composer require benjaminhoegh/parsedown-extended
Then include Composer's autoloader and create a parser instance:
require 'vendor/autoload.php'; use BenjaminHoegh\ParsedownExtended\ParsedownExtended; $parsedown = new ParsedownExtended(); echo $parsedown->text('Hello _Parsedown_!');
For inline Markdown only, use the inherited line() method:
echo $parsedown->line('Hello _Parsedown_!');
Configuration
ParsedownExtended exposes a configuration handler through config().
$parsedown = new ParsedownExtended(); $parsedown->config()->set('toc', true); $parsedown->config()->set('toc.levels', ['h1', 'h2', 'h3']); $parsedown->config()->set('math.enabled', true); $parsedown->config()->set('allow_raw_html', false);
Grouped configuration is also supported:
$parsedown->config()->set('toc', [ 'levels' => ['h1', 'h2', 'h3'], 'tag' => '[TOC]', 'id' => 'table-of-contents', ]);
For the full supported API and configuration paths, see the Documentation.
Table of contents
Use text() when you want [TOC] replaced automatically:
echo $parsedown->text($markdown);
Use body() and contentsList() when you want to render the document and table of contents separately:
$body = $parsedown->body($markdown); $toc = $parsedown->contentsList(); echo $toc; echo $body;
Security
ParsedownExtended is a Markdown parser extension, not an HTML sanitizer.
If you render Markdown from untrusted users, review your allow_raw_html setting and sanitize the generated HTML according to your application's threat model.
Please do not open public issues for suspected security vulnerabilities. See SECURITY.md for reporting instructions.
Bugs and feature requests
Before opening an issue, please search existing and closed issues.
- Use issues for reproducible bugs.
- Use discussions for questions, ideas, and support.
- Include a minimal reproduction when reporting bugs.
Open a new issue here: Issues
Contributing
Contributions are welcome, especially focused bug fixes, documentation improvements, and small compatibility fixes.
Before starting large features or refactors, please open a discussion first so the scope can be agreed before work begins.
Please read the contributing guidelines before opening a pull request.
Community
Join GitHub Discussions for questions, ideas, and project discussion.
License
Code is released under the MIT License.
Documentation is released under Creative Commons.