remark-jaruby
v0.1.1
Published
remark plugin to support Japanese ruby
Downloads
49
Maintainers
Readme
remark-jaruby
remark plugin to support custom ruby syntax in markdown.
Feature
- compatible with latest unified ecosystem
- fully typed
- ESM only
Syntax
As per specification in remark-ruby
Define ruby:
{聖剣}^(エクスカリバー)
Compiled to:
<p>
<ruby>聖剣<rp>(</rp><rt>エクスカリバー</rt><rp>)</rp></ruby>
</p>
See note: support for text delimitation ( equals to <rb>
tag) is omitted.
Usage
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import remarkJaruby from "remark-jaruby";
const MdToHtml = (md) => {
const result = unified()
.use(remarkParse)
.use(remarkJaruby)
.use(remarkRehype)
.use(rehypeStringify)
.processSync(md);
return result.toString();
};
const markdown = `
{聖剣}^(エクスカリバー)
`;
console.log(MdToHtml(markdown));
generates...
<p>
<ruby>聖剣<rp>(</rp><rt>エクスカリバー</rt><rp>)</rp></ruby>
</p>
Dependency
Uses micromark-extension-jaruby and mdast-util-jaruby internally.
Note
- This package is almost a refactoring of remark-ruby. Original package is licensed under MIT License.
- Support for text delimitation &
<rb>
tag in original package was omitted, since only few browsers can display it.