mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-29 20:29:40 +02:00
docs: add support for ``regexp
`` code blocks
Currently, shiki doesn't support code-blocks that use the regexp language, which means vitepress throws an error on them: ```regexp ^([1-9][0-9]*)(minute|hour|day|week|month)$ ``` As a hack until shiki supports them, I've just modified them to get converted into JavaScript RegEx literal code-blocks, e.g.: ```javascript /^([1-9][0-9]*)(minute|hour|day|week|month)$/ ```
This commit is contained in:
@@ -54,6 +54,15 @@ const MermaidExample = async (md: MarkdownRenderer) => {
|
||||
return `<div class="tip custom-block"><p class="custom-block-title">NOTE</p><p>${token.content}}</p></div>`;
|
||||
}
|
||||
|
||||
if (token.info.trim() === 'regexp') {
|
||||
// shiki doesn't yet support regexp code blocks, but the javascript
|
||||
// one still makes RegExes look good
|
||||
token.info = 'javascript';
|
||||
// use trimEnd to move trailing `\n` outside if the JavaScript regex `/` block
|
||||
token.content = `/${token.content.trimEnd()}/\n`;
|
||||
return defaultRenderer(tokens, index, options, env, slf);
|
||||
}
|
||||
|
||||
if (token.info.trim() === 'jison') {
|
||||
return `<div class="language-">
|
||||
<button class="copy"></button>
|
||||
|
Reference in New Issue
Block a user