Skip to content

Commit 7016d79

Browse files
committed
Improve handling of requests without whitespace
Initially, whitespace was left optional between a request's name and its arguments to stay compatible with classical Troff. This ended up causing more problems than it solved, as long macro names became mishighlighted: .space -> .sp ace .init -> .in it .check -> .ch eck This has been fixed, as most files in the wild would've been written for a modern implementation (GNU/Heirloom). The original issue isn't ignored though; requests with numbers attached are matched so lines like ".ps15" are highlighted correctly in older files.
1 parent 6abe836 commit 7016d79

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

grammars/roff.cson

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ repository:
158158
|gcolor|hcode|hla|hlm|hpfa|hpfcode|hpf|hym|hys|itc|kern|length|linetabs|lsm
159159
|mso|nop|nroff|opena|open|output|pev|pnr|psbb|pso|ptr|pvs|rchar|rfschar|rj
160160
|rnn|schar|shc|shift|sizes|special|spreadwarn|sty|substring|tkf|tm1|tmc|trf
161-
|trin|trnt|troff|unformat|vpt|warnscale|warn|writec|writem|write)"
161+
|trin|trnt|troff|unformat|vpt|warnscale|warn|writec|writem|write)
162+
(?=\\s|\\\\[\"#])"
162163
end: "(?<!\\\\)(?=\n)|(?=\\\\\")"
163164
beginCaptures:
164165
1: {name: "punctuation.definition.request.roff"}
@@ -229,7 +230,8 @@ repository:
229230
(ab|ad|af|bd|bp|br|c2|cc|ce|cf|ch|cs|cu|da|di|dt|ec|em|eo
230231
|ev|ex|fc|fi|fl|fp|ft|hc|hw|hy|in|it|lc|lg|lf|ll|ls|lt|mc
231232
|mk|na|ne|nf|nh|nm|nn|ns|nx|os|pc|pi|pl|pm|pn|po|ps|rd|rm
232-
|rn|rr|rs|rt|so|sp|ss|sv|sy|ta|tc|ti|tm|tr|uf|vs|wh)"
233+
|rn|rr|rs|rt|so|sp|ss|sv|sy|ta|tc|ti|tm|tr|uf|vs|wh)
234+
(?=\\s|\\d+\\s*$|\\\\[\"#])"
233235
end: "(?<!\\\\)(?=\n)|(?=\\\\\")"
234236
beginCaptures:
235237
1: {name: "punctuation.definition.request.roff"}
@@ -259,7 +261,7 @@ repository:
259261

260262
# String definition
261263
name: "meta.function.request.$2.roff"
262-
begin: "^([.'])[ \t]*([ad]s1?)[ \t]*(((?:[^\\s\\\\]|\\\\(?!\").)+))?"
264+
begin: "^([.'])[ \t]*([ad]s1?)[ \t]+(((?:[^\\s\\\\]|\\\\(?!\").)+))?"
263265
end: "(?<!\\\\)$"
264266
beginCaptures:
265267
1: name: "punctuation.definition.request.roff"
@@ -469,7 +471,7 @@ repository:
469471

470472
# No terminator specified
471473
name: "meta.function.definition.request.$2.roff"
472-
begin: "^([.'])[ \t]*((dei?1?)|(ami?1?))\\s*(\\S+?)?\\s*(\\\\[\"#].*)?$"
474+
begin: "^([.'])[ \t]*((dei?1?)|(ami?1?))\\s+(\\S+?)?\\s*(\\\\[\"#].*)?$"
473475
end: "^(?:[ \t]*\\x5C{2})?\\.[ \t]*\\."
474476
beginCaptures:
475477
1: {name: "punctuation.definition.request.roff"}
@@ -485,7 +487,7 @@ repository:
485487

486488
# Terminator included
487489
name: "meta.function.definition.request.with-terminator.$2.roff"
488-
begin: "^([.'])[ \t]*((dei?1?)|(ami?1?))\\s*(\\S+)\\s*(\"[^\"]+\"?|\\S+?(?=\\s|\\\\[\"#]))?(.*)$"
490+
begin: "^([.'])[ \t]*((dei?1?)|(ami?1?))\\s+(\\S+)\\s*(\"[^\"]+\"?|\\S+?(?=\\s|\\\\[\"#]))?(.*)$"
489491
end: "^(\\.)[ \t]*((\\6)(?=$|\\s|\\\\(?:$|\")))"
490492
beginCaptures:
491493
1: {name: "punctuation.definition.request.roff"}

0 commit comments

Comments
 (0)