Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit01cd3571d311b68f289b23e159edad1c54273565 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-03-28 12:39:54 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-03-28 12:39:54 +0300
Files9f32da5cd75e689890a0bf9445784bb1a864ffeb
syndamia.com-01cd3571d311b68f289b23e159edad1c54273565.tar
syndamia.com-01cd3571d311b68f289b23e159edad1c54273565.tar.gz
syndamia.com-01cd3571d311b68f289b23e159edad1c54273565.zip
Parentf732202b9edde97e1d2f424d89e12ab661279a2b (diff)
[Syntax-highlighting] Separated grammar syntax highlighting variable init
1 files changed, 17 insertions, 6 deletions
-rw-r--r--awk-edits/Syntax-highlighting.awk23
diff --git a/awk-edits/Syntax-highlighting.awk b/awk-edits/Syntax-highlighting.awk
index 4cffc6e..7a8065e 100644
--- a/awk-edits/Syntax-highlighting.awk
+++ b/awk-edits/Syntax-highlighting.awk
@@ -15,7 +15,6 @@ BEGIN {
# This variable specifies what language is currently being highlighted.
# 0 is none, and >0 is the index/id of the language.
syntaxhighlighting=0;
- grammarNamesI = 0;
}
#
@@ -24,18 +23,24 @@ BEGIN {
# Code in the form
# name -> expression | expression | ...
#
-# Supports grammar and grammar+, the difference being that the first resets
+# Supports "grammar" and "grammar+", the difference being that the first resets
# what grammer names have been found in predvious grammar code blocks,
# while the second doesn't.
# The idea is that you could want to define a grammar in one code block,
# do some explanations and then continue the definition with other rules.
#
-syntaxhighlighting == 1 || /class="language-grammar(|\+)"/ {
- if (syntaxhighlighting == 0 && match($0, /class="language-grammar"/))
- grammarNamesI = 0;
+syntaxhighlighting == 0 && /class="language-grammar"/ {
+ grammarNamesI = 0;
syntaxhighlighting = 1;
+}
+syntaxhighlighting == 0 && /class="language-grammar\+"/ {
+ grammarNamesI = 1;
+ syntaxhighlighting = 1;
+}
+
+syntaxhighlighting == 1 {
# Extract the name of the current grammar in the array grammarNames
# Since a grammar name could appear in multiple different rule expressions
grammarDef = match($0, /[[:alnum:]]+[[:blank:]]*-&#62/);
@@ -63,8 +68,13 @@ syntaxhighlighting == 1 || /class="language-grammar(|\+)"/ {
#
# -- Regexes --
#
+# Supports "regex"
+
+syntaxhighlighting == 0 && /class="language-regex"/ {
+ syntaxhighlighting = 2;
+}
-syntaxhighlighting == 2 || /class="language-regex"/ {
+syntaxhighlighting == 2 {
syntaxhighlighting = 2;
gsub(/[\|\*]/, "<span class=\"SH-kwd\">&</span>");
@@ -74,6 +84,7 @@ syntaxhighlighting == 2 || /class="language-regex"/ {
#
# -- C# --
#
+# Supports "csharp"
/class="language-csharp"/ {
syntaxhighlighting = 3;