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

旧时模样 提交于 2019-12-08 09:43:36

问题


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:


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}


来源:https://stackoverflow.com/questions/10420757/syntax-highlighting-javascript-in-lyx-insert-child-program-listing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!