TeX - LaTeX Asked on January 6, 2021
I have a language grammar in textmate grammar specification, for example like the one below from the texmate site:
{ scopeName = 'source.untitled';
fileTypes = ( );
foldingStartMarker = '{s*$';
foldingStopMarker = '^s*}';
patterns = (
{ name = 'keyword.control.untitled';
match = 'b(if|while|for|return)b';
},
{ name = 'string.quoted.double.untitled';
begin = '"';
end = '"';
patterns = (
{ name = 'constant.character.escape.untitled';
match = '\.';
}
);
},
);
}
In visual studio code e.g. this can define the syntax highlighting for the code in the editor.
In latex I can define new languages with styles for listings via the lang.sty
and style.sty
format, e.g. like so (excerpts):
usepackage{xcolor}
usepackage{textcomp}
% TODO: Add support for digits.
%definecolor{digits}{RGB}{0,0,128} % dark blue
definecolor{comment}{RGB}{0,128,0} % dark green
definecolor{string}{RGB}{255,0,0} % red
definecolor{keyword}{RGB}{0,0,255} % blue
lstdefinestyle{rules}{
commentstyle=color{comment},
stringstyle=color{string},
keywordstyle=[1]color{keyword},
...
style.sty
lstdefinelanguage{rules}{
sensitive=true,
alsoletter={%-><=},
% comments.
% // line comment
% /* general comment */
comment=[l]{#},
morecomment=[s]{/*}{*/},
% strings.
% "foo"
% `bar`
% 'x'
string=[b]{"},
...
lang.sty
Is it possible to transfer a textmate grammar to the latex listing style format without much work? Or is there even any known way of automatically including it?
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP