Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export to pdf/image with Syntax highlightning - emacs

I have a file open in Emacs which highlights the syntax and I want to share the file (with syntax highlighting) with another person who does not use Emacs.

Is it possible to export the file open in Emacs with syntax highlightning?

Any target format is ok: e.g. HTML, PDF, Image

like image 217
18bytes Avatar asked Nov 29 '11 08:11

18bytes


2 Answers

You can use the command M-x htmlfontify-buffer to create an html file with syntax highlighting from any buffer.

It's included in standard Emacs, definitely in version 24, I'm not sure about 23.

like image 121
Christian Berg Avatar answered Nov 13 '22 21:11

Christian Berg


You can use htmlize-buffer that comes with 'htmlize.el' (find it at http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el.cgi (dead link?) or install from MELPA or download from the htmlize Github project. This will create a HTML file with all the syntax highlighting of your current buffer.

like image 2
u-punkt Avatar answered Nov 13 '22 21:11

u-punkt