Summary Files Commits Branches @commit @diff @stats
path: root / awk-edits / Syntax-highlighting.awk
diff options
context:
space:
mode:
Commit256745e04194ec60d3d3069909afdef85e060d35 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-04-29 11:20:30 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-04-29 11:20:30 +0300
Filesad357b9a40d565b876fec1e55628ba7dc83b7159 /awk-edits/Syntax-highlighting.awk
syndamia.com-256745e04194ec60d3d3069909afdef85e060d35.tar
syndamia.com-256745e04194ec60d3d3069909afdef85e060d35.tar.gz
syndamia.com-256745e04194ec60d3d3069909afdef85e060d35.zip
Parent0d04ad2871d29dc0c733b0454e3ec44133850c83 (diff)
[Syntax-highlighting] Ported all of bash regexes
1 files changed, 24 insertions, 7 deletions
-rw-r--r--awk-edits/Syntax-highlighting.awk31
diff --git a/awk-edits/Syntax-highlighting.awk b/awk-edits/Syntax-highlighting.awk
index 1655e8e..caec9cf 100644
--- a/awk-edits/Syntax-highlighting.awk
+++ b/awk-edits/Syntax-highlighting.awk
@@ -23,8 +23,8 @@ function hi(pat, class) {
function hie(pat, epat, class) {
return gesub(pat, epat, "<span class=\"HI-" class "\">&</span>");
}
-function hil(lbpat, pat, lrpat, empt, class) {
- return glsub(lbpat, pat, lrpat, "<span class=\"HI-" class "\">&</span>", empt);
+function hil(lbpat, pat, lrpat, class) {
+ return glsub(lbpat, pat, lrpat, "<span class=\"HI-" class "\">&</span>");
}
#
@@ -107,16 +107,33 @@ syntaxhighlighting == 2 {
}
syntaxhighlighting == 3 {
+ $0 = gesub(@/=/, "<[^>]*>", "\\&#61;");
hi(@/("[^"]*"|'[^']*')/, "string");
+ $0 = hil(@/[^\>&]/,
+ @/#.*$/,
+ "",
+ "comment");
+ $0 = hil(@/[^[:alpha:]#]/,
+ @/[[:digit:]]+/,
+ @/([^[:alpha:];]|$)/,
+ "number");
hi(@/\$(\(|\(\(|{).+(\)|\)\)|})/, "structure");
hi(@/\$[^[:blank:]]+/, "structure");
- # gsub(/[[:blank:]]+-[-_[:alnum:]]+/, "<span class=\"SH-kwd2\">&</span>");
- $0 = hil(@/[^[:alnum:]]/, @/(if|fi|then|case|esac|==|!=|-eq|-ne|-gt|-ge|-lt|-le|;;|;|\|\||&#38;&#38;)/, @/[^[:alnum:]]/, 3, "conditional");
+ $0 = hil(@/[[:blank:]]+/, @/-[-_[:alnum:]]+/, "", "operator");
+ $0 = hil(@/(^|[^[:alnum:]])/,
+ @/(if|fi|then|case|esac|&#61;&#61;|!&#61;|-eq|-ne|-gt|-ge|-lt|-le|;;|;|\|\||&#38;&#38;)/,
+ @/([^[:alnum:]]|$)/,
+ "conditional");
hi(@/(^|[[:blank:]]+)(for|while|until|in|do|done)($|[[:blank:]])/, "repeat");
- $0 = hil(@/[[:blank:]]*/, @/[[:alnum:]]+/, @/=/, 0, "identifier");
- # $0 = hil("", @/[-_[:alnum:]]+[[:blank:]]*/, @/\([^\)]*\)/, 0, "function");
+ $0 = hil(@/(^|[[:blank:]]+)/,
+ @/[[:alnum:]]+/,
+ @/(|\+|-)&#61;/,
+ "identifier");
+ $0 = hil("",
+ @/[-_[:alnum:]]+[[:blank:]]*/,
+ @/\([^\)]*\)/,
+ "function");
hi(@/[\{\}]/, "function");
- # $0 = hil(@/[^\>]/, @/#.*$/, "", 0, "comment");
}
#