0.3.1 • Published 7 months ago

remark-denden-ruby v0.3.1

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

remark-denden-ruby

remark plugin to support ruby syntax of denden markdown.

Installation

# Of course you can use npm, yarn or other tools.
pnpm add remark-denden-ruby

Usage

ESM only.

import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import remarkRuby from "remark-denden-ruby";

const md2html = (md) => {
  const result = unified()
    .use(remarkParse)
    .use(remarkRuby)
    .use(remarkRehype)
    .use(rehypeStringify)
    .processSync(md);
  return result.toString();
};

const markdown = `
{幻想殺し|イマジンブレイカー}
`;

console.log(md2html(markdown));

The result is:

<!-- formatted HTML -->
<p>
  <ruby>幻想殺し<rp>(</rp><rt>イマジンブレイカー</rt><rp>)</rp></ruby>
</p>

Restrictions

Escaping like \{Info\|Warning\} is not supported due to technical reason. You can use inline code instead.