Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support \fBIPR1234 and \c as constant escapes, \$[*1-9] as variable (macro arguments), .[ad]s and \*q/\*(Am/\*[name] #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions mandoc.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ scope: text.mandoc
# Since their usage is discouraged in mandoc documents, and this definition is
# already huge and painful, I did not add support for them, which will cause them
# to show up as "illegal".
# `\f` is supported, but marked as deprecated.
# Context-less `\f` is supported.
# roff character escapes marked as deprecated by roff(7) are not supported, and
# will show up as "illegal".

variables:
one_char_escape: "[~0|^&)%:e'`-]"
one_char_escape: "[~0|^&)%:e'`-c]"
two_char_escape: (?:\|=|~=|~~|=~|<=|=>|<<|>>|!=|==|<-|->|<>|-\+|\+-|\*\*|/_|12|14|34|18|38|58|78|3d|%0|-D|-h|\.[ij]|a[-".^abcdho~]|'[AEIOUYaeiouy]|`[AEIOUaeiou]|~[ANOano]|:[AEIOUaeiou]|\^[AEIOUaeiou]|,[Cc]|/[LOlo]|o[Aa]|\*[ABGDEZYHIKLMCOPRSTUFXQWabgdezyhiklmcoprstufxqw]|\+[hfpe]|ts|AE|ae|Ah|AN|an|ap|aq|at|ba|bb|Bq|bq|br|bu|bv|c\*|c\+|ca|ci|CL|co|cq|CR|Cs|ct|cu|dA|da|dd|de|dg|DI|di|Do|dq|em|en|eq|es|Eu|eu|f/|fa|Fc|fc|ff|Fi|fi|Fl|fl|fm|Fn|Fo|fo|ga|gr|hA|ha|HE|ho|hy|ib|if|IJ|ij|Im|ip|is|lA|la|lB|lb|lC|lc|lf|lh|lk|lq|lt|lz|mc|mi|mo|mu|nb|nc|nm|no|OE|oe|Of|OK|Om|oq|OR|or|pc|pd|pl|Po|pp|ps|pt|r!|r\?|rA|ra|rB|rb|rC|rc|Re|rf|rg|rh|rk|rn|rq|rs|rt|ru|S1|S2|S3|sb|sc|Sd|sd|sh|sl|SP|sp|sq|sr|ss|st|te|tf|ti|tm|TP|Tp|uA|ua|ul|vA|va|wp|Ye)
scaling_width: '[+-]?[0-9]*.[0-9]*[ciPpfvmnuM]'
# Zero-padded left to at least 4 digits, letters uppercase only
Expand Down Expand Up @@ -45,9 +45,19 @@ contexts:
scope: punctuation.delimiter.mandoc
# Font requests
- match: \\f[BIPR1-4]
scope: invalid.deprecated.mandoc
scope: constant.character.escape.mandoc
- match: \\f\((?:BI|C[BIRW])
scope: invalid.deprecated.mandoc
scope: constant.character.escape.mandoc
# Macro arguments
- match: \\\\\$[*1-9]+
scope: variable.language.mandoc
# Predefined strings
- match: \\\*(?:(?:\[([^]]+)\])|(?:\((..))|(.))
scope: constant.character.escape.mandoc
captures:
1: variable.language.mandoc
2: variable.language.mandoc
3: variable.language.mandoc
## Special characters
# Refer to the `SPECIAL CHARACTERS' section of roff(7)
- match: \\{{one_char_escape}}
Expand Down Expand Up @@ -434,6 +444,11 @@ contexts:
pop: true
- match: ^[.\']Ns(?=\s) # No effect when at line start, so probably wrong
scope: invalid.deprecated.mandoc
- match: ^([.\'][ad]s)\s([^\s]+)\s"?(.+)
captures:
1: keyword.mandoc
2: variable.language.mandoc
3: string.unquoted.mandoc

# TODO: handle argument formatting for those as well
callable_macro:
Expand Down