feat: group for control sequence to scope highlighting of types and module

This commit is contained in:
Éric BURGHARD 2022-06-26 21:40:56 +02:00
parent 61a490d658
commit 1c8bd551db

View File

@ -33,37 +33,44 @@ provide-module latex %~
add-highlighter shared/latex regions
add-highlighter shared/latex/content default-region group
# Region for control sequence (with latex2e arguments and options) starting with unescaped \
# and ending at eol or word boundaries not preceded nor followed by @ : \ { } [ ] *
add-highlighter shared/latex/cs region '(?<!\\)(?:\\\\)*\K\\[@\w]' '\n|(?<![@:\\{}\[\]*])(?![@:{}\[\]*])\b' group
add-highlighter shared/latex/comment region '(?<!\\)(?:\\\\)*\K%' '\n' fill comment
# latex2e private functions
add-highlighter shared/latex/content/ regex '\\[a-zA-Z@]+\b' 0:function
# Scopes, starting with a backslash
add-highlighter shared/latex/content/ regex '\\[a-zA-Z]+\b' 0:keyword
# latex3 functions (expl3 doc)
add-highlighter shared/latex/content/ regex '\\(?:__|@@_)?[a-zA-Z@]+_\w+(:[nNpTFDwcVvxefo]+)?\b' 0:function 1:+db@type
# latex3 variable (expl3 doc)
add-highlighter shared/latex/content/ regex '\\([lgc]_)[a-zA-Z]+_[a-zA-Z]+\b' 0:variable 1:+db
# latex3 type (expl3 doc)s
add-highlighter shared/latex/content/ regex '_(bool|box|cctab|clist|coffin|dim|fp|ior|iow|int|muskip|prop|seq|skip|str|tl)' 0:+db
# latex3 l3kernel modules (l3kernel/doc/l3prefixes.csv)
add-highlighter shared/latex/content/ regex '\\(alignment|alloc|ampersand|atsign|backslash|bitset|bool|box|catcode|cctab|char|chk|circumflex|clist|code|codedoc|coffin|colon|color|cs|debug|dim|document|dollar|driver|e|else|empty|etex|exp|expl|false|fi|file|flag|fp|group|hash|hbox|hcoffin|if|inf|initex|insert|int|intarray|ior|iow|job|kernel|keys|keyval|left|log|lua|luatex|mark|marks|math|max|minus|mode|msg|muskip|nan|nil|no|novalue|one|or|other|parameter|pdf|pdftex|peek|percent|pi|prg|prop|ptex|quark|recursion|ref|regex|reverse|right|scan|seq|skip|sort|space|stop|str|sys|tag|term|tex|text|tilde|tl|tmpa|tmpb|token|true|underscore|uptex|use|utex|vbox|vcoffin|xetex|zero)_' 0:+db
# macros arguments
add-highlighter shared/latex/content/ regex '(?<!\\)(?:\\\\)*\K#+[1-9]\b' 0:string
# grouped lists
add-highlighter shared/latex/content/ regex '(?<!\\)(?:\\\\)*\K\{([\s/;,\w]+)\}' 1:string
# Document and latex2e control sequence
add-highlighter shared/latex/cs/ regex '(?:\\[a-zA-Z@]+)' 0:keyword
## Options passed to latex2e control sequences, between brackets
add-highlighter shared/latex/cs/ regex '\\[a-zA-Z@]+\b\[([^\]]+)\]' 1:value
## Emphasized text
add-highlighter shared/latex/cs/ regex '\\(?:emph|textit|textsl)\{([^}]+)\}' 1:default+i
## Underlined text
add-highlighter shared/latex/cs/ regex '\\underline\{([^}]+)\}' 1:default+u
## Bold text
add-highlighter shared/latex/cs/ regex '\\textbf\{([^}]+)\}' 1:default+b
## Section headings
add-highlighter shared/latex/cs/ regex '\\(part|section)\*?\{([^}]+)\}' 2:title
add-highlighter shared/latex/cs/ regex '\\(chapter|(sub)+section|(sub)*paragraph)\*?\{([^}]+)\}' 4:header
# Options passed to scopes, between brackets
add-highlighter shared/latex/content/ regex '\\(?!_)\w+\b\[([^\]]+)\]' 1:value
# Content between dollar signs/pairs
# LaTeX3 control sequence
## Functions (expl3 doc) module_name:arguments_types.
add-highlighter shared/latex/cs/ regex '\\(?:__|@@_)?[a-zA-Z@]+_\w+(:[nNpTFDwcVvxefo]+)?' 0:function 1:+db@type
## Variables (expl3 doc): scope_name_type
add-highlighter shared/latex/cs/ regex '\\([lgc]_)[a-zA-Z@]+_[a-zA-Z]+' 0:variable 1:+db
## l3kernel modules (l3kernel/doc/l3prefixes.csv)
add-highlighter shared/latex/cs/ regex '\\(alignment|alloc|ampersand|atsign|backslash|bitset|bool|box|catcode|cctab|char|chk|circumflex|clist|code|codedoc|coffin|colon|color|cs|debug|dim|document|dollar|driver|e|else|empty|etex|exp|expl|false|fi|file|flag|fp|group|hash|hbox|hcoffin|if|inf|initex|insert|int|intarray|ior|iow|job|kernel|keys|keyval|left|log|lua|luatex|mark|marks|math|max|minus|mode|msg|muskip|nan|nil|no|novalue|one|or|other|parameter|pdf|pdftex|peek|percent|pi|prg|prop|ptex|quark|recursion|ref|regex|reverse|right|scan|seq|skip|sort|space|stop|str|sys|tag|term|tex|text|tilde|tl|tmpa|tmpb|token|true|underscore|uptex|use|utex|vbox|vcoffin|xetex|zero)_' 0:+db
# LaTeX3 types (expl3 doc)
add-highlighter shared/latex/cs/ regex '_(bool|box|cctab|clist|coffin|dim|fp|ior|iow|int|muskip|prop|seq|skip|str|tl)\b' 0:+db
# This belongs to content group as the LaTeX3 convention is separating macros names, args and options
# with spaces and thus should not be catched by the cs region
## macros arguments
add-highlighter shared/latex/content/ regex '(?<!\\)(?:\\\\)*\K#+[1-9]' 0:string
## group containing words lists (separated by ; , / or spaces)
add-highlighter shared/latex/content/ regex '(?<!\\)(?:\\\\)*\K\{([\s/;,\w\d]+)\}' 1:string
# Math mode between dollar signs/pairs
add-highlighter shared/latex/content/ regex '((?<!\\)\$(\\\$|[^$])+\$)|((?<!\\)\$\$(\\\$|[^$])+\$\$)|((?<!\\)\\\[.*?\\\])|(\\\(.*?\\\))' 0:meta
# Emphasized text
add-highlighter shared/latex/content/ regex '\\(emph|textit)\{([^}]+)\}' 2:default+i
# Bold text
add-highlighter shared/latex/content/ regex '\\textbf\{([^}]+)\}' 1:default+b
# Section headings
add-highlighter shared/latex/content/ regex '\\(part|section)\*?\{([^}]+)\}' 2:title
add-highlighter shared/latex/content/ regex '\\(chapter|(sub)+section|(sub)*paragraph)\*?\{([^}]+)\}' 4:header
# Indent
# ------