From c226779aca588a8d034be71056ac8a1194c0bf08 Mon Sep 17 00:00:00 2001 From: john-batch <70102999+john-batch@users.noreply.github.com> Date: Sun, 15 Aug 2021 16:00:41 +0200 Subject: [PATCH] Case-insensitive highlighting of hexadecimal constants --- runtime/syntax/erb.yaml | 4 ++-- runtime/syntax/git-rebase-todo.yaml | 2 +- runtime/syntax/groovy.yaml | 30 ++++++++++++++--------------- runtime/syntax/html4.yaml | 4 ++-- runtime/syntax/html5.yaml | 4 ++-- runtime/syntax/objc.yaml | 3 +-- runtime/syntax/php.yaml | 2 +- runtime/syntax/python3.yaml | 2 +- runtime/syntax/ruby.yaml | 2 +- runtime/syntax/vue.yaml | 17 +++++++--------- 10 files changed, 33 insertions(+), 37 deletions(-) diff --git a/runtime/syntax/erb.yaml b/runtime/syntax/erb.yaml index d58e9b2d..fbe420b1 100644 --- a/runtime/syntax/erb.yaml +++ b/runtime/syntax/erb.yaml @@ -1,6 +1,6 @@ filetype: erb -detect: +detect: filename: "\\.erb$|\\.rhtml$" rules: @@ -12,7 +12,7 @@ rules: - symbol: "[:=]" - identifier: "(alt|bgcolor|height|href|id|label|longdesc|name|onclick|onfocus|onload|onmouseover|size|span|src|style|target|type|value|width)=" - constant.string: "\"[^\"]*\"" - - constant.number: "(?i)#[0-9A-F]{6,6}" + - constant.number: "(?i)#[0-9a-fA-F]{6,6}" - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" - comment: "" - preproc: "" diff --git a/runtime/syntax/git-rebase-todo.yaml b/runtime/syntax/git-rebase-todo.yaml index 0d31d13a..724f9c9c 100644 --- a/runtime/syntax/git-rebase-todo.yaml +++ b/runtime/syntax/git-rebase-todo.yaml @@ -7,7 +7,7 @@ rules: # Rebase commands - statement: "^(p(ick)?|r(eword)?|e(dit)?|s(quash)?|f(ixup)?|x|exec|b(reak)?|d(rop)?|l(abel)?|t|reset|m(erge)?)\\b" # Commit IDs - - identifier: "\\b([0-9a-f]{7,40})\\b" + - identifier: "\\b([0-9a-fA-F]{7,40})\\b" # Color keywords for Github (and others) - type.keyword: "\\b(?i)((fix(es|ed)?|close(s|d)?) #[0-9]+)\\b" diff --git a/runtime/syntax/groovy.yaml b/runtime/syntax/groovy.yaml index eb41331e..c8d310c3 100644 --- a/runtime/syntax/groovy.yaml +++ b/runtime/syntax/groovy.yaml @@ -9,13 +9,13 @@ rules: - identifier: "\\b[A-Z_$]+\\b" # The style guide for JVM languages is PascalCase for classes and interfaces - identifier.class: "\\b[A-Z][a-zA-Z0-9$]+\\b" - + # Primitive types - type: "\\b(byte|short|int|long|float|double|char|boolean|void)\\b" - + # Type-related keywords - type.keyword: "\\b(private|public|protected|static|final|var|def)\\b" - + # Keywords - statement: "\\b(for|while|do|if|else|switch|case|default|try|catch|finally)\\b" - statement: "\\b(break|continue|return|throw|assert)\\b" @@ -23,11 +23,11 @@ rules: - statement: "\\b(this|super)\\b" # Unsused, but reserved keywords - statement: "\\b(goto|const)\\b" - + # Operators and punctuation - symbol.operator: "[-+*/%=<>^~&|!?:;,.@]|\\b(in|is|as|instanceof|new)\\b" - symbol.brackets: "[(){}]|\\[|\\]" - + # Decimal integer literal - constant.number: "(?i)\\b[1-9]([_0-9]*[0-9])?[GLIDF]?\\b" # Binary integer literal @@ -35,14 +35,14 @@ rules: # Octal integer literal - constant.number: "(?i)\\b0[0-7]([0-7_]*[0-7])?[GLIDF]?\\b" # Hexadecimal integer literal - - constant.number: "(?i)\\b0x[0-9a-f]([0-9a-f_]*[0-9a-f])?[GLIDF]?\\b" + - constant.number: "(?i)\\b0x[0-9a-fA-F]([0-9a-f_]*[0-9a-fA-F])?[GLIDF]?\\b" # Floating-point literal - constant.number: "(?i)\\b[0-9]([0-9_]*[0-9])?([.][0-9]([0-9_]*[0-9])?)?(e[+-]?[0-9]([0-9_]*[0-9])?)?[DF]?\\b" - constant.bool: "\\b(true|false|null)\\b" - + # Annotations - identifier: "@[A-Za-z_$][A-Za-z0-9_$]*\\b" - + # Single-quoted strings - constant.string: start: "'" @@ -50,7 +50,7 @@ rules: skip: "\\\\." rules: - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})" - + # This also matches the Triple-double-quoted strings region, but I can't really find a way to mitigate it, all the while still matching "" as a string correctly # Also, nesting ${} are never going to be matched correctly with just regex either, so highlighting will break if one is to nest interpolation # These two problems combined mean slight mistakes in highlighing that the user is just going to have to deal with @@ -63,7 +63,7 @@ rules: - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})" - identifier.var: "\\x24[\\w\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+([.][a-zA-Z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+)*" - identifier: "\\x24[{].*[}]" - + # Triple-double-quoted strings - constant.string: start: "\"\"\"" @@ -76,7 +76,7 @@ rules: start: "[$][{]" end: "[}]" rules: [] - + # Triple-single-quoted strings - constant.string: start: "'''" @@ -84,28 +84,28 @@ rules: skip: "\\\\." rules: - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})" - + # Slashy strings are left out, because they match in unwanted places pretty much all the time # Dollar-slashy strings - constant.string: start: "[$]/" end: "/[$]" rules: [] - + # Single-line comments - comment: start: "//" end: "$" rules: - todo: "(TODO|XXX|FIXME):?" - + # Multiline comments - comment: start: "/[*]" end: "[*]/" rules: - todo: "(TODO|XXX|FIXME):?" - + # Groovydoc comments - comment: start: "/[*][*]@?" diff --git a/runtime/syntax/html4.yaml b/runtime/syntax/html4.yaml index 7bf851ea..c132d61e 100644 --- a/runtime/syntax/html4.yaml +++ b/runtime/syntax/html4.yaml @@ -1,6 +1,6 @@ filetype: html4 -detect: +detect: filename: "\\.htm[l]?4$" header: "" @@ -13,7 +13,7 @@ rules: - symbol: "[:=]" - identifier: "(alt|bgcolor|height|href|id|label|longdesc|name|on(click|focus|load|mouseover)|size|span|src|style|target|type|value|width)=" - constant.string: "\"[^\"]*\"" - - constant.number: "(?i)#[0-9A-F]{6,6}" + - constant.number: "(?i)#[0-9a-fA-F]{6,6}" - default: start: ">" end: "<" diff --git a/runtime/syntax/html5.yaml b/runtime/syntax/html5.yaml index bce0ae89..411d5385 100644 --- a/runtime/syntax/html5.yaml +++ b/runtime/syntax/html5.yaml @@ -1,6 +1,6 @@ filetype: html5 -detect: +detect: filename: "\\.htm[l]?5$" header: "" @@ -13,7 +13,7 @@ rules: - symbol: "[:=]" - identifier: "(alt|bgcolor|height|href|id|label|longdesc|name|on(click|focus|load|mouseover)|size|span|src|style|target|type|value|width)=" - constant.string: "\"[^\"]*\"" - - constant.number: "(?i)#[0-9A-F]{6,6}" + - constant.number: "(?i)#[0-9a-fA-F]{6,6}" - default: start: ">" end: "<" diff --git a/runtime/syntax/objc.yaml b/runtime/syntax/objc.yaml index 1a8b7197..223d6929 100644 --- a/runtime/syntax/objc.yaml +++ b/runtime/syntax/objc.yaml @@ -25,7 +25,7 @@ rules: - statement: "([.:;,+*|=!\\%\\[\\]]|<|>|/|-|&)" - - constant.number: "(\\b(-?)?[0-9]+\\b|\\b\\[0-9]+\\.[0-9]+\\b|\\b0x[0-9A-F]+\\b)" + - constant.number: "(\\b(-?)?[0-9]+\\b|\\b\\[0-9]+\\.[0-9]+\\b|\\b0x[0-9a-fA-F]+\\b)" - constant: "(@\\[(\\\\.|[^\\]])*\\]|@\\{(\\\\.|[^\\}])*\\}|@\\((\\\\.|[^\\)])*\\))" - constant: "\\b<(\\\\.[^\\>])*\\>\\b" - constant: "\\b(nil|NULL|YES|NO|TRUE|true|FALSE|false|self)\\b" @@ -57,4 +57,3 @@ rules: end: "\\*/" rules: - todo: "(TODO|XXX|FIXME):?" - diff --git a/runtime/syntax/php.yaml b/runtime/syntax/php.yaml index a4e20dec..7488be3c 100644 --- a/runtime/syntax/php.yaml +++ b/runtime/syntax/php.yaml @@ -12,7 +12,7 @@ rules: - special: "&[^;[[:space:]]]*;" - symbol: "[:=]" - identifier: "(alt|bgcolor|height|href|label|longdesc|name|onclick|onfocus|onload|onmouseover|size|span|src|style|target|type|value|width)=" - - constant.number: "(?i)#[0-9A-F]{6,6}" + - constant.number: "(?i)#[0-9a-fA-F]{6,6}" - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" - comment: "" - default: "<\\?(php|=)\" end=\"\\?>" diff --git a/runtime/syntax/python3.yaml b/runtime/syntax/python3.yaml index 93f4f483..f84d536e 100644 --- a/runtime/syntax/python3.yaml +++ b/runtime/syntax/python3.yaml @@ -29,7 +29,7 @@ rules: - constant.number: "\\b[0-9](_?[0-9])*(\\.([0-9](_?[0-9])*)?)?(e[0-9](_?[0-9])*)?\\b" # decimal - constant.number: "\\b0b(_?[01])+\\b" # bin - constant.number: "\\b0o(_?[0-7])+\\b" # oct - - constant.number: "\\b0x(_?[0-9a-f])+\\b" # hex + - constant.number: "\\b0x(_?[0-9a-fA-F])+\\b" # hex - constant.string: start: "\"\"\"" diff --git a/runtime/syntax/ruby.yaml b/runtime/syntax/ruby.yaml index c55feb4b..f1f9e2a2 100644 --- a/runtime/syntax/ruby.yaml +++ b/runtime/syntax/ruby.yaml @@ -18,7 +18,7 @@ rules: - statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|for|if|in|module|next|nil|not|or|private|protected|public|redo|rescue|retry|return|self|super|then|undef|unless|until|when|while|yield)\\b" - constant: "(\\$|@|@@)?\\b[A-Z]+[0-9A-Z_a-z]*" - - constant.number: "(?i)\\b0x[0-9a-f][0-9a-f_]*\\b" + - constant.number: "(?i)\\b0x[0-9a-fA-F][0-9a-f_]*\\b" - constant.number: "(?i)\\b0b[01][01_]*\\b" - constant.number: "(?i)\\b[0-9][0-9_]*(['.'][0-9_]+)?(e[\\-]?[0-9_]+)?\\b" # Ruby "Symbols" diff --git a/runtime/syntax/vue.yaml b/runtime/syntax/vue.yaml index a505ca40..d5e10c34 100644 --- a/runtime/syntax/vue.yaml +++ b/runtime/syntax/vue.yaml @@ -11,14 +11,14 @@ rules: rules: - error: "<[^!].*?>" - symbol.tag: "(?i)<[/]?(a|a(bbr|ddress|rea|rticle|side|udio)|b|b(ase|d(i|o)|lockquote|r|utton)|ca(nvas|ption)|center|cite|co(de|l|lgroup)|d(ata|atalist|d|el|etails|fn|ialog|l|t)|em|embed|fieldset|fig(caption|ure)|form|iframe|h[1-6]|hr|i|img|in(put|s)|kbd|keygen|label|legend|li|link|ma(in|p|rk)|menu|menuitem|met(a|er)|nav|noscript|o(bject|l|pt(group|ion)|utput)|p|param|picture|pre|progress|q|r(p|t|uby)|s|samp|se(ction|lect)|svg|small|source|span|strong|su(b|p|mmary)|textarea|time|track|u|ul|var|video|wbr)( .*)*?>" - - symbol.tag.extended: "(?i)<[/]?(body|div|html|head(er)?|footer|title|table|t(body|d|h(ead)?|r|foot))( .*)*?>" + - symbol.tag.extended: "(?i)<[/]?(body|div|html|head(er)?|footer|title|table|t(body|d|h(ead)?|r|foot))( .*)*?>" - preproc: "(?i)<[/]?(script|style)( .*)*?>" - special: "&[^;[[:space:]]]*;" - + - identifier: "(alt|bgcolor|class|height|href|id|label|longdesc|name|on(click|focus|load|mouseover)|placeholder|size|span|src|style|target|type|value|width)=" - symbol: "[:=]" - constant.string: "\"[^\"]*\"" - - constant.number: "(?i)#[0-9A-F]{6,6}" + - constant.number: "(?i)#[0-9a-fA-F]{6,6}" - symbol.tag: "<|>" - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" @@ -41,27 +41,24 @@ rules: - symbol.tag.extended: "(?i)<[/]?(router-link|router-view)\\b" - identifier: "(to|v-slot)=" - symbol: "[:=]" - - - default: + + - default: start: "" limit-group: symbol.tag rules: - include: "javascript" - - default: + - default: start: "" end: "" rules: - include: "typescript" - + - default: start: "" end: "" limit-group: symbol.tag rules: - include: "css" - - - -- 2.44.0