[TxMt] Latex to CSS (pygments ?)

Alain Matthes alain.matthes at mac.com
Sun Feb 4 16:45:38 UTC 2007


Le 3 févr. 07 à 16:54, Charilaos Skiadas a écrit :

> It would perhaps be possible, the Python bundle wouldn't enter into  
> it at all. But looking at the links you posted, pygments doesn't  
> seem to support LaTeX as one of the languages for input. So we'll  
> need to know a bit more about what Kjell is doing, in order to be  
> able to help.
>

pygments can take a latex file

I 'm not an expert with python : it's my first code !

import codecs
from pygments import highlight
from pygments.lexers import TexLexer
from pygments.formatters import HtmlFormatter>>> from
pygments.formatters import HtmlFormatter
from pygments.lexers import TexLexer
from pygments.formatters import HtmlFormatter
fileObj = codecs.open("/Users/ego/Desktop/sign-diagram.tex", "r" ,
"utf8")
code = fileObj.read()
filecontent = highlight(u, TexLexer(), HtmlFormatter())
unicodefilecontent = unicode(filecontent)
out = file( "/Users/ego/Desktop/sign-diagram.html", "w")
out.write(unicodefilecontent)
out.close()

and with

print HtmlFormatter().get_style_defs('.highlight') i've the css


Alain

ps Kjell do'nt work with Textmate but Kjell use python and Django for  
his site !





More information about the textmate mailing list