GCODE highlighting is not included by default

AI-generated summary

GCODE Highlighting Not Included by Default

A user, filip, reported an issue with GCODE highlighting not working properly on the site, despite being a supported language in highlight.js. jomaxro explained that highlight.js supports many languages, but not all are enabled by default for performance reasons. To fix the issue, jomaxro suggested adding GCODE to the “highlighted languages” site setting.

After enabling GCODE, filip reported that the highlighting was still not working correctly, but suspected it was a highlight.js issue, specifically with handling GCODE comments. jomaxro confirmed that this was an issue to be taken up with highlight.js, and was glad that enabling GCODE had improved the situation.

Hi,

Trouble

.gcode highlighting is confused, even though gcode is a supported language in highlight.js.

A simple test

auto language selection (maybe some sort of C? )

M117 Heating Up ; write heating up
M190 S30 ; heat up the bed to 30°C and hold

ruby specified (yay. this is to show that forced language selection does something)

M117 Heating Up ; write heating up
M190 S30 ; heat up the bed to 30°C and hold

gcode specified (nay, it looks like the auto-select, and it ain’t right.)

M117 Heating Up ; write heating up
M190 S30 ; heat up the bed to 30°C and hold

thus

Is there some test I can do to see whether this is on Discourse side or Highlight.js side?
(And then, what would that mean…)

highlight.js supports a very large number of languages. It would result in very poor performance if we supported all languages by default. gcode is not a default language supported, so it will not work here on Meta. You can add support for gcode on your site by adding it to the highlighted languages site setting.

For reference, here are the languages supported on Meta:

Thanks for a swift reply.

After I enabled gcode, the highlighting is still funky/ funky in a completely new way, but now it looks like highlight.js issue. I guess the gcode support is just… not working. Still better than before! just can’t handle gcode comments it seems.

Thanks!

That you’d need to take up with highlight.js. Glad you got it working!