highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

fix(gcode): stricter gcode line number matching

Open barthy-koeln opened this issue 2 years ago • 1 comments

Changes

The current G-CODE syntax is too loose on the "line number" instruction matching.

Example:

N1 M6
N2 SAVE_CONFIG

Rendered as:

<span class="hljs-symbol">N1</span> <span class="hljs-name">M6</span>
<span class="hljs-symbol">N1</span> SAVE_CO<span class="hljs-symbol">NFIG</span>

NFIG is not a line number instruction or symbol. My proposed fix is to strictly match the letter N, followed by one or more digits.


This does not resolve all issues, such as matching N\d+ that is NOT at the start of the line:

SKEW_PROFILE SAVE=GuteN8

Rendered as

SKEW_PROFILE SAVE=Gute<span class="hljs-symbol">N8</span>

I haven't found a straightforward and reliable specification or source listing exactly which optional characters are allowed before line numbers. Unfortunately, I currently don't have the time to dive deeper into ISO specs.

But I think that this a good minimal change that resolves some issues and hopefully doesn't cause others.

Checklist

  • [x] Added markup tests
  • [x] Updated the changelog at CHANGES.md

barthy-koeln avatar Apr 06 '24 11:04 barthy-koeln

I suggest closing this in favor of #4040

barthy-koeln avatar Apr 14 '24 10:04 barthy-koeln

Closing per suggestion.

joshgoebel avatar Oct 31 '24 21:10 joshgoebel