rubyAnnotation()

支持使用 `{漢字|かんじ}` 语法编写 ruby/注音标记。

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

签名

function rubyAnnotation(): UnifastPlugin

参数

无。

用法

import { compile, rubyAnnotation } from "@unifast/node";

const md = `
{漢字|かんじ}の読み方を学びましょう。
`;

const result = compile(md, { plugins: [rubyAnnotation()] });
// {漢字|かんじ} becomes <ruby>漢字<rp>(</rp><rt>かんじ</rt><rp>)</rp></ruby>

示例

Ruby 注音(振假名)

同一句中多个注音

import { compile, rubyAnnotation } from "@unifast/node";

const md = `
{東京|とうきょう}は{日本|にほん}の{首都|しゅと}です。
`;

const result = compile(md, { plugins: [rubyAnnotation()] });

混合内容

import { compile, rubyAnnotation } from "@unifast/node";

const md = `
# {日本語|にほんご}ガイド

{漢字|かんじ}には**たくさん**の{読|よ}み{方|かた}があります。

- {音読|おんよ}み — Chinese-derived reading
- {訓読|くんよ}み — Native Japanese reading
`;

const result = compile(md, { plugins: [rubyAnnotation()] });