sc0 / parsedown
Markdown 解析器。
2.1.0
2017-04-24 17:39 UTC
Requires
- php: >=5.5.0
Requires (Dev)
- phpunit/phpunit: ^5.3
- dev-master
- 2.1.0
- 2.0.1
- 2.0.0
- 1.8.1
- 1.7.1
- 1.7.0
- 1.6.0
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- 1.0.0-rc.5
- 1.0.0-rc.4
- 1.0.0-rc.3
- 1.0.0-rc.2
- 1.0.0-rc.1
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.7
- 0.7.6
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.8
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
This package is auto-updated.
Last update: 2024-09-17 07:44:41 UTC
README
PHP中的更优秀的Markdown解析器
功能
- 超级快速
- GitHub 风格
- 可扩展
- 在5.6到7.0及HHVM上测试过
- Markdown Extra 扩展
安装
安装composer包。
示例
use Sc\Parsedown\Parsedown; $Parsedown = new Parsedown(); echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p>
带有重命名标签/属性的复杂示例
use Sc\Parsedown\Parsedown; $replacements = [ 'p' => [ 'tag_name' => 'div', // rename <p> to <div> 'class' => 'paragraph', // add class="paragraph" attribute to div 'data-foo' => 'bar', // add data-foo="bar" attribute to div ], 'em' => [ 'class' => 'em', // don't rename tag, just add class="em" attribute to em ], ]; $Parsedown = new Parsedown($replacements); echo $Parsedown->text('Hello _Parsedown_!'); # prints: <div class="paragraph" data-foo="bar">Hello <em class="em">Parsedown</em>!</div>
问题
Parsedown是如何工作的?
它试图像人类一样读取Markdown。首先,它会查看行。它对行的开始方式感兴趣。这有助于它识别块。例如,如果一行以-
开头,那么它可能属于一个列表。一旦它识别出块,它就会继续到内容。在读取的过程中,它会注意特殊字符。这有助于它识别内联元素(或内联)。
我们称这种方法为“基于行的”。我们相信Parsedown是第一个采用这种方法进行Markdown解析的解析器。自从Parsedown发布以来,其他开发者也采用了相同的方法,在PHP和其他语言中开发了其他Markdown解析器。
它与CommonMark兼容吗?
它通过了大部分的CommonMark测试。大多数未通过测试的情况都涉及到相当不常见的情况。尽管如此,随着CommonMark的成熟,兼容性应该会提高。
谁在使用它?
phpDocumentor,October CMS,Bolt CMS,Kirby CMS,Grav CMS,Statamic CMS,Herbie CMS,RaspberryPi.org等更多。
我如何提供帮助?
使用它,给它加星标,分享它,如果您愿意,还可以捐赠。