A remark plugin that renders nomnoml diagrams inline as svg.
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkNomnoml from '@zenobius/remark-nomnoml';
import remarkStringify from 'remark-stringify';
const processor = unified()
.use(remarkParse)
.use(remarkNomnoml)
.use(remarkStringify);
const input = '```nomnoml\n
#stroke: #a86128\n
#direction: down\n
[<frame>Decorator pattern|\n
[<abstract>Component||+ operation()]\n
[Client] depends --> [Component]\n
[Decorator|- next: Component]\n
[Decorator] decorates -- [ConcreteComponent]\n
[Component] <:- [Decorator]\n
[Component] <:- [ConcreteComponent]\n
]\n
```\n';
const output = processor.processSync(input);
console.log(output.contents);▸ remarkNomnoml(this, ...parameters): undefined | void | Transformer<Root, Root>
| Name | Type |
|---|---|
this |
Processor<undefined, undefined, undefined, undefined, undefined> |
...parameters |
[RemarkNomNomlOptions?] |
undefined | void | Transformer<Root, Root>
• Optional errorFallback: (node: Code, error: string, file: VFile) => undefined | void | BlockContent
Create a fallback node if processing of a diagram fails.
▸ (node, error, file): undefined | void | BlockContent
| Name | Type | Description |
|---|---|---|
node |
Code |
The mdast code node that couldn't be rendered. |
error |
string |
The error message that was thrown. |
file |
VFile |
The file on which the error occurred. |
undefined | void | BlockContent
• Optional style: string