diff --git a/src/stub.js b/src/stub.js index ee342b5e3d..a447266e34 100644 --- a/src/stub.js +++ b/src/stub.js @@ -5,7 +5,11 @@ import * as builtIns from "builtInLanguages"; const hljs = HighlightJS; for (const key of Object.keys(builtIns)) { - const languageName = key.replace("grmr_", ""); + // our builtInLanguages Rollup plugin has to use `_` to allow identifiers to be + // compatible with `export` naming conventions, so we need to convert the + // identifiers back into the more typical dash style that we use for language + // naming via the API + const languageName = key.replace("grmr_", "").replace("_", "-"); hljs.registerLanguage(languageName, builtIns[key]); } // console.log(hljs.listLanguages()); diff --git a/test/builds/browser_build_as_commonjs.js b/test/builds/browser_build_as_commonjs.js index 8db2ec4e18..2bdd6e0cca 100644 --- a/test/builds/browser_build_as_commonjs.js +++ b/test/builds/browser_build_as_commonjs.js @@ -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.")