Syntax highlighting Javascript in LyX, insert chil

2019-06-12 17:02发布

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

1条回答
放荡不羁爱自由
2楼-- · 2019-06-12 17:34

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}
查看更多
登录 后发表回答