From 3143b900ee506f64a5d5ffbb07251e8c22b6cde4 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 15 Jun 2025 13:55:10 -0400 Subject: [PATCH] Remove remaining color-specific rules to reduce complexities --- ansi/ansi.go | 8 ++++---- syntax/stxJs.go | 2 +- syntax/stxMakefile.go | 4 ++-- syntax/stxPython.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ansi/ansi.go b/ansi/ansi.go index 95c8de0..7827a97 100644 --- a/ansi/ansi.go +++ b/ansi/ansi.go @@ -39,16 +39,16 @@ func Colorize(inputCode, languageID string) (string, error) { colorCode = "\033[94m" // Bright Blue case highlite.Groups["preproc"]: colorCode = "\033[91m" // Bright Red - case highlite.Groups["special"], highlite.Groups["red"]: + case highlite.Groups["special"]: colorCode = "\033[31m" // Red case highlite.Groups["constant.string"], highlite.Groups["constant"], - highlite.Groups["constant.number"], highlite.Groups["cyan"]: + highlite.Groups["constant.number"]: colorCode = "\033[36m" // Cyan - case highlite.Groups["constant.specialChar"], highlite.Groups["magenta"]: + case highlite.Groups["constant.specialChar"]: colorCode = "\033[95m" // Bright Magenta case highlite.Groups["type"]: colorCode = "\033[33m" // Yellow - case highlite.Groups["comment"], highlite.Groups["brightgreen"]: + case highlite.Groups["comment"]: colorCode = "\033[92m" // Bright Green default: colorCode = "\033[0m" // Reset diff --git a/syntax/stxJs.go b/syntax/stxJs.go index 22d2792..f719edf 100644 --- a/syntax/stxJs.go +++ b/syntax/stxJs.go @@ -12,7 +12,7 @@ rules: - constant.number: "\\b[-+]?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?" - constant.number: "\\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" - identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]" - - cyan: "[\\(|\\)|/|+|\\-|\\*|\\[|.|,|;]" + - special: "[\\(|\\)|/|+|\\-|\\*|\\[|.|,|;]" - statement: "\\b(break|case|catch|continue|default|delete|do|else|finally)\\b" - statement: "\\b(for|function|get|if|in|instanceof|new|return|set|switch)\\b" - statement: "\\b(switch|this|throw|try|typeof|var|void|while|with|const|let)\\b" diff --git a/syntax/stxMakefile.go b/syntax/stxMakefile.go index df69feb..06b8322 100644 --- a/syntax/stxMakefile.go +++ b/syntax/stxMakefile.go @@ -17,8 +17,8 @@ rules: - statement: "(flavor|echo|foreach|if|else|fi(;)?|elif|case|esac(;)?|for|done|shift|chmod|chown(info)?|pwd|join|lastword|notdir|or)[[:space:]]" - statement: "\\$\\((origin|patsubst|realpath|shell|sort|strip|suffix)[[:space:]]" - statement: "\\$\\((value|warning|wildcard|word|wordlist|words)[[:space:]]" - - red: "([[:space:]]|^)(rm|rmdir|exit)[[:space:]]" - - magenta: "([[:space:]]|^)(gcc|ld)[[:space:]]" + - keyword: "([[:space:]]|^)(rm|rmdir|exit)[[:space:]]" + - special: "([[:space:]]|^)(gcc|ld)[[:space:]]" - type: "^.+:" - identifier: "[()$]" - constant.string: diff --git a/syntax/stxPython.go b/syntax/stxPython.go index fb4ae08..50f576b 100644 --- a/syntax/stxPython.go +++ b/syntax/stxPython.go @@ -13,7 +13,7 @@ rules: - type: "\\b(bool|bytearray|bytes|classmethod|complex|dict|enumerate|filter|float|frozenset|int|list|map|memoryview|object|property|range|reversed|set|slice|staticmethod|str|super|tuple|type|zip)\\b" - identifier: "def [a-zA-Z_0-9]+" - statement: "\\b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\\b" - - brightgreen: "@.*[(]" + - special: "@.*[(]" - statement: "([.:;,+*|=!\\%@]|<|>|/|-|&)" - statement: "([(){}]|\\[|\\])" - constant.number: "\\b[0-9]+\\b"