Skip to content

Commit

Permalink
chore(docs): Use langPrefix in highlight.js example. (#2176)
Browse files Browse the repository at this point in the history
To properly integrate [highlight.js](https://github.com/highlightjs/highlight.js/) when using `marked.setOptions`, you need to leverage `langPrefix` to add an additional `hljs` class to the top-level `<code>` element which will be rendered.

Closes #2171
  • Loading branch information
theengineear authored Aug 23, 2021
1 parent ce30ed4 commit e583f46
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/USING_ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ marked.setOptions({
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
return hljs.highlight(code, { language }).value;
},
langPrefix: 'hljs language-', // highlight.js css expects a top-level 'hljs' class.
pedantic: false,
gfm: true,
breaks: false,
Expand Down

1 comment on commit e583f46

@vercel
Copy link

@vercel vercel bot commented on e583f46 Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.