definitionList()
支援定義列表語法:以 `term` 與 `: description` 配對表示。
import { definitionList } from "@unifast/node";函式簽名
function definitionList(): UnifastPlugin參數
無。
用法
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()] });上面的 Markdown 會產生下列 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>範例
定義列表
同一術語對應多個描述
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()] });輸出:
<dl>
<dt>unifast</dt>
<dd>A fast Markdown/MDX compiler.</dd>
<dd>Built with Rust for maximum performance.</dd>
</dl>多個術語與描述
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()] });輸出:
<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>