Skip to content

Line numbers for rtf output #1217

@Anteru

Description

@Anteru

(Original issue 1513 created by jonascj on 2019-05-06T12:56:56.977289+00:00)

I suggest to add a crude line numbering option to the RTF formatter available in pygments/pygmentize

Basically, after the rtf output is generated numbers padded with spaces could be added to the rtf document, in front of every line of highlighted code.

{ 2 } and {10 } serves very well as line numbers if put in front of every line of highlighted code (with a monospaced font of course). A script to do this is easily crafted, but it would be nice to add it to the RTF formatter. See the attached RTF-document as an example of my suggestion.

The only downside is that the code is not copy friendly in the final document (i.e. you will copy the line numbers as well), but who copies code from RTF/Word/LibreOffice documents anyway? My use case is students who do not write reports using LaTeX. This formatting option would make it easy to generate nice looking code snippets to paste into their reports (without resorting to taking screenshots).

I might get round to looking at submitting a patch during the summer, but maybe someone else will be hooked by this. In any case, now it is here for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-formattingarea: changes to formattershelp wantedCommunity help appreciated!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions