Home > Backend Development > PHP Problem > How to convert php markdown to html

How to convert php markdown to html

藏色散人
Release: 2023-03-06 09:16:01
Original
2951 people have browsed it

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.

How to convert php markdown to html

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(&#39;Hello _Parsedown_!&#39;); # prints: <p>Hello <em>Parsedown</em>!</p>
?>
Copy after login

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);
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template