修复md格式错误的问题
This commit is contained in:
@@ -1,17 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
function decodeMarkdownEntities($markdown) {
|
function decodeMarkdownEntities($markdown) {
|
||||||
// Decode HTML entities in code blocks
|
// Decode HTML entities in code blocks
|
||||||
$markdown = preg_replace_callback('/(```.*?```|`[^`]*`)/s', function ($matches) {
|
// $markdown = preg_replace_callback('/(```.*?```|`[^`]*`)/s', function ($matches) {
|
||||||
return htmlentities($matches[0], ENT_QUOTES, 'UTF-8');
|
// return htmlentities($matches[0], ENT_QUOTES, 'UTF-8');
|
||||||
}, $markdown);
|
// }, $markdown);
|
||||||
|
|
||||||
// Decode HTML entities in inline math and display math
|
// Decode HTML entities in inline math and display math
|
||||||
$markdown = preg_replace_callback('/(\$\$.*?\$\$|\$[^$]*\$)/s', function ($matches) {
|
$markdown = preg_replace_callback('/(\$\$.*?\$\$|\$[^$]*\$)/s', function ($matches) {
|
||||||
return htmlentities($matches[0], ENT_QUOTES, 'UTF-8');
|
return htmlentities($matches[0], ENT_QUOTES, 'UTF-8');
|
||||||
}, $markdown);
|
}, $markdown);
|
||||||
// 特殊转义
|
|
||||||
$markdown = str_replace("<p>", "", $markdown);
|
|
||||||
$markdown = str_replace("</p>", "\n", $markdown);
|
|
||||||
$markdown = str_replace("<br />", "\n", $markdown);
|
|
||||||
return $markdown;
|
return $markdown;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,9 @@ if ($pr_flag) {
|
|||||||
strpos($s, "class=\"md") === false
|
strpos($s, "class=\"md") === false
|
||||||
) // 没找到,那就加上
|
) // 没找到,那就加上
|
||||||
$s = "<span class='md'>" . $s . "</span>";
|
$s = "<span class='md'>" . $s . "</span>";
|
||||||
$s = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
|
// $s = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
|
||||||
|
// 特殊转义
|
||||||
|
$s = str_replace("<br />", "\n", $s);
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user