newmember123 / google-code-prettify

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

Feature Request: Highlight modified lines (have patch) #327

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I thought I'd run this idea by you

I have many code samples on a blog and I progressively add things to them down 
an article while explaining why I'm making the changes. I use 
google-code-prettify to colorize them but I'd also like to be able to highlight 
which lines changes.

I have a patch that adds CSS to do this.  Basically you pick a prefix, I picked 
'*' then you put that prefix in front of any line you want called out.  Example

    <pre "prettyprint">
    def foobar:
       print "this is an existing line"
       print "this is line was modified"
       print "this is an existing line"
    </pre>

To mark that 3rd line as modified you change it to this

    <pre "prettyprint showlinemods">
    def foobar:
       print "this is an existing line"
    *   print "this is line was modified"
       print "this is an existing line"
    </pre>

The patch changes the numberLines function so that it can optionally use a UL 
instead of an OL. Then, for each LI, if the content starts with the prefix it 
removes the prefix and adds the class "linemodified" to that LI. since 
numberLines is called before all the parsing happens this means the prefixes 
will have been removed before the code is prettified

At that point using CSS you all kinds of stuff from making modified lines 
appear in a different color to having modified lines use a different bullet 
like for example have non-modified lines have no bullet and have modified lines 
start with ">"

Here's a sample showing CSS used to call out specific list items in an 
unordered list.

http://jsfiddle.net/greggman/h5Pxh/

Anyway, I attached a preliminary patch. If yea, great. If no interest that's 
fine. If you want something changed please suggest it.

Original issue reported on code.google.com by g...@chromium.org on 22 Jan 2014 at 3:17

Attachments: