Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#32 linenos='table' style code highlighting

open
nobody
None
5
2012-11-11
2012-11-11
Markarian421
No

Highlighting code with :number-lines: turned on renders the line numbers "inline" with the code lines in HTML. This makes it impractical to cut & paste code snippets into an editor or the shell. Pygments has an option linenos that puts line numbers in a separate table column which makes cutting work.

However, from scanning the code it seems docutils' use of pygments is more low-level (e.g. not really using the formatters, just the lexers/tokenizers). An option to format lines with tables is hence not so straight-forward. Maybe I submit a patch myself later on...

Discussion

  • Markarian421
    Markarian421
    2012-11-11

    Seems code-block in Sphinx does the right thing with line numbering. Kind of unfortunate that there are different directives in Sphinx doing more or less the same thing...