Skip to content

Commit

Permalink
Improve handling of requests without whitespace
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alhadis committed Aug 1, 2016
1 parent 6abe836 commit 7016d79
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions grammars/roff.cson
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ repository:
|gcolor|hcode|hla|hlm|hpfa|hpfcode|hpf|hym|hys|itc|kern|length|linetabs|lsm
|mso|nop|nroff|opena|open|output|pev|pnr|psbb|pso|ptr|pvs|rchar|rfschar|rj
|rnn|schar|shc|shift|sizes|special|spreadwarn|sty|substring|tkf|tm1|tmc|trf
|trin|trnt|troff|unformat|vpt|warnscale|warn|writec|writem|write)"
|trin|trnt|troff|unformat|vpt|warnscale|warn|writec|writem|write)
(?=\\s|\\\\[\"#])"
end: "(?<!\\\\)(?=\n)|(?=\\\\\")"
beginCaptures:
1: {name: "punctuation.definition.request.roff"}
Expand Down Expand Up @@ -229,7 +230,8 @@ repository:
(ab|ad|af|bd|bp|br|c2|cc|ce|cf|ch|cs|cu|da|di|dt|ec|em|eo
|ev|ex|fc|fi|fl|fp|ft|hc|hw|hy|in|it|lc|lg|lf|ll|ls|lt|mc
|mk|na|ne|nf|nh|nm|nn|ns|nx|os|pc|pi|pl|pm|pn|po|ps|rd|rm
|rn|rr|rs|rt|so|sp|ss|sv|sy|ta|tc|ti|tm|tr|uf|vs|wh)"
|rn|rr|rs|rt|so|sp|ss|sv|sy|ta|tc|ti|tm|tr|uf|vs|wh)
(?=\\s|\\d+\\s*$|\\\\[\"#])"
end: "(?<!\\\\)(?=\n)|(?=\\\\\")"
beginCaptures:
1: {name: "punctuation.definition.request.roff"}
Expand Down Expand Up @@ -259,7 +261,7 @@ repository:

# String definition
name: "meta.function.request.$2.roff"
begin: "^([.'])[ \t]*([ad]s1?)[ \t]*(((?:[^\\s\\\\]|\\\\(?!\").)+))?"
begin: "^([.'])[ \t]*([ad]s1?)[ \t]+(((?:[^\\s\\\\]|\\\\(?!\").)+))?"
end: "(?<!\\\\)$"
beginCaptures:
1: name: "punctuation.definition.request.roff"
Expand Down Expand Up @@ -469,7 +471,7 @@ repository:

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

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

0 comments on commit 7016d79

Please sign in to comment.