summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaise2022-10-28 15:24:50 -0500
committerBlaise2022-10-28 15:38:31 -0500
commit55c6aa8c2cdbf9323ebd62599689991f4bd26a82 (patch)
treef8879ae74a0bb43544ff3a322ac1cdbede172c89
parentb3fa7450e80485f89e11d93e40de069d86d846c2 (diff)
Special treatment for diffs
-rw-r--r--microlight.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/microlight.js b/microlight.js
index 202cc0c..295cad2 100644
--- a/microlight.js
+++ b/microlight.js
@@ -62,6 +62,8 @@
62 lastTokenType, 62 lastTokenType,
63 // flag determining if token is multi-character 63 // flag determining if token is multi-character
64 multichar, 64 multichar,
65 // first token of line
66 firstToken,
65 node; 67 node;
66 68
67 // running through characters and highlighting 69 // running through characters and highlighting
@@ -110,6 +112,8 @@
110 ).setAttribute('class', 'c'+( 112 ).setAttribute('class', 'c'+(
111 // not formatted 113 // not formatted
112 !tokenType ? 0 : 114 !tokenType ? 0 :
115 // diff
116 tokenType > 10 ? tokenType :
113 // punctuation 117 // punctuation
114 tokenType < 3 ? 2 : 118 tokenType < 3 ? 2 :
115 // comments 119 // comments
@@ -133,10 +137,13 @@
133 // initializing a new token 137 // initializing a new token
134 token = ''; 138 token = '';
135 139
140 // first token of line
141 firstToken = pos < 2 || prev1 == '\n';
142
136 // determining the new token type (going up the 143 // determining the new token type (going up the
137 // list until matching a token type start 144 // list until matching a token type start
138 // condition) 145 // condition)
139 tokenType = 11; 146 tokenType = 15;
140 while (![ 147 while (![
141 1, // 0: whitespace 148 1, // 0: whitespace
142 // 1: operator or braces 149 // 1: operator or braces
@@ -159,7 +166,15 @@
159 chr+next1 == '/*', // 8: multiline comment 166 chr+next1 == '/*', // 8: multiline comment
160 chr+next1 == '//', // 9: single-line comment 167 chr+next1 == '//', // 9: single-line comment
161 // 10: hash-style comment 168 // 10: hash-style comment
162 chr == '#' && next1+text[pos+1]+text[pos+2] != 'inc' 169 chr == '#' && next1+text[pos+1]+text[pos+2] != 'inc',
170 // 11: diff add
171 firstToken && chr == '+',
172 // 12: diff remove
173 firstToken && chr == '-',
174 // 13: diff compared
175 firstToken && (chr+next1+text[pos+1] == '+++' || chr+next1+text[pos+1] == '---'),
176 // 14: diff offset
177 firstToken && chr+next1 == '@@'
163 ][--tokenType]); 178 ][--tokenType]);
164 } 179 }
165 180