syntax-highlightinggoogle-code-prettify

Google Code Prettify - stripes/piano keys without line numbers?


I'm using Prettify (from Google Code - https://code.google.com/p/google-code-prettify/). When one adds the linenums attribute then it renders the program using alternating background colors on each line (i.e., it uses "stripes" or "piano keys"). When one removes that attribute Prettify no longer stripes the lines.

Is it possible to get Prettify to stripe source code WITHOUT also adding line numbers?


Solution

  • If you look at the themes gallery you'll see that this is affected by the stylesheet, and that there are some with line numbers on every line.


    Something like

    <style>li.L4, li.L9 { list-style-type: none }</style>
    

    should do it.

    The operative part of the default stylesheet is

    li.L0,
    li.L1,
    li.L2,
    li.L3,
    li.L5,
    li.L6,
    li.L7,
    li.L8 { list-style-type: none }
    

    which turns off list bulleting for all items with index i where (i % 10) ∉ (4,9), hence the li.L4, li.L9 selector fills the gaps.