定制 wnx/commonmark-mark-extension 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist Tests Check & fix styling Total Downloads

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

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-25