alecthomas / chroma

A general purpose syntax highlighter in pure Go
MIT License
4.24k stars 378 forks source link

Add support for Latex output #188

Open gsstark opened 5 years ago

gsstark commented 5 years ago

I use the "minted" package for Latex which uses Pygmants to format program listings. However it doesn't handle Yaml properly and it looks like this would be an alternative.

I'm not sure if this means adding a Latex formatter to chroma or adding support for chroma to the minted code. I'm actually suspecting it's the latter which if the API is similar might actually be very simple. I'll look into this further when I get a chance.

alecthomas commented 5 years ago

I'm not quite sure what you're asking for...are you asking for Chroma to be able to output Latex? If so that seems like a reasonable request, but I don't have the knowledge or inclination myself. I'd happily merge a PR though.

zemirco commented 3 years ago

Just came across this issue because I thought it would be really nice to have.

I know it's not easy to implement but I'll definitely watch this space. When I have some extra time I might start working on this. The advantage is obviously that we only need the single executable from chroma to highlight the source code.

tobb10001 commented 6 months ago

I came across this when writing my thesis and decided to help myself with my own little hack.

Since minted calls Pygments under the hood, I came up with a way to use Chroma through Pygments. It works by building a Python wrapper around Chroma, that allows Pygments to recognize and use Chroma parsers.

Otherwise I noticed, that the LaTeX generation happens in Pygments itself (source code here), not in minted. This could maybe be ported to Chroma as well.

However, even if Chroma implements this, minted would need to know that it needs to call Chroma, which would have to be done on the minted side of things. This might be done in future versions of minted, at least judging by this comment.