DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:ruby

This is an old revision of the document!


Ruby Plugin

Compatible with DokuWiki

Greebo, 2018-04-22

plugin Add ruby (normally used to display Japanese Kana on Chinese characters to describe how to read the Chinese characters. This plugin is mainly for Japanese surroundings)

Last updated on
2018-04-30
Provides
Syntax

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to xhtmlruby

Tagged with furigana, japanese, ruby

:!: このプラグインに関して、日本語版ページがございます。(This page is also available in Japanese)

Summary

You can add ruby to your text by using this plugin.
“Ruby” is shown on specified characters. Ruby is mainly used to display Japanese Kana on Chinese characters and describe how to read the Chinese characters.

This plugin is mainly for Japanese surroundings, because other languages may not need “ruby.”

:!:I'm a beginner of PHP programming, so I referred to anchor plugin when creating my plugin.
:!:I’m not a native English speaker, so this page may contain some mistakes in English sentences.

Installation

Go to the directory <your dokuwiki root directory>/lib/plugins/ , and make ruby directory here, then add the following syntax.php in it.

syntax.php
<?php
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
class syntax_plugin_ruby extends DokuWiki_Syntax_Plugin {
 
    function getType(){
        return 'substition';
    }
 
    function getSort(){
        return 150;
    }
 
function getInfo() {return array('author' => 'Hokkaidoperson', 'name' => 'Ruby Plugin', 'desc' => 'Add ruby (normally used to display Japanese Kana on Chinese characters to describe how to read the Chinese characters.  This plugin is mainly for Japanese surroundings)', 'url' => 'http://dokuwiki.org/plugin:ruby');}
 
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern('\{\{ruby:[^}]*\}\}',$mode,'plugin_ruby');
    }
 
   function handle($match, $state, $pos, &$handler){
        return explode(':', substr($match, strlen('{{ruby:'), -2));
    }
 
    function render($mode, &$renderer, $data) {
        $renderer->doc .= '<ruby><rb>' .htmlspecialchars($data[0]) . '</rb><rp>(</rp><rt>' .htmlspecialchars($data[1]) . '</rt><rp>)</rp></ruby>';
    }
}
 
?>

Examples / Usage

For example, if you enter:

{{ruby:車:くるま}}

the you'll see small text “くるま” on the text “車” (“車” stands for “car(s)” in Japanese, and is read “kuruma (くるま)”).
But some devices doesn't support the ruby syntax. In such devices it'll be shown like “車(くるま)”

You can see this plugin working on a page in my wiki (sorry but this page is available only in Japanese).

Syntax

{{ruby:characters:another characters on it}}
  • characters: In many cases, you enter the Chinese characters
  • another characters on it: In many cases, you enter how to read this Chinese characters

Configuration and Settings

None

Change Log

  • 2018-04-30
    • Published

Known Bugs and Issues

No issues now

Discussion

plugin/ruby.1525084754.txt.gz · Last modified: 2018-04-30 12:39 by hokkaidoperson

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki