✨ feat: 更新问题页面和提交页面,集成Vditor适配器,优化Markdown渲染
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
?>
|
||||
<?php include("template/$OJ_TEMPLATE/header.php");?>
|
||||
<?php include("include/bbcode.php");?>
|
||||
<script src="<?php echo "template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<div class="padding">
|
||||
<h1><?php echo $news_title ?></h1>
|
||||
<div class="ui existing segment">
|
||||
@@ -15,37 +15,47 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$(".md").each(function(){
|
||||
$(this).html(marked.parse($(this).text()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
});
|
||||
function addMarkdownInputOutputLabels() {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Input?>"+i+":</div>");
|
||||
}
|
||||
});
|
||||
$(".language-output"+i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
function styleMarkdownTables() {
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
});
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
HustOJVditor.renderMarkdownBlocks('.md', {
|
||||
useTextContent: true
|
||||
}).then(function () {
|
||||
addMarkdownInputOutputLabels();
|
||||
styleMarkdownTables();
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render discuss markdown.', error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php include("template/$OJ_TEMPLATE/footer.php");?>
|
||||
|
||||
Reference in New Issue
Block a user