Question

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

Was it helpful?

Solution

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}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top