Syntax highlighting Javascript in LyX, insert child -> program listing
Asked Answered
C

1

0

Im writing my masters thesis, which includes alotta javascript. Im including it as a child file, as a program listing with the following options:

breaklines=true
captionpos=b
frame=tb
language=Python

There is no javascript language/listing file, which is why Im trying python. Also tried Java, but neither did much good.

Is there any way to get some js syntax highlighting here? It really is alot of code, so its not very easy to read when its all black.

Thanks

Contemn answered 2/5, 2012 at 19:58 Comment(0)
P
4

There is no JavaScript/language file in fact, but you can customize by hand. When you right-click to the code block in your LyX editor, Parameters->Advanced tab, you can put your listing options manually (NB : my LyX is in French so the path to click could be slightly different).

Following http://lenaherrmann.net/2010/05/20/javascript-syntax-highlighting-in-the-latex-listings-package i added :

comment={[l]{//}}
commentstyle={\color{purple}\ttfamily}
identifierstyle={\color{black}}
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break}
keywordstyle={\color{blue}\bfseries}
morecomment={[s]{/*}{*/}}
ndkeywords={class, export, boolean, throw, implements, import, this}
ndkeywordstyle={\color{darkgray}\bfseries}
sensitive=false
stringstyle={\color{red}\ttfamily}
Papillon answered 5/3, 2013 at 13:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.