Syntax highlighting of code blocks is easily accomplished through the use of relevant rehype plugins that are explored in the sections below. In most situations, you also need to apply custom Sanitzation schemas to whitelist stylistic properties introduced from syntax highlighters.
rehype-highlightSyntax highlighting is done through the rehype-highlight plugin, which uses highlight.js under the hood. Please refer to the plugin documentation for configuations.
function greet() {
return "hello world";
}rehype-prismSyntax highlighting is done through the rehype-prism plugin, which uses prism.js under the hood. Please refer to the plugin documentation for configuations.
function greet() {
return "hello world";
}By default, unified-doc will auto-assign parsers based on inferred mime-type from the filename. This means that parsers supporting various content types (e.g. .html, .md) will not render its contents as source code in a code block. To explicitly render such content type as source code, disable the parser by assigning null to its corresponding mime type.
<blockquote><strong>some</strong> markdown content</blockquote>