valeriangalliat / markdown-it-highlightjs

Preset to use highlight.js with markdown-it.
The Unlicense
58 stars 31 forks source link

Load only languages needed to support (in Browser) #27

Closed tonqa closed 2 years ago

tonqa commented 2 years ago

I need language support for bash, which seems not to be out of the box. Other languages already get shown. Currently, I do the following for loading the markdown-it-highlightjs and bash language and potentially other languages.

async loadFurtherPlugins() {
  await Promise.all([
    import("markdown-it-highlightjs"),
    import("highlight.js/lib/languages/bash"),
  ]).then(([markdownHighlightJs, bashLanguage]) => {
    md.use(markdownHighlightJs?.default, {
      register: {
        "bash": bashLanguage?.default,
      },
    });
  });
}

Via debugging everythings seems to be okay, no errors. The markdown-it-highlightjs and the bash language object are loaded properly. However, the bash language is not shown in the web frontend. What do I do wrong?

tonqa commented 2 years ago

I just recognized that the following lines are not highlighted in bash language at all.

yarn add @fortawesome/free-solid-svg-icons
yarn add @fortawesome/free-brands-svg-icons

But in general the above lines works. Additionally, I recognized bash is activated by default. Thanks again.