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

request: gcode highlighting #1571

Closed
marc-medley opened this issue Sep 23, 2018 · 4 comments · Fixed by #1572
Closed

request: gcode highlighting #1571

marc-medley opened this issue Sep 23, 2018 · 4 comments · Fixed by #1572

Comments

@marc-medley
Copy link

Request: add "G-code" syntax highlighting to prism with the language identifier of gcode.

G-code is the common name for the most widely used numerical control (NC) programming language. see Wikipedia: G-code

The implementation is really small and already exists in https://github.com/kmoser77/prismjs-reprap-gcode.

Prism.languages.reprap_gcode = {
	comment: /;.*/,
	keyword: /\b(G[\d]+|M[\d]+)\b/g,
	property: /\b(X|Y|Z|E|F|S|P|T|I|J|D|H|R|Q|N|\*)/g
};

gcode-syntax-highlight

@RunDevelopment
Copy link
Member

@marc-medley
May I ask what the * property refers to? I can't find it in the linked Wikipedia page.

@marc-medley
Copy link
Author

/;.*/ is comment string wildcard

property…\*)… is for a checksum field that may appear at the end of the executable portion of the line:

N3 T0*57 ; This is a comment
N4 G92 E0*67
; So is this
N5 G28*22

see https://reprap.org/wiki/G-code#.2A:_Checksum

@RunDevelopment
Copy link
Member

@marc-medley
Thank you!

We might as well also add strings before they destroy our comments.

@marc-medley
Copy link
Author

… also add strings before they destroy our comments.

good catch.

mAAdhaTTah pushed a commit that referenced this issue Dec 1, 2018
This PR adds the [G-code language](https://reprap.org/wiki/G-code) to Prism
and resolves #1571.

### Features

- All fields from A-Z ([case sensitive](https://reprap.org/wiki/G-code#Case_sensitivity)) and [checksums](https://reprap.org/wiki/G-code#.2A:_Checksum) (`*`).
- [Comments](https://reprap.org/wiki/G-code#Comments) of both the semicolon and parenthesis style.
- [Quoted strings](https://reprap.org/wiki/G-code#Quoted_strings).
- The colon punctuation of [lists (see the example)](https://reprap.org/wiki/G-code#M584:_Set_drive_mapping).
ggrossetie pushed a commit to ggrossetie/prism that referenced this issue Mar 11, 2019
This PR adds the [G-code language](https://reprap.org/wiki/G-code) to Prism
and resolves PrismJS#1571.

### Features

- All fields from A-Z ([case sensitive](https://reprap.org/wiki/G-code#Case_sensitivity)) and [checksums](https://reprap.org/wiki/G-code#.2A:_Checksum) (`*`).
- [Comments](https://reprap.org/wiki/G-code#Comments) of both the semicolon and parenthesis style.
- [Quoted strings](https://reprap.org/wiki/G-code#Quoted_strings).
- The colon punctuation of [lists (see the example)](https://reprap.org/wiki/G-code#M584:_Set_drive_mapping).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants