这里有一件事。我在我的网站上使用“Highlight.js”(一个基于JavaScript的自动语法高亮器)来对代码进行语法高亮。但它不支持行号或斑马线条纹(用于交替显示代码行)。
我的代码块被包含在像这样的
谢谢。
PS:我不懂JavaScript,请尽可能清晰明了地解释。我会尽力理解。谢谢。
我的代码块被包含在像这样的
<pre><code>
块中:<pre><code>
<script type="text/javascript">
// Say hello world until the user starts questioning
// the meaningfulness of their existence.
function helloWorld(world) {
for (var i = 42; --i >= 0;) {
alert('Hello ' + String(world));
}
}
</script>
<style>
p { color: pink }
b { color: blue }
u { color: "umber" }
</style>
</code></pre>
输出结果如下:
现在我想要使用JavaScript动态地为代码块显示行号。我该如何做?(如果可能的话,如何显示斑马线条纹?)谢谢。
PS:我不懂JavaScript,请尽可能清晰明了地解释。我会尽力理解。谢谢。