使用代码标记突出显示HTML代码 - 错误?
问题描述:
我使用highlight.js要突出以下代码:使用代码标记突出显示HTML代码 - 错误?
<pre><code class="hljs php">
echo '<table border="1">';
echo '<tr>';
foreach ($keys as &$k)
{
echo '<th>'.$k.'</th>';
}
echo '</tr>';
echo '</table>'
</code></pre>
AAAND所有的表标签是由浏览器中呈现,而不是显示为明文... see for yourself(jsfiddle without highlight.js)
是不是我oris的代码标签有什么问题? 任何想法? 谢谢
答
您的标签:
<pre><code bla bla> must end </pre></code>
最终
<pre><code bla bla> must end </code></pre>
编辑: 答案的评论:
<pre>
<code class="hljs php">
<table>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
</tr>
</table>
</code>
</pre>
其nessecsary到HTML逃离“<'和'>'。 这可以通过this php Function
这里唯一错误的是你的[误解代码标记](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code)。 – Kaii 2014-09-19 19:38:04
所以它唯一的'风格'? – rudib 2014-09-19 20:14:31