definitionList()

Hỗ trợ cú pháp danh sách định nghĩa với các cặp `term` và `: description`.

import { definitionList } from "@unifast/node";

Chữ ký

function definitionList(): UnifastPlugin

Tham số

Không có.

Cách dùng

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 ở trên sinh ra HTML như sau:

<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>

Ví dụ

Danh sách định nghĩa

Nhiều mô tả cho một thuật ngữ

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()] });

Đầu ra:

<dl>
  <dt>unifast</dt>
  <dd>A fast Markdown/MDX compiler.</dd>
  <dd>Built with Rust for maximum performance.</dd>
</dl>

Nhiều thuật ngữ và mô tả

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()] });

Đầu ra:

<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>