Commit ee7ab563b63b43e7ce03c4b23b39d6ad49056ba9

Michael Schmidt 2021-12-05T14:32:23

G-Code: Use standard-conforming alias for checksum (#3205)

diff --git a/components/prism-gcode.js b/components/prism-gcode.js
index d093878..a41bc79 100644
--- a/components/prism-gcode.js
+++ b/components/prism-gcode.js
@@ -7,9 +7,10 @@ Prism.languages.gcode = {
 	'keyword': /\b[GM]\d+(?:\.\d+)?\b/,
 	'property': /\b[A-Z]/,
 	'checksum': {
-		pattern: /\*\d+/,
-		alias: 'punctuation'
+		pattern: /(\*)\d+/,
+		lookbehind: true,
+		alias: 'number'
 	},
 	// T0:0:0
-	'punctuation': /:/
+	'punctuation': /[:*]/
 };
diff --git a/components/prism-gcode.min.js b/components/prism-gcode.min.js
index 85e2c52..54464df 100644
--- a/components/prism-gcode.min.js
+++ b/components/prism-gcode.min.js
@@ -1 +1 @@
-Prism.languages.gcode={comment:/;.*|\B\(.*?\)\B/,string:{pattern:/"(?:""|[^"])*"/,greedy:!0},keyword:/\b[GM]\d+(?:\.\d+)?\b/,property:/\b[A-Z]/,checksum:{pattern:/\*\d+/,alias:"punctuation"},punctuation:/:/};
\ No newline at end of file
+Prism.languages.gcode={comment:/;.*|\B\(.*?\)\B/,string:{pattern:/"(?:""|[^"])*"/,greedy:!0},keyword:/\b[GM]\d+(?:\.\d+)?\b/,property:/\b[A-Z]/,checksum:{pattern:/(\*)\d+/,lookbehind:!0,alias:"number"},punctuation:/[:*]/};
\ No newline at end of file
diff --git a/tests/languages/gcode/checksum_feature.test b/tests/languages/gcode/checksum_feature.test
index d3ea456..166ae2b 100644
--- a/tests/languages/gcode/checksum_feature.test
+++ b/tests/languages/gcode/checksum_feature.test
@@ -4,7 +4,8 @@ G28*22
 
 [
 	["keyword", "G28"],
-	["checksum", "*22"]
+	["punctuation", "*"],
+	["checksum", "22"]
 ]
 
 ----------------------------------------------------