Skip to content

Commit

Permalink
Fix registered language name for grammar names with dash, fixes #3263.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jul 5, 2021
1 parent 55f68f7 commit ff54054
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stub.js
Expand Up @@ -5,7 +5,7 @@ import * as builtIns from "builtInLanguages";
const hljs = HighlightJS;

for (const key of Object.keys(builtIns)) {
const languageName = key.replace("grmr_", "");
const languageName = key.replace("grmr_", "").replace("_", "-");
hljs.registerLanguage(languageName, builtIns[key]);
}
// console.log(hljs.listLanguages());
Expand Down
9 changes: 9 additions & 0 deletions test/builds/browser_build_as_commonjs.js
Expand Up @@ -21,4 +21,13 @@ API.forEach(n => {
assert(_ => keys.includes(n), `API should include ${n}`);
});

// See e.g. highlightjs/highlight.js#3263
const langs = ["python", "python-repl"]
langs.forEach(n => {
assert(_ => {
res = hljs.getLanguage(n);
return typeof res === 'object' && res !== null
})
})

console.log("Pass: browser build works with Node.js just fine.")

0 comments on commit ff54054

Please sign in to comment.