Closed DoubleF3lix closed 2 years ago
Using the markdown below and
```plaintext .minecraft saves <WORLD NAME> datapacks <datapack name> pack.mcmeta data <namespace> advancements dimension dimension_type functions loot_tables predicates recipes structures tags blocks entity_types fluids functions items worldgen biome configured_carver configured_feature configured_structure_feature configured_surface_builder noise_settings processor_list template_pool minecraft tags functions load.json tick.json ``` (ignore)
And this JavaScript to load the file:
async function displayMarkdownContent(name) { showdown.extension("codehighlight", function() { function htmlunencode(text) { return ( text .replace(/&/g, "&") .replace(/</g, "<") .replace(/>/g, ">") ); } return [ { type: 'output', filter: function (text, converter, options) { // use new shodown's regexp engine to conditionally parse codeblocks var left = "<pre><code\\b[^>]*>", right = "</code></pre>", flags = "g", replacement = function (wholeMatch, match, left, right) { // unescape match to prevent double escaping match = htmlunencode(match); return left + hljs.highlightAuto(match).value + right; }; return showdown.helper.replaceRecursiveRegExp(text, replacement, left, right, flags); } } ]; }); const markdownText = await fetch(`/java_datapack_tutorial/guides/${name}.md`).then(r => r.text()); let markdownOutput = new showdown.Converter({extensions: ["codehighlight"]}).makeHtml(markdownText); document.getElementById(`display-${name}-markdown`).innerHTML = markdownOutput; console.log(`Displaying /java_datapack_tutorial/guides/${name}.md`); }
I expected there to be no syntax highlighting, but instead it looks like this:
The same issue happens if the language is set to nohighlight
nohighlight
Not sure what I changed, but this doesn't happen anymore.
Using the markdown below and
And this JavaScript to load the file:
I expected there to be no syntax highlighting, but instead it looks like this:
The same issue happens if the language is set to
nohighlight