All Projects → laysent → remark-ruby

laysent / remark-ruby

Licence: MIT license
Custom syntax for remarkjs, adding ruby (furigana) to markdown.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to remark-ruby

gatsby-remark-images-grid
Use css grid layouts in markdown
Stars: ✭ 22 (+15.79%)
Mutual labels:  remarkjs, remark-plugin
remark-hint
Sprinkle hints/tips/warnings on your documents
Stars: ✭ 36 (+89.47%)
Mutual labels:  remarkjs, remark-plugin
twoslash
You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
Stars: ✭ 596 (+3036.84%)
Mutual labels:  remark-plugin
android-lecture
android lecture notes
Stars: ✭ 25 (+31.58%)
Mutual labels:  remarkjs
remark-license
plugin to generate a license section
Stars: ✭ 15 (-21.05%)
Mutual labels:  remark-plugin
remark-man
plugin to compile markdown to man pages
Stars: ✭ 87 (+357.89%)
Mutual labels:  remark-plugin
transformer-oembed
@remark-embedder transformer for oEmbed supported links
Stars: ✭ 25 (+31.58%)
Mutual labels:  remark-plugin
RemarkPortable
Remark made simple and portable
Stars: ✭ 24 (+26.32%)
Mutual labels:  remarkjs
cicero
🎤 Serving presentation slides written in Markdown.
Stars: ✭ 50 (+163.16%)
Mutual labels:  remarkjs
Mecab Ipadic Neologd
Neologism dictionary based on the language resources on the Web for mecab-ipadic
Stars: ✭ 2,408 (+12573.68%)
Mutual labels:  furigana
RubyTextMeshPro
Unity Text Mesh Proでルビ(フリガナ)のタグを追加しました.
Stars: ✭ 61 (+221.05%)
Mutual labels:  furigana
remark-highlight.js
Legacy plugin to highlight code blocks with highlight.js — please use `rehype-highlight` instead
Stars: ✭ 58 (+205.26%)
Mutual labels:  remark-plugin
xaringan slides
📺 Links to HTML5 presentations made using the R package {xaringan}.
Stars: ✭ 20 (+5.26%)
Mutual labels:  remarkjs
remark-directive
remark plugin to support directives
Stars: ✭ 137 (+621.05%)
Mutual labels:  remark-plugin
cache
A cache for @remark-embedder
Stars: ✭ 12 (-36.84%)
Mutual labels:  remark-plugin
remark-footnotes
Legacy plugin to add support for pandoc footnotes — please use `remark-gfm` instead
Stars: ✭ 38 (+100%)
Mutual labels:  remark-plugin
gatsby-remark-relative-images
Convert markdown image src(s) to be relative for gatsby-remark-images.
Stars: ✭ 79 (+315.79%)
Mutual labels:  remark-plugin
remark-bookmarks
plugin to manage links
Stars: ✭ 15 (-21.05%)
Mutual labels:  remark-plugin
remark-jsx
A simple way to use React inside Markdown.
Stars: ✭ 29 (+52.63%)
Mutual labels:  remarkjs
remark-it
markdown -> slideshow ——Write PPT like a programmer
Stars: ✭ 125 (+557.89%)
Mutual labels:  remarkjs

remark-ruby

This remark plugin parses custom Markdown syntax to produce (HTML) ruby.

It introduces a new MDAST node type: "ruby".

interface ruby <: Node {
  type: "ruby";
  base: string;
  text: string;
  data: {
    hName: "ruby";
    hChildren: [
      {
        type: 'text',
        value: string,
      },
      {
        type: 'element',
        children: [
          { type: 'text', value: string }
        ],
        tagName: 'rp',
      },
      {
        type: 'element',
        children: [
          { type: 'text', value: string }
        ],
        tagName: 'rt',
      },
      {
        type: 'element',
        children: [
          { type: 'text', value: string },
        ],
        tagName: 'rp',
      }
    ],
  },
}

Syntax

Ruby is defined in the following way:

This plugin works on {Markdown AST}^(MDAST).

This would compile to the following HTML:

<p>This plugin works on <ruby>Markdown AST<rp>(</rp><rt>MDAST</rt><rp>)</rp></p>

Text Delimitation

You could also use [] to delimit text:

{[][士]}^([へん][たい])

This would compile to the following HTML:

<p><ruby><rb></rb><rb></rb><rp>(</rp><rt>へん</rt><rt>たい</rt><rp>)</rp></ruby></p>

Notice that this requires the usage of rb tag, which is not supported by most of the browsers except Firefox. Check caniuse for details.

Installation

npm:

npm install remark-ruby

Usage

Dependencies:

const unified = require('unified')
const remarkParse = require('remark-parse')
const remarkRuby = require('remark-ruby')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')

Usage:

unified()
  .use(remarkParse)
  .use(remarkRuby)
  .use(remark2rehype)
  .use(stringify)

Options

options.parenthesis

Ruby fallback parenthesis which will be used in rp tag. It should be a string with at most two characters. The first will be used as left parenthesis, the last will be used as right parenthesis.

By default, it's value is ().

example

.use(remarkAbbr, { parenthesis: '「」' })

given

This plugin works on {Markdown AST}^(MDAST).

produces

<p>This plugin works on <ruby>Markdown AST<rp></rp><rt>MDAST</rt><rp></rp></p>

License

MIT © LaySent

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].