14

Is there a syntax-highlighting for LuaLaTeX on this site? I think it would be necessary to color the Lua commands in the LaTeX code, because Lua is a integral part of (Lua)LaTeX. I think it would improve the readability of code an maybe push the acceptance of Lua for use in LaTeX.

I have no idea about programming a syntax-highlighting, but the Lua code is always placed in \directlua{} or \begin{luacode} ... \end{luacode} (and some other environments). So I guess and hope it is not so difficult to create a highlighting. Additionally there could be a new button above the answer text field like the 'Code Sample' button, but for Lua commands (i.e. for placing just Lua code without LaTeX commands and Lua environments).

3
  • 1
    I'm not sure Lua code is 'an integral par of LuaLaTeX', at least for end users. Well packaged Lua code should be supplied by developers, who should then have the Lua code in a separate file from the TeX.
    – Joseph Wright Mod
    Commented Feb 12, 2012 at 15:16
  • 1
    @Joseph: Thanks for your response. But I don't agree with you completely. I think Lua is a very helpful tool for all users which are no TeX experts to create their own macros. Just some hours ago I posted an answer to a question (tex.stackexchange.com/a/44389/10570) which shows the difference between (cryptic) plain TeX and Lua. But I don't want to discuss about the relevance of Lua. The main goal of this question is the feature-request of syntax-highlighting the Lua code on this website. The given example also shows that it is hard to read the Lua code. Would be nice to improve that.
    – Holle
    Commented Feb 13, 2012 at 15:45
  • @JosephWright and Holle, syntax highlighting of pure lua only needs an SE person to activate it. Does anyone know what languages we have access to? We have the obvious, and also shell going by this answer (but I had to activate it manually), but definitely not lua. As list of languages that are available in theory is here.
    – qubyte
    Commented Feb 22, 2012 at 13:38

1 Answer 1

7

Syntax highlighting is provided, when available (not all sites are enabled), by google-code-prettify, and is thus limited to the languages handled by this highlighter. I bumped into the problem myself recently when writing up a Fortran 95 code question on another SE. If you add the necessary code to do this highlighting to prettify, then the chances are that it will eventually filter through to here.

However, I don't think that this is necessary, and mixing languages will probably be hard to implement. If you are happy to separate lua code and LaTeX, it is be possible to force the lua code to be properly highlighted using the line

<!-- language: lang-lua -->

above the code, unindented. As syntax highlighting is not available on this meta site, here is an example of it working:

enter image description here

5
  • It seems to work on Andrew Staceys answer here: tex.stackexchange.com/a/44748/9736 after doncherrys edit
    – Psirus
    Commented Feb 22, 2012 at 13:46
  • Huh. I wonder what's going on then...
    – qubyte
    Commented Feb 22, 2012 at 13:48
  • Currently there is no syntax highlighting on this meta site (but there is on the main site). See meta.tex.stackexchange.com/questions/873/… (and vote if you want it changed).
    – N.N.
    Commented Feb 22, 2012 at 13:58
  • @N.N. I really should have spotted the lack of highlighting. It makes sense in hindsight.
    – qubyte
    Commented Feb 22, 2012 at 14:18
  • Thank you! The code looks much better than before.
    – Holle
    Commented Feb 22, 2012 at 20:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .