wnx/commonmark-mark-extension
最新稳定版本:v1.4.0
Composer 安装命令:
composer require wnx/commonmark-mark-extension
包简介
Render ==highlighted== texts as <mark> elements in league/commonmark
README 文档
README
A league/commonmark extension to turn highlighted text into <mark>-HTML elements.
For example, the following markdown text …
The ==quick brown fox== jumps over the lazy dog.
… is turned into the following HTML.
<p>The <mark>quick brown fox</mark> jumps over the lazy dog.</p>
Installation
You can install the package via composer:
composer require wnx/commonmark-mark-extension
Usage
Create a custom CommonMark environment, and register the MarkExtension.
use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\MarkdownConverter; use Wnx\CommonmarkMarkExtension\MarkExtension; // Configure the Environment with all the CommonMark parsers/renderers $environment = new Environment(); $environment->addExtension(new CommonMarkCoreExtension()); // Add this extension $environment->addExtension(new MarkExtension()); // Instantiate the converter engine and start converting some Markdown! $converter = new MarkdownConverter($environment); echo $converter->convertToHtml('The ==quick== brown fox jumps over the ==lazy dog==');
If you're using a different character than = to highlight text in Markdown, you can pass a character configuration to the extension.
use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; use League\CommonMark\MarkdownConverter; use Wnx\CommonmarkMarkExtension\MarkExtension; // Define your configuration, if needed $config = [ 'mark' => [ 'character' => ':', ], ]; // Configure the Environment with all the CommonMark parsers/renderers $environment = new Environment($config); $environment->addExtension(new CommonMarkCoreExtension()); // Add this extension $environment->addExtension(new MarkExtension()); // Instantiate the converter engine and start converting some Markdown! $converter = new MarkdownConverter($environment); echo $converter->convertToHtml('The ::quick:: brown fox jumps over the ::lazy dog::');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 12.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-25