1
0
mirror of https://github.com/renbaoshuo/UOJ-Luogu-RemoteJudge.git synced 2024-10-18 10:08:49 +00:00
UOJ-Luogu-RemoteJudge/web/app/libs/uoj-html-lib.php

19 lines
498 B
PHP
Raw Permalink Normal View History

2023-03-19 13:29:15 +00:00
<?php
function renderMarkdown($content_md) {
$purifier = HTML::pruifier();
try {
$v8 = new V8Js();
$v8->content_md = $content_md;
$v8->executeString(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/js/marked.js'), 'marked.js');
$content = $v8->executeString('marked(PHP.content_md)');
} catch (V8JsException $e) {
throw new Exception('V8Js error: ' . $e->getMessage());
}
$content = $purifier->purify($content);
return $content;
}