in PHP 7.4.27
code:
<?php
$markDownContent="### test_H3 \r\n
#### test_H4";
$c = CommonMark\Parse($markDownContent);
var_dump($c);
echo "The markdown syntax content is converted to html content: \r\n";
$str = CommonMark\Render\HTML($c);
echo $str;
?>
output :
object(CommonMark\Node\Document)#1 (1) {
["children"]=>
array(2) {
[0]=>
object(CommonMark\Node\Heading)#2 (1) {
["children"]=>
array(1) {
[0]=>
object(CommonMark\Node\Text)#4 (1) {
["literal"]=>
string(7) "test_H3"
}
}
}
[1]=>
object(CommonMark\Node\Heading)#3 (1) {
["children"]=>
array(1) {
[0]=>
object(CommonMark\Node\Text)#4 (1) {
["literal"]=>
string(7) "test_H4"
}
}
}
}
}
The markdown syntax content is converted to html content:
<h3>test_H3</h3>
<h4>test_H4</h4>