3 ms·
$ mkdir rtfs $ for F in src/**.rs; do > pygmentize -o rtfs/$(basename $F .rs).rtf -O linenos=1 $F > done Now open the .rtf
by smlckz 6y ago
$ mkdir rtfs
$ for F in src/**.rs; do
> pygmentize -o rtfs/$(basename $F .rs).rtf -O linenos=1 $F
> done
Now open the .rtf files with a word processor and print them.
To change the highlighting theme, e.g. to "pastie":
$ pygmentize -O style=pastie,linenos=1 ....
- vlmutolo 6y agoThis… might actually work. Thanks!
- smlckz 6y agoWe had a project work to submit C programs. Originally, the teacher told us to write the programs by hand. I had written ~20 C programs in my computer and was feeling lazy to write out all of them by hand onto paper. I then asked the teacher if I could submit the programs printed on paper and she said yes. I was already using Pygments to highlight my source code and was thinking if I could print them highlighted with it. Pygments has many formatters to format output. I used .rtf but you can also output images as well.
- smlckz 6y agoNo, now looked at the docs and saw that linenos does not work with rtf formatter. Sorry :( (I didn't have to print line numbers back then) You can generate LaTeX documents, images etc. with line numbers. And then print them. hmm. https://pygments.org/docs/formatters/ https://pygments.org/docs/formatters/ https://pygments.org/docs/cmdline/ https://pygments.org/docs/cmdline/