definitionList()
Поддерживает синтаксис списков определений с парами `термин` и `: описание`.
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>