Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

gml_string

GML syntax highlighting for games, websites, and more 路 By YellowAfterlife

Fix for GML string web version

A topic by indieklem created Mar 10, 2024 Views: 83 Replies: 3
Viewing posts 1 to 3

Hi,
I was following the web version of gml_string and I think there is an error in the getting started part:

for (let el of document.querySelectorAll("pre:not(.gml)")) {
    el.classList.add(".gml");
    el.innerHTML = gml_string.renderToHTML(el.innerHTML, "gml"); 
}

This return:
"Uncaught TypeError: tkk is undefined"
"renderToHTML /js/gml_string.js:993"

To fix this error here is my code:

for (let el of document.querySelectorAll("code:not(.gml)")) {
    el.classList.add("gml");
    var tks = [];
    gml_string.parse(el.innerHTML, tks);     el.innerHTML = gml_string.renderToHTML(tks, "gml");
}

Look like it was passing the wrong arg to the function renderToHtml(), tokens (tks) where missing.
Thanks for the plugin anyway, it was a bit difficult to setup cause of this but everything look fine now!

Developer(+1)

Cheers, I鈥檒l update the doc - I think that鈥檚 a leftover from an older version.

Developer

Upon further inspection, where鈥檇 you get that code sample from? The documentation quotes the correct way of doing it

This is from the code block, in the Getting Started section  馃憞馃徎