@mdit/plugin-uml
Plugin to support splitting contents from context.
Usage
import MarkdownIt from "markdown-it";
import { uml } from "@mdit/plugin-uml";
const mdIt = MarkdownIt().use(uml, {
name: "demo",
open: "demostart",
close: "demoend",
render: (tokens, index) => {
// render content here
},
});
mdIt.render(`\
@demostart
Content
Another content
@demoend
`);This plugin will extract content between @openmarker and @closemarker into a single token, then render it with render function.
Tips
The plugin is different from container plugin as contents inside container will be parsed as markdown, but contents inside uml will be parsed as plain text and transform in to a single token.
Escaping
You can use
\to escape@, so the following won't be parsed:\@demostart \@demoend
Options
name
- Type:
string - Required: Yes
- Details: UML name.
open
- Type:
string - Required: Yes
- Details: Opening marker.
close
- Type:
string - Required: Yes
- Details: Closing marker.
render
- Type:
RenderRule - Required: Yes
/**
* @param tokens - List of tokens.
* @param index - Current token index.
* @param options - Markdown-it options.
* @param env - Markdown-it environment.
* @param self - Markdown-it renderer instance.
*
* @returns Rendered HTML string.
*/
type RenderRule = (
tokens: Token[],
index: number,
options: Options,
env: Env,
self: Renderer,
) => string;- Details: Render function.