实际上并没有 JavaScript/语言文件,但您可以手动自定义。当您在 LyX 编辑器中右键单击代码块时,Parameters->Advanced 选项卡,您可以手动放置列表选项(注意:我的 LyX 是法语,因此点击路径可能会略有不同)。
关注http://lenaherrmann.net/2010/05/20/javascript-syntax-highlighting-in-the-latex-listings-package 我添加了:
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}