| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
dc4g
9年前发布

PHP Markdown 解析器:PHP Markdown

PHP Markdown 包括 PHP Markdown 解析器和其他 PHP Markdown 编辑器的额外功能。

Introduction

This is a library package that includes the PHP Markdown parser and its sibling PHP Markdown Extra with additional features.

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

"Markdown" is actually two things: a plain text markup syntax, and a software tool, originally written in Perl, that converts the plain text markup to HTML. PHP Markdown is a port to PHP of the original Markdown program by John Gruber.

Requirement

This library package requires PHP 5.3 or later.

Note: The older plugin/library hybrid package for PHP Markdown and PHP Markdown Extra is still maintained and will work with PHP 4.0.5 and later.

Before PHP 5.3.7, pcre.backtrack_limit defaults to 100 000, which is too small in many situations. You might need to set it to higher values. Later PHP releases defaults to 1 000 000, which is usually fine.

Usage

This library package is meant to be used with class autoloading. For autoloading to work, your project needs have setup a PSR-0-compatible autoloader. See the included Readme.php file for a minimal autoloader setup. (If you cannot use autoloading, see below.)

With class autoloading in place, putting the 'Michelf' folder in your include path should be enough for this to work:

use \Michelf\Markdown;  $my_html = Markdown::defaultTransform($my_text);

Markdown Extra syntax is also available the same way:

use \Michelf\MarkdownExtra;  $my_html = MarkdownExtra::defaultTransform($my_text);

If you wish to use PHP Markdown with another text filter function built to parse HTML, you should filter the text after thetransformfunction call. This is an example with [PHP SmartyPants][psp]:

use \Michelf\Markdown, \Michelf\SmartyPants;  $my_html = Markdown::defaultTransform($my_text);  $my_html = SmartyPants::defaultTransform($my_html);

All these examples are using the staticdefaultTransformstatic function found inside the parser class. If you want to customize the parser configuration, you can also instantiate it directly and change some configuration variables:

use \Michelf\MarkdownExtra;  $parser = new MarkdownExtra;  $parser->fn_id_prefix = "post22-";  $my_html = $parser->transform($my_text);

To learn more, see the full list of configuration variables.


项目主页:
http://www.open-open.com/lib/view/home/1439898440458

 本文由用户 dc4g 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1439898440458.html
Markdown处理库 Markdown