Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options to change syntax highlighting theme #10

Open
KL13NT opened this issue May 3, 2021 · 0 comments
Open

Options to change syntax highlighting theme #10

KL13NT opened this issue May 3, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@KL13NT
Copy link
Owner

KL13NT commented May 3, 2021

Marp uses highlight-js under the hood with specific highlight-js CSS for each Marp theme. Currently, there's no way to change this behaviour but overriding the whole highlighter setup as mentioned here.

We could switch out hl-js with prism-js as mentioned here. I modified the code mentioned in the issue above to use Prism instead of highlight-js. This should work.

// engine.js
const { Marp } = require('@marp-team/marp-core')
const hljs = require('highlight.js')
const hljsDefineIECST = require('highlightjs-structured-text')
const Prism = require('prismjs')

module.exports = (opts) => {
  const marp = new Marp(opts) // marp initialization in scripts

  // Use custom highlight.js instance in Marp highlighter
  // The following is exactly same as https://github.com/marp-team/marp-core/blob/883e1d75ddf0bdf26a00cafd4f58d94a26fe4949/src/marp.ts#L92-L99
  marp.highlighter = (code, lang) => {
    if (Prism.languages[lang]) {
      return Prism.highlight(code, Prism.languages[lang], lang);
    }
    return code
  }

  return marp
}
@KL13NT KL13NT added enhancement New feature or request status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and removed status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity labels May 3, 2021
KL13NT added a commit that referenced this issue May 3, 2021
…l required configurable styles there's no need to load more, especially given #10
KL13NT added a commit that referenced this issue May 3, 2021
Since Marp already provides all required configurable styles there's no need to load more, especially given #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant