Replies: 1 comment
-
Hey there! This library will render your input to HTML like this: <pre><code class="language-mermaid">
flowchart LR
A --> B
B --> C
D --> C
</code></pre> So you'd want to install and use the mermaid JS library on the front end of your site. Have it look for those Alternatively, if you'd like to render your mermaid input inside of a final class MyCustomFencedCodeRenderer implements NodeRendererInterface
{
private FencedCodeRenderer $defaultRenderer;
public function __construct(FencedCodeRenderer $defaultRenderer)
{
$this->defaultRenderer = $defaultRenderer
}
public function render(Node $node, ChildNodeRendererInterface $childRenderer)
{
FencedCode::assertInstanceOf($node);
// Does this contain a mermaid diagram?
$infoWords = $node->getInfoWords();
if (\count($infoWords) !== 0 && $infoWords[0] === 'mermaid') {
return new HtmlElement('div', ['class' => 'mermaid'], Xml::escape($node->getLiteral()));
}
// Nope - use the default renderer instead
return $this->defaultRenderer->render($node, $childRenderer);
}
} Hope that helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to convert mermaid syntax to svg diagrams. How can I do it?
If you write the following,
I'd like to show this.
Beta Was this translation helpful? Give feedback.
All reactions