suizokukan
suizokukan

Reputation: 1379

ruby tags for Sphinx/rst

I create HTML documents from a rst-formated text, with the help of Sphinx. I need to display some Japanese words with furiganas (=small characters above the words), something like that : Japanese text with furiganas over some words

I'd like to produce HTML displaying furiganas thanks to the < ruby > tag.

I can't figure out how to get this result. I tried to:

Any idea to help me ?

Upvotes: 3

Views: 195

Answers (3)

G. Milde
G. Milde

Reputation: 929

For raw HTML in inline context, you can generate a custom role based on the "raw" role:

.. role:: HTML(raw)
   :format: html

and use it like

你\ :HTML:`<ruby>好<rt>hǎo</rt></ruby>`\ 呀!

The backslash-escaped spaces are required so that the inline markup is recognized. (Alternatively, set the character-level-inline-markup configuration setting to True.)

Upvotes: 0

Sherman
Sherman

Reputation: 21

Put the whole line, i.e., all characters including the untaged ones in the .. raw:: html directive might solve the problem. Here is an example:

.. raw:: html

    你<ruby>好<rt>hǎo</rt></ruby>呀!

Generated

Upvotes: 0

suizokukan
suizokukan

Reputation: 1379

As long as I know, there's no simple way to get the expected result.

For a specific project, I choosed not to generate the furiganas with the help of Sphinx but to modify the .html files afterwards. See the add_ons/add_furiganas.py script and the result here. Yes, it's a quick-and-dirty trick :(

Upvotes: 1

Related Questions