Skip to content

Commit

Permalink
Update modeline patterns to use github-linguist/linguist#5271
Browse files Browse the repository at this point in the history
  • Loading branch information
Alhadis committed Mar 12, 2021
1 parent cac307b commit 2fa1eaf
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 95 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 9 additions & 9 deletions grammars/afm.cson
Original file line number Diff line number Diff line change
Expand Up @@ -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;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:afm|adobe[-_]?font[-_]?metrics)
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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|$)"
Expand Down
18 changes: 9 additions & 9 deletions grammars/bdf.cson
Original file line number Diff line number Diff line change
Expand Up @@ -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;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:bdf)
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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"]
Expand Down
30 changes: 14 additions & 16 deletions grammars/bez.cson
Original file line number Diff line number Diff line change
Expand Up @@ -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;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim modeline
(?:(?:^|[ \\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:(?:std|standard)[-_]?bez(?:ier)?)
(?=$|\\s|:)
"""
patterns: [include: "#main"]

Expand Down
18 changes: 9 additions & 9 deletions grammars/ff-script.cson
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ firstLineMatch: """(?x)
(?!.*?[ \\t]-lang(?:=|\\s+)py)
|
# Modeline
(?i:
(?:
# Emacs
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
(?:fontforge|pfaedit)
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:fontforge|pfaedit)
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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"]
Expand Down
18 changes: 9 additions & 9 deletions grammars/ff-sfd.cson
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ firstLineMatch: """(?x)
^SplineFontDB:\\ [\\d.]+
|
# Modeline
(?i:
(?:
# Emacs
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
(?:sfd|spline[-_]?font[-_]?(?:database|db))
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:sfd|spline[-_]?font[-_]?(?:database|db))
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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"]
Expand Down
18 changes: 9 additions & 9 deletions grammars/figlet-control.cson
Original file line number Diff line number Diff line change
Expand Up @@ -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;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:fig(?:let)?+[-_]?(?:cfg|config|conf|control|ctrl))
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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: [{
Expand Down
18 changes: 9 additions & 9 deletions grammars/figlet-font.cson
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ firstLineMatch: """(?x)
\\Aflf2a
|
# Modeline
(?i:
(?:
# Emacs
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
(?:fig(?:let)?+[-_]?(?:font|(?<=let)))
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:fig(?:let)?+[-_]?(?:font|(?<=let)))
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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"]
Expand Down
18 changes: 9 additions & 9 deletions grammars/opentype.cson
Original file line number Diff line number Diff line change
Expand Up @@ -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;]|(?<![-*])-\\*-).*?-\\*-
-\\*-(?i:[ \\t]*(?=[^:;\\s]+[ \\t]*-\\*-)|(?:.*?[ \\t;]|(?<=-\\*-))[ \\t]*mode[ \\t]*:[ \\t]*)
(?i:fea(?:tures?(?:[-_]?file)?)|opentype|otf)
(?=[ \\t;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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"]
Expand Down
30 changes: 14 additions & 16 deletions grammars/x-fontdir.cson
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ fileTypes: [
"encodings.dir"
]
firstLineMatch: """(?x)
# Modeline
(?i:
# Emacs
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
fontdir
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\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;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim modeline
(?:(?:^|[ \\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:fontdir)
(?=$|\\s|:)
"""
patterns: [include: "#main"]

Expand Down

0 comments on commit 2fa1eaf

Please sign in to comment.