Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gcode): stricter gcode line number matching #4034

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Expand Up @@ -39,6 +39,7 @@ Core Grammars:
- enh(markdown) add entity support [David Schach][] [TaraLei][]
- enh(css) add `justify-items` and `justify-self` attributes [Vasily Polovnyov][]
- enh(css) add `accent-color`, `appearance`, `color-scheme`, `rotate`, `scale` and `translate` attributes [Carl Räfting][]
- fix(gcode) stricter gcode line number matching [Barthy Bonhomme][]

New Grammars:

Expand Down Expand Up @@ -88,7 +89,7 @@ Themes:
[Rúnar Bjarnason]: https://github.com/runarorama
[Carl Räfting]: https://github.com/carlrafting
[BackupMiles]: https://github.com/BackupMiles

[Barthy Bonhomme]: https://github.com/barthy-koeln


## Version 11.9.0
Expand Down
8 changes: 1 addition & 7 deletions src/languages/gcode.js
Expand Up @@ -51,13 +51,7 @@ export default function(hljs) {
},
{
className: 'symbol',
variants: [
{
begin: 'N',
end: '\\d+',
illegal: '\\W'
}
]
begin: 'N\\d+'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
begin: 'N\\d+'
match: /N\d+/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change the other 10 regexes with single quotes in that file, too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I found heaps more issues with samples of gcode I could find online. I will submit a PR with substantial changes. Until this, this suggestion was implemented and this PR can stay as small as it is.

}
];

Expand Down
1 change: 1 addition & 0 deletions test/markup/gcode/default.expect.txt
Expand Up @@ -28,4 +28,5 @@
<span class="hljs-symbol">N26</span> <span class="hljs-attr">#4</span>=<span class="hljs-attr">#5</span>*<span class="hljs-built_in">COS[<span class="hljs-number">45</span>]</span>
<span class="hljs-symbol">N27</span> <span class="hljs-attr">#4</span>=<span class="hljs-attr">#5</span>*<span class="hljs-built_in">SIN[<span class="hljs-number">45</span>]</span>
<span class="hljs-symbol">N28</span> <span class="hljs-attr">VZOFZ</span>=<span class="hljs-number">652.9658</span>
<span class="hljs-symbol">N29</span> SAVE_CONFIG
<span class="hljs-meta">%</span>
1 change: 1 addition & 0 deletions test/markup/gcode/default.txt
Expand Up @@ -28,4 +28,5 @@ N25 G84.3 X-0.1
N26 #4=#5*COS[45]
N27 #4=#5*SIN[45]
N28 VZOFZ=652.9658
N29 SAVE_CONFIG
%