Skip to content

remark plugin to support custom ruby syntax in markdown

License

Notifications You must be signed in to change notification settings

haxibami/remark-jaruby

Repository files navigation

remark-jaruby

Node.js CI Node.js Package codecov GitHub license

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.

About

remark plugin to support custom ruby syntax in markdown

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •