mirror of
https://github.com/renbaoshuo/UOJ-Luogu-RemoteJudge.git
synced 2024-12-12 17:46:29 +00:00
19 lines
498 B
PHP
19 lines
498 B
PHP
|
<?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;
|
||
|
}
|