14 lines
528 B
PHP
14 lines
528 B
PHP
<?php
|
|
function decodeMarkdownEntities($markdown) {
|
|
// Decode HTML entities in code blocks
|
|
// $markdown = preg_replace_callback('/(```.*?```|`[^`]*`)/s', function ($matches) {
|
|
// return htmlentities($matches[0], ENT_QUOTES, 'UTF-8');
|
|
// }, $markdown);
|
|
|
|
// Decode HTML entities in inline math and display math
|
|
$markdown = preg_replace_callback('/(\$\$.*?\$\$|\$[^$]*\$)/s', function ($matches) {
|
|
return htmlentities($matches[0], ENT_QUOTES, 'UTF-8');
|
|
}, $markdown);
|
|
return $markdown;
|
|
}
|