definitionList()
Support definition list syntax with `term` and `: description` pairs.
import { definitionList } from "@unifast/node";Signature
function definitionList(): UnifastPluginParameters
None.
Usage
import { compile, definitionList } from "@unifast/node";
const md = `
Markdown
: A lightweight markup language for creating formatted text.
HTML
: The standard markup language for documents designed to be displayed in a web browser.
`;
const result = compile(md, { plugins: [definitionList()] });The above Markdown produces the following HTML:
<dl>
<dt>Markdown</dt>
<dd>A lightweight markup language for creating formatted text.</dd>
<dt>HTML</dt>
<dd>The standard markup language for documents designed to be displayed in a web browser.</dd>
</dl>Examples
Definition list
Multiple descriptions per term
import { compile, definitionList } from "@unifast/node";
const md = `
unifast
: A fast Markdown/MDX compiler.
: Built with Rust for maximum performance.
`;
const result = compile(md, { plugins: [definitionList()] });Output:
<dl>
<dt>unifast</dt>
<dd>A fast Markdown/MDX compiler.</dd>
<dd>Built with Rust for maximum performance.</dd>
</dl>Multiple terms and descriptions
import { compile, definitionList } from "@unifast/node";
const md = `
Plugin
Extension
: A module that adds functionality to the core system.
Transformer
: A function that modifies the AST during compilation.
`;
const result = compile(md, { plugins: [definitionList()] });Output:
<dl>
<dt>Plugin</dt>
<dt>Extension</dt>
<dd>A module that adds functionality to the core system.</dd>
<dt>Transformer</dt>
<dd>A function that modifies the AST during compilation.</dd>
</dl>