如何向Google Prettify中的所有行添加行号? [英] How to add line numbers to all lines in Google Prettify?

查看:1361
本文介绍了如何向Google Prettify中的所有行添加行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用prettify:

I am using prettify:

<pre class="prettyprint linenums">
  some code
</pre>

它工作,但行号显示每5行,而不是每行。我使用这些文件

It works but the line number show every 5 lines and not for every line. I am using these files

<link href="../src/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../src/prettify.js"></script>

基本在此页结尾 http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html 您可以看到我想要的,但我看着那个代码,我不能弄清楚。

Basically at the end of this page http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html you can see that I want, but I looked at that code and I can't figure it out.

推荐答案

根本原因是 list-style-type:none prettify.css:

The root cause is list-style-type: none in prettify.css:

/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L5,
li.L6,
li.L7,
li.L8 { list-style-type: none /* <<< THIS is the cause! */ }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 { background: #eee }

您可以删除该规则或替换为:

You can either remove that rule or override it with:

.linenums li {
    list-style-type: decimal;
}

这篇关于如何向Google Prettify中的所有行添加行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆