league / commonmark-ext-smartpunct
v1.2.0
2020-04-04 15:23 UTC
Requires
- php: ^7.1
- league/commonmark: ^1.3
Requires (Dev)
- jgm/smartpunct: 0.29
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2020-04-04 15:24:07 UTC
README
已弃用
此扩展已被弃用。现在所有功能都包含在 league/commonmark
1.3+ 版本的 League\CommonMark\Extension\SmartPunct
命名空间中,因此您应该升级到该版本并使用该捆绑扩展,而不是此扩展。
概述
智能地将ASCII引号、破折号和省略号转换为它们的Unicode等效字符。适用于 league/commonmark
PHP Markdown解析器。
例如,以下Markdown...
"CommonMark is the PHP League's Markdown parser," she said. "It's super-configurable... you can even use additional extensions to expand its capabilities -- just like this one!"
将生成以下HTML
<p>“CommonMark is the PHP League’s Markdown parser,” she said. “It’s super-configurable… you can even use additional extensions to expand its capabilities – just like this one!”</p>
安装
通过Composer
$ composer require league/commonmark-ext-smartpunct
用法
可以将扩展添加到任何新的 环境
use League\CommonMark\CommonMarkConverter; use League\CommonMark\Environment; use League\CommonMark\Ext\SmartPunct\SmartPunctExtension; // Obtain a pre-configured Environment with all the CommonMark parsers/renderers ready-to-go $environment = Environment::createCommonMarkEnvironment(); // Add this extension $environment->addExtension(new SmartPunctExtension()); // Set your configuration $config = [ 'smartpunct' => [ 'double_quote_opener' => '“', 'double_quote_closer' => '”', 'single_quote_opener' => '‘', 'single_quote_closer' => '’', ], ]; // Instantiate the converter engine and start converting some Markdown! $converter = new CommonMarkConverter($config, $environment); echo $converter->convertToHtml('# Hello World!');
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
测试
$ composer test
安全
如果您发现任何与安全相关的问题,请发送电子邮件至 colinodell@gmail.com,而不是使用问题跟踪器。
致谢
许可
此库使用BSD-3许可证。有关更多信息,请参阅 许可文件