dosper7 / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

Add ability to highlight specific lines #136

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be nice to have ability to highlight specific lines of code to catch 
viewer's attention (by changing background color for example).

Syntax could be <pre class="prettyprint highlight:10,20,30,40"></pre>

Original issue reported on code.google.com by serg472@gmail.com on 23 Dec 2010 at 10:41

GoogleCodeExporter commented 8 years ago
Does http://google-code-prettify.googlecode.com/svn/trunk/README.html#linenums 
not work for you?

If you do use line numbering, you can always style a particular line by doing 
something like

    #my-code-block li:nth-child(50) { background: yellow }

in modern browsers.

Original comment by mikesamuel@gmail.com on 7 Jan 2011 at 9:19

GoogleCodeExporter commented 8 years ago
Closing for lack of response.

Original comment by mikesamuel@gmail.com on 4 Mar 2011 at 8:26

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This issue has not been fixed. I would also like this feature being implemented 
in google-code-prettify instead of needing to have another css code.

Original comment by c.w.t...@gmail.com on 22 May 2014 at 9:27

GoogleCodeExporter commented 8 years ago
I would also like this feature.
@mikesamuel, using nth-child(50) like your example will highlight the 50th 
line. But if we use "linenums:17" to highlight the 50th line on the code we 
need to use nth-child(33) because of the offset and I need a calculator to make 
50-17=33 :-)

Original comment by claudio....@gmail.com on 30 Jan 2015 at 4:03

GoogleCodeExporter commented 8 years ago
You don't need CSS at all to do this.

<pre clas="prettyprint">Line 1
<span class="highlighted">Line 2</span>
Line 3</pre>

should work just fine since prettify preserves tags in the input.

Original comment by mikesamuel@gmail.com on 31 Jan 2015 at 10:01