youyiio/beyong-markdown
Composer 安装命令:
composer require youyiio/beyong-markdown
包简介
PHP markdown parse, base on parsedown.
README 文档
README
Configurable Markdown to HTML converter with Parsedown Extra.
Table of Content
- 1. Installation
- 2. Features
- HTML or XHTML
- Predefined Abbreviations
- Predefined Links
- Automatic
rel="nofollow"Attribute on External Links - Custom Code Class Format
- Custom Code Text Format
- Put
<code>Attributes on<pre>Element - Custom Table Class
- Custom Table Alignment Class
- Custom Footnote ID Format
- Custom Footnote Back ID Format
- Custom Footnote Class
- Custom Footnote Link Class
- Custom Footnote Back Link Class
- Custom Footnote Link Text
- Custom Footnote Back Link Text
- Advance Attribute Parser
- Code Block Class Without
language-Prefix
Installation
composer require youyiio/beyong-markdown:^1.0
usage
use beyong\markdown\ParsedownExtraPlugin; use beyong\markdown\ParsedownExtra; $parser = new ParsedownExtraPlugin(); // settings ... $parser->code_class = 'lang-%s'; echo $parser->text('# Header {.sth}');
Features
HTML or XHTML
$parser->element_suffix = '>'; // HTML5
Predefined Abbreviations
$parser->abbreviations = array( 'CSS' => 'Cascading Style Sheet', 'HTML' => 'Hyper Text Markup Language', 'JS' => 'JavaScript' );
Predefined Links
$parser->links = array( 'mecha-cms' => array( 'url' => 'http://mecha-cms.com', 'title' => 'Mecha CMS' ), 'test-image' => array( 'url' => 'http://example.com/favicon.ico', 'title' => 'Test Image' ) );
Automatic rel="nofollow" Attribute on External Links
// custom link attributes $parser->links_attr = array(); // custom external link attributes $parser->links_external_attr = array( 'rel' => 'nofollow', 'target' => '_blank' ); // custom image attributes $parser->images_attr = array( 'alt' => "" ); // custom external image attributes $parser->images_external_attr = array();
Custom Code Class Format
$parser->code_class = 'language-%s';
$parser->code_class = function($text) { return trim(str_replace('.', ' ', $text)); };
Custom Code Text Format
$parser->code_text = '<span class="my-code">%s</span>'; $parser->code_block_text = '<span class="my-code-block">%s</span>';
$parser->code_text = function($text) { return do_syntax_highlighter($text); }; $parser->code_block_text = function($text) { return do_syntax_highlighter($text); };
Put <code> Attributes on <pre> Element
$parser->code_block_attr_on_parent = true;
Custom Table Class
$parser->table_class = 'table-bordered';
Custom Table Alignment Class
$parser->table_align_class = 'text-%s';
Custom Footnote ID Format
$parser->footnote_link_id = 'cite_note:%s';
Custom Footnote Back ID Format
$parser->footnote_back_link_id = 'cite_ref:%s-%s';
Custom Footnote Class
$parser->footnote_class = 'footnotes';
Custom Footnote Link Class
$parser->footnote_link_class = 'footnote-ref';
Custom Footnote Back Link Class
$parser->footnote_back_link_class = 'footnote-backref';
Custom Footnote Link Text
$parser->footnote_link_text = '[%s]';
$parser->footnote_link_text = function($text) { return '[' . $text . ']'; };
Custom Footnote Back Link Text
$parser->footnote_back_link_text = '<i class="icon icon-back"></i>';
Advance Attribute Parser
{#foo}→<tag id="foo">{#foo#bar}→<tag id="bar">{.foo}→<tag class="foo">{.foo.bar}→<tag class="foo bar">{#foo.bar.baz}→<tag id="foo" class="bar baz">{#foo .bar .baz}→<tag id="foo" class="bar baz">(white-space before#and.becomes optional in my extension){foo="bar"}→<tag foo="bar">{foo="bar baz"}→<tag foo="bar baz">{foo='bar'}→<tag foo="bar">{foo='bar baz'}→<tag foo="bar baz">{foo=bar}→<tag foo="bar">{foo=}→<tag foo="">{foo}→<tag foo="foo">{foo=bar baz}→<tag foo="bar" baz="baz">{#a#b.c.d e="f" g="h i" j='k' l='m n' o=p q= r s t="u#v.w.x y=z"}→<tag id="b" class="c d" e="f" g="h i" j="k" l="m n" o="p" q="" r="r" s="s" t="u#v.w.x y=z">
Code Block Class Without language- Prefix
Dot prefix in class name are now becomes optional, custom attributes syntax also acceptable:
php→<pre><code class="language-php">php html→<pre><code class="language-php language-html">.php→<pre><code class="php">.php.html→<pre><code class="php html">.php html→<pre><code class="php language-html">{.php #foo}→<pre><code id="foo" class="php">
youyiio/beyong-markdown 适用场景与选型建议
youyiio/beyong-markdown 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「parser」 「markdown」 「beyongx」 「beyong」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 youyiio/beyong-markdown 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 youyiio/beyong-markdown 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 youyiio/beyong-markdown 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
An MT940 bank statement parser for PHP
Adds more BBCode
Laravel integration for the jsonapi.org parser
A modern HTML DOM parser for PHP using DOMDocument and Symfony CssSelector.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-08