Ruby annotations (
<ruby>
) tag plugin for markdown-it markdown parser.
{ruby base|ruby text}
=> <ruby>ruby base<rt>ruby text</rt></ruby>
Markup is based on DenDenMarkdown definition.
npm install markdown-it-ruby --save
import MarkdownIt from 'markdown-it';
import rubyPlugin from 'markdown-it-ruby';
const md = new MarkdownIt().use(rubyPlugin);
md.render('{ruby base|ruby text}'); // => '<p><ruby>ruby base<rt>ruby text</rt></ruby></p>'
const MarkdownIt = require('markdown-it');
const rubyPlugin = require('markdown-it-ruby');
const md = new MarkdownIt().use(rubyPlugin);
md.render('{ruby base|ruby text}'); // => '<p><ruby>ruby base<rt>ruby text</rt></ruby></p>'
You can pass options to the plugin:
const md = new MarkdownIt().use(rubyPlugin, {
rp: ['(', ')'] // Add parentheses around ruby text
});
// Output: <ruby>漢字<rp>(</rp><rt>かんじ</rt><rp>)</rp></ruby>
md.render('{漢字|かんじ}');
Option | Type | Default | Description |
---|---|---|---|
rp |
[string, string] |
['', ''] |
Array of opening and closing parentheses to wrap around ruby text. When both values are empty strings, no rp elements will be output. |