Printing code with syntax highlighting?

后端 未结 13 2181
轻奢々
轻奢々 2021-02-01 16:00

I have occasion to need to print code (Horrors!!! ;) ), and i was wondering what editor or tool would i use to print that code out with proper formatting and syntax highlighting

相关标签:
13条回答
  • 2021-02-01 16:18

    Visual Studio will, and allows you have a completely separate configuration for printing.

    0 讨论(0)
  • 2021-02-01 16:26

    I while ago I created a household python script that wraps pygments into a small console utility. It works with any language supported by pygments.

    Also if you happen to use eclipse, you could simply copy the selected text in the editor and then paste it in a RTF-aware editor like MS Word - it will preserve all the colors, fonts and formatting.

    0 讨论(0)
  • 2021-02-01 16:28

    The tool called enscript is very much the tool for doing this. It is very powerful, is not tied to an editor nor a language and you can create PDF's with syntax highlighting.

    The documentation pretty much says it all.

    enscript man page

    0 讨论(0)
  • 2021-02-01 16:29

    If you have problems with Visual Studio 2012 concerning the highlighted printing an handeling the described problem:

    • Download and install this Power Tool which implements the color printing, besides some other features and bug fixes. Works for me!
    0 讨论(0)
  • 2021-02-01 16:29

    Solution For Bash Shell

    1. Add this line to ~/.bashrc if you are using UBUNTU
      or, to ~/.bash_profile if you are using MAC
      If that file does not exists, create it.

      alias lprc='vim -me -c ":syntax on" -c ":hardcopy" -c ":q"'

    2. source ~/.bashrc or source ~/.bash_profile

    3. To print colored hello.py just do this:
      lprc hello.py instead of lpr hello.py

    0 讨论(0)
  • 2021-02-01 16:32

    http://pygments.org/ is one option. It supports a ton of languages, and since it's written as a python library, you can script the conversion process however you want.

    0 讨论(0)
提交回复
热议问题