G-Code: Use standard-conforming alias for checksum (#3205)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
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"]
]
----------------------------------------------------