How to convert markdown to html: 1. Use the Parsedown conversion library to convert markdown to html; 2. Convert markdown to html through the PHP Markdown tool.
Recommended: "PHP Video Tutorial"
Two PHP versions of markdown to html open source Library
The way of writing markdown has become popular. Various editors have built-in markdown parsers, which can convert markdown into various beautiful styles. So is there a similar library in PHP? How to convert markdown text to html? Yes, I will introduce 2 models to you today.
1. Parsedown
Introducing two PHP markdown to HTML open source libraries
Parsedown is a very compact PHP markdown conversion library with only one PHP file. , the code is also very capable, and the execution efficiency is also very fast.
Just look at the comparison
Introducing two PHP versions of markdown to HTML open source libraries
Specific code:
<?php $Parsedown = new Parsedown(); echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p> ?>
2. PHP Markdown
PHP Markdown 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 in an easy-to-read, easy-to-write plain text format that is then converted into 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 plain text markup into HTML. PHP Markdown is a PHP port of John Gruber's original Markdown program.
php markdown can also automatically use the functions of interpreter and filter, which is also very powerful
Convert code
<?php use Michelf\Markdown; $my_html = Markdown::defaultTransform($my_text); ?>
Both php markdown are very powerful,
Two markdown online webide addresses http://editor.bfw.wiki/Studio/Open.html?projectid=15759698453773380035
github https://github.com/erusev/parsedown
github https://github.com/michelf/php-markdown
The above is the detailed content of How to convert php markdown to html. For more information, please follow other related articles on the PHP Chinese website!