Skip to content

How to highlight a word in a code block #436

Answered by yhatt
masahir0y asked this question in Q&A
Discussion options

You must be logged in to vote

Marp (Core) uses highlight.js for code highlighting.

It is not possible to highlight a specific word within a code block, and not recommend to add the custom syntax for highlighting a specific word. If added the custom syntax, it may change the meaning of the original code and break syntax highlighting.

If you really need the ability to highlight specific words within a code block, you can write a script to overload the Marp Core's highlighter through Marp CLI custom engine.
https://github.com/marp-team/marp-core/blob/93cd661c1682afe950b8481d16a57a3f674fea6a/src/marp.ts#L94-L102

// engine.js
module.exports = ({ marp }) =>
  marp.use(({ marpit: marp }) => {
    const originalHighlighter = m…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yhatt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants