rubychan / coderay

Fast and easy syntax highlighting for selected languages, written in Ruby.
http://coderay.rubychan.de/
Other
846 stars 115 forks source link

LaTeX encoder #183

Open Quintus opened 9 years ago

Quintus commented 9 years ago

Hi,

I was wondering why CodeRay has no LaTeX encoder, so I made one :-). I did a few tests with it, and it seemed ok, but I’ve not yet thrown really obfuscated code on it.

The large string in the file is a LaTeX preamble snippet that needs to be included (e.g. by \include). This preamble snippet allows you to customize the coloring of the result code. Currently, it uses mostly plain black (thus the highlighting isn’t that detailed), but it allows for nearly the same amount of customisation as CodeRay’s CSS classes for the HTML highlighter do.

The highlighter supports line numbers and whitespace visualisation.

I recommend to use this with LuaLaTeX. I’ve tested it with PDFLaTeX though, and as long as you have plain old ASCII sourcecode files (including comments!), it works with it. The show_whitespace option definitely requires a Unicode-aware TeX engine such as Luatex as it uses Unicode characters for replacement.

This probably implements #50. I’ve written this completely from scratch, though.

Vale, Quintus

Quintus commented 9 years ago

Yay, this breaks GitHub’s highlighter completely. A shame they aren’t using CodeRay! :frog:

Vale, Quintus

korny commented 9 years ago

Wow, this is awesome! I'm not using LaTeX anymore, so I would need a bit of time to test it. Can we add some tests? Preferrably even one that actually runs the output through tex…

Quintus commented 9 years ago

I think I should be able to add some tests, yes. It will take me some time, though, because I’m busy with different things right now.

Vale, Quintus

Quintus commented 9 years ago

@korny is that correct that you invited me to @Rubychan? I’m just doing PRs on CodeRay occasionally, but I can’t maintain it as such. https://github.com/Secretchronicles/TSC eats up most of my free time.

Vale, Quintus

korny commented 9 years ago

Yes I did :-) You earned it. You don't have to use it, but it feels right to me that you have a commit bit, too.

On 22.04.2015, at 09:30, Marvin Gülker notifications@github.com wrote:

@korny is that correct that you invited me to @Rubychan?

Quintus commented 9 years ago

Ok thank you! I feel honoured.

Vale, Quintus

sieversMartin commented 6 years ago

Why hasn't this been merged? Are there other ways to display LaTeX code within Coderay?

Quintus commented 6 years ago

I suppose it hasn't been merged because neither me nor korny are actively working on CodeRay...