在错误的地方也加上markdown转义

This commit is contained in:
2025-04-11 13:36:46 +08:00
parent 74f712e776
commit 5504685bca
2 changed files with 20 additions and 15 deletions

View File

@@ -63,20 +63,6 @@ if(isset($_GET['keyword']) && $_GET['keyword']!=""){
</form>
</center>
<?php
/*
echo "<select class='input-mini' onchange=\"location.href='problem_list.php?page='+this.value;\">";
for ($i=1;$i<=$cnt;$i++){
if ($i>1) echo '&nbsp;';
if ($i==$page) echo "<option value='$i' selected>";
else echo "<option value='$i'>";
echo $i+9;
echo "**</option>";
}
echo "</select>";
*/
?>
<center>
<table width=100% border=1 style="text-align:center;">
<form id='pform' method=post action=contest_add.php >

View File

@@ -30,13 +30,32 @@
margin-bottom: -10px !important;
}
</style>
<?php
function trans_md($str)
{
$s = $str;
$s = bbcode_to_html($s);
if (
strpos($s, "class='md") === false &&
strpos($s, "class=\"md") === false
) // 没找到,那就加上
$s = "<span class='md'>" . $s . "</span>";
// 删除代码块里的<br />防止引起混乱
$s = preg_replace_callback('/(```.*?```|`[^`]*`)/s', function ($matches) {
return str_replace('<br />', '', $matches[0]);
}, $s);
// 特殊转义
$s = str_replace("<br />", "\n", $s);
return $s;
}
?>
<div class="padding">
<div style="margin-top: 0px; margin-bottom: 14px; " v-if="content != null && content !== ''">
<p class="transition visible">
<strong ><?php echo "$MSG_ERROR_INFO";?> </strong>
</p>
<div class="ui existing segment">
<pre v-if="escape" style="margin-top: 0; margin-bottom: 0; " id="errtxt"><?php echo $view_reinfo?></pre>
<pre v-if="escape" style="margin-top: 0; margin-bottom: 0; " id="errtxt"><?php echo trans_md($view_reinfo)?></pre>
</div>
</div>