@myxotod/eleventy-plugin-furigana
v1.0.0
Published
An eleventy plugin to display furigana on top of japanese kanji
Maintainers
Readme
eleventy-plugin-furigana
Eleventy plugin that adds a filter to parse content for kanji followed by []-brackets containing hiragana and converts it to furigana.
{{ '私[わたし]の名前[なまえ]はマックスです。' | furigana | safe }}
will produce this:
Usage
Install this package
npm install --save-dev @myxotod/eleventy-plugin-furiganaAdd and register the plugin inside your .eleventy.js config file
// .eleventy.js
const furigana = require("@myxotod/eleventy-plugin-furigana");
module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(furigana);
};Finally use it in your code with the furigana-filter
{{ content | furigana | safe }}Example
{{ '<p>私[わたし]<p>' | furigana | safe }}
<!-- will become -->
<p><ruby>私 <rp>(</rp><rt>わたし</rt><rp>)</rp></ruby></p>Options
You can pass several options when adding the plugin in your eleventy config file like so:
eleventyConfig.addPlugin(furigana, {
verbose: false
});|Option|Default|Type|Description|
|---|---|---|---|
|class|furigana|String|Provide a custom class for the surrounding <ruby> tag|
|regex|/([\u4E00-\u9FAF\u3040-\u3096\u30A1-\u30FA\uFF66-\uFF9D\u31F0-\u31FF]{1})\[(.*?)\]/g|Regex Pattern|Pattern to parse kanji|
|verbose|false|Boolean|Output additional data to your terminal when an eleventy build happens|
