diff --git a/CHANGELOG.md b/CHANGELOG.md index 79fe13c..c876131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,9 +18,11 @@ This project adheres to [Semantic Versioning](http://semver.org). * Fixed highlighting of SFD `GaspTable` fields without colons * Fixed missing highlighting of BDF comments which precede `STARTFONT` * Fixed missing highlighting of FontForge's Unicode codepoint literals +* Fixed [various inaccuracies][1] related to modeline matching [bez]: https://github.com/adobe-type-tools/psautohint/blob/99e1cb862/doc/bezformat.md [fd]: https://github.com/adobe-type-tools/psautohint/blob/12bffdd/python/psautohint/fdTools.py +[1]: https://github.com/github/linguist/pull/5271 [v1.3.0] diff --git a/grammars/afm.cson b/grammars/afm.cson index fa1f6c2..f574054 100644 --- a/grammars/afm.cson +++ b/grammars/afm.cson @@ -6,20 +6,20 @@ firstLineMatch: """(?x) ^Start(?:Comp|Master)?FontMetrics\\s+(?:\\d+(?:\\.\\d+)?)\\s*$ | # Modeline - (?i: + (?: # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:afm|adobe[-_]?font[-_]?metrics) - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - (?:afm|adobe[-_]?font[-_]?metrics) - (?=\\s|:|$) + (?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:afm|adobe[-_]?font[-_]?metrics) + (?=$|\\s|:) ) """ foldStartPattern: "^Start([A-Z]\\w+)(?=\\s|$)" diff --git a/grammars/bdf.cson b/grammars/bdf.cson index 5a57ccd..db6289d 100644 --- a/grammars/bdf.cson +++ b/grammars/bdf.cson @@ -6,20 +6,20 @@ firstLineMatch: """(?x) ^STARTFONT\\s+[0-9]+\\.[0-9]+\\s*$ | # Modeline - (?i: + (?: # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - bdf - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - bdf - (?=\\s|:|$) + (?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:bdf) + (?=$|\\s|:) ) """ patterns: [include: "#main"] diff --git a/grammars/bez.cson b/grammars/bez.cson index 879513a..e4d5214 100644 --- a/grammars/bez.cson +++ b/grammars/bez.cson @@ -3,22 +3,20 @@ name: "Standard Bézier" scopeName: "source.stdbez" fileTypes: ["bez"] firstLineMatch: """(?x) - # Modeline - (?i: - # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:std|standard)[-_]?bez(?:ier)? - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - (?:std|standard)[-_]?bez(?:ier)? - (?=\\s|:|$) - ) + + # Emacs modeline + -\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*) + (?i:(?:std|standard)[-_]?bez(?:ier)?) + (?=[ \\t;]|(?]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:(?:std|standard)[-_]?bez(?:ier)?) + (?=$|\\s|:) """ patterns: [include: "#main"] diff --git a/grammars/ff-script.cson b/grammars/ff-script.cson index 89cedbf..9a8a21e 100644 --- a/grammars/ff-script.cson +++ b/grammars/ff-script.cson @@ -7,20 +7,20 @@ firstLineMatch: """(?x) (?!.*?[ \\t]-lang(?:=|\\s+)py) | # Modeline - (?i: + (?: # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:fontforge|pfaedit) - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - (?:fontforge|pfaedit) - (?=\\s|:|$) + (?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:fontforge|pfaedit) + (?=$|\\s|:) ) """ patterns: [include: "#main"] diff --git a/grammars/ff-sfd.cson b/grammars/ff-sfd.cson index bd0cec6..9353535 100644 --- a/grammars/ff-sfd.cson +++ b/grammars/ff-sfd.cson @@ -7,20 +7,20 @@ firstLineMatch: """(?x) ^SplineFontDB:\\ [\\d.]+ | # Modeline - (?i: + (?: # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:sfd|spline[-_]?font[-_]?(?:database|db)) - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - (?:sfd|spline[-_]?font[-_]?(?:database|db)) - (?=\\s|:|$) + (?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:sfd|spline[-_]?font[-_]?(?:database|db)) + (?=$|\\s|:) ) """ patterns: [include: "#main"] diff --git a/grammars/figlet-control.cson b/grammars/figlet-control.cson index 06c9c98..8993b32 100644 --- a/grammars/figlet-control.cson +++ b/grammars/figlet-control.cson @@ -6,20 +6,20 @@ firstLineMatch: """(?x) \\Aflc2a | # Modeline - (?i: + (?: # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:fig(?:let)?+[-_]?(?:cfg|config|conf|control|ctrl)) - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - (?:fig(?:let)?+[-_]?(?:cfg|config|conf|control|ctrl)) - (?=\\s|:|$) + (?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:fig(?:let)?+[-_]?(?:cfg|config|conf|control|ctrl)) + (?=$|\\s|:) ) """ patterns: [{ diff --git a/grammars/figlet-font.cson b/grammars/figlet-font.cson index e7ee573..539afe2 100644 --- a/grammars/figlet-font.cson +++ b/grammars/figlet-font.cson @@ -6,20 +6,20 @@ firstLineMatch: """(?x) \\Aflf2a | # Modeline - (?i: + (?: # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:fig(?:let)?+[-_]?(?:font|(?<=let))) - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - (?:fig(?:let)?+[-_]?(?:font|(?<=let))) - (?=\\s|:|$) + (?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:fig(?:let)?+[-_]?(?:font|(?<=let))) + (?=$|\\s|:) ) """ patterns: [include: "#main"] diff --git a/grammars/opentype.cson b/grammars/opentype.cson index 9a7b847..8c2ddc3 100644 --- a/grammars/opentype.cson +++ b/grammars/opentype.cson @@ -7,20 +7,20 @@ firstLineMatch: """(?x) \\A\\s*@figures\\s+=\\s+\\\[\\r?\\n\\s*zero(?:$|\\s) | # Modeline - (?i: + (?: # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:fea(?:tures?(?:[-_]?file)?)|opentype|otf) - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - (?:fea(?:tures?(?:[-_]?file)?)|opentype|otf) - (?=\\s|:|$) + (?:(?:^|[ \\t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:fea(?:tures?(?:[-_]?file)?)|opentype|otf) + (?=$|\\s|:) ) """ patterns: [include: "#main"] diff --git a/grammars/x-fontdir.cson b/grammars/x-fontdir.cson index fd385d2..ce30b2d 100644 --- a/grammars/x-fontdir.cson +++ b/grammars/x-fontdir.cson @@ -8,22 +8,20 @@ fileTypes: [ "encodings.dir" ] firstLineMatch: """(?x) - # Modeline - (?i: - # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - fontdir - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s)) - (?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:] - (?:filetype|ft|syntax)\\s*= - fontdir - (?=\\s|:|$) - ) + + # Emacs modeline + -\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*) + (?i:fontdir) + (?=[ \\t;]|(?]?[0-9]+|m)?|[ \\t]ex)(?=:(?=[ \\t]*set?[ \\t][^\\r\\n:]+:)|:(?![ \\t]*set?[ \\t])) + (?:(?:[ \\t]*:[ \\t]*|[ \\t])\\w*(?:[ \\t]*=(?:[^\\\\\\s]|\\\\.)*)?)*[ \\t:] + (?:filetype|ft|syntax)[ \\t]*= + (?i:fontdir) + (?=$|\\s|:) """ patterns: [include: "#main"]