cradeq / commonmark-html-whitelist-extension
Allows HTML tags to be used in Markdown, while still escaping or stripping all other HTML input.
Installs: 342
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:commonmark-extension
Requires
- php: ^8.1
- league/commonmark: ^2.5
Requires (Dev)
- phpunit/phpunit: ^10.5.32|^11.4
README
This package allows any HTML tags to be used in Markdown, while still escaping or stripping all other HTML input. Only tags without attributes or styling are supported. Content of the HTML elements remains intact.
Install
This project can be installed via composer:
composer require cradeq/commonmark-html-whitelist-extension
Usage
use Cradeq\CommonMark\HtmlWhitelistExtension; use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; $environment = new Environment([ 'html_input' => 'strip', // Both strip and escape are supported 'html_whitelist' => [ 'tags' => ['br', 'sub'], // Any set of html tags ], ]); $environment->addExtension(new CommonMarkCoreExtension); $environment->addExtension(new HtmlWhitelistExtension);