45 lines
1.6 KiB
TeX
45 lines
1.6 KiB
TeX
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||
|
%%%%%%%%%%% YAML syntax highlighting %%%%%%%%%%%%%%%%%
|
||
|
|
||
|
% http://tex.stackexchange.com/questions/152829/how-can-i-highlight-yaml-code-in-a-pretty-way-with-listings
|
||
|
|
||
|
% here is a macro expanding to the name of the language
|
||
|
% (handy if you decide to change it further down the road)
|
||
|
\newcommand\YAMLcolonstyle{\color{red}\mdseries}
|
||
|
\newcommand\YAMLkeystyle{\color{black}\bfseries}
|
||
|
\newcommand\YAMLvaluestyle{\color{blue}\mdseries}
|
||
|
|
||
|
\makeatletter
|
||
|
|
||
|
\newcommand\language@yaml{yaml}
|
||
|
|
||
|
\expandafter\expandafter\expandafter\lstdefinelanguage
|
||
|
\expandafter{\language@yaml}
|
||
|
{
|
||
|
keywords={true,false,null,y,n},
|
||
|
keywordstyle=\color{darkgray}\bfseries,
|
||
|
basicstyle=\YAMLkeystyle, % assuming a key comes first
|
||
|
sensitive=false,
|
||
|
comment=[l]{\#},
|
||
|
morecomment=[s]{/*}{*/},
|
||
|
commentstyle=\color{purple}\ttfamily,
|
||
|
stringstyle=\YAMLvaluestyle\ttfamily,
|
||
|
moredelim=[l][\color{orange}]{\&},
|
||
|
moredelim=[l][\color{magenta}]{*},
|
||
|
moredelim=**[il][\YAMLcolonstyle{:}\YAMLvaluestyle]{:}, % switch to value style at :
|
||
|
morestring=[b]',
|
||
|
morestring=[b]",
|
||
|
literate = {---}{{\ProcessThreeDashes}}3
|
||
|
{>}{{\textcolor{red}\textgreater}}1
|
||
|
{|}{{\textcolor{red}\textbar}}1
|
||
|
{\ -\ }{{\mdseries\ -\ }}3,
|
||
|
}
|
||
|
|
||
|
% switch to key style at EOL
|
||
|
\lst@AddToHook{EveryLine}{\ifx\lst@language\language@yaml\YAMLkeystyle\fi}
|
||
|
\makeatother
|
||
|
|
||
|
\newcommand\ProcessThreeDashes{\llap{\color{cyan}\mdseries-{-}-}}
|
||
|
|
||
|
%%%%%%%%%%% YAML syntax highlighting %%%%%%%%%%%%%%%%%
|
||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|