KanaText class extends the functionality of Text class.
Project description
extends the functionality of the Text class. any person, who use index/glossary directives with Japanse Kanji, is to be so happy.
conf.py
First of all, add sphinxcontrib-kana_text to sphinx extension list in conf.py
extensions = ['sphinxcontrib.kana_text']
#html_kana_text_on_genindex = False
#html_kana_text_use_own_indexer = 'large'
rst file
then use index directive, glossary directive, index role and kana role.
You can specify the follwings:
.. index:: ようご|用語^21
.. glossary::
ようごいち|用語壱^212
用語1の説明。
And you can also use index/kana role.
build
finally, build your sphinx project:
$ make kana
take a look at genindex.html.
genindex.html
{# genindex.html #}
{%- extends "layout.html" %}
{% set title = _('Index') %}
{% macro kana_entry(kname) %}
{%- if kname is string -%}
{{ kname|e }}
{%- else %}
{%- for isruby, val in kname -%}
{%- if isruby -%}
<ruby><rb>{{ val[0]|e }}</rb><rp>(</rp>
<rt>{{ val[1]|e }}</rt><rp>)<rp>
</ruby>
{%- else %}
{{ val|e }}
{%- endif %}
{%- endfor %}
{%- endif %}
{% endmacro %}
{% macro indexentries(firstname, links) %}
{%- if links -%}
<a href="{{ links[0][1] }}">
{%- if links[0][0] %}<strong>{% endif -%}
{{ kana_entry(firstname) }}
{%- if links[0][0] %}</strong>{% endif -%}
</a>
{%- for ismain, link in links[1:] -%}
, <a href="{{ link }}">{% if ismain %}<strong>{% endif -%}
[{{ loop.index }}]
{%- if ismain %}</strong>{% endif -%}
</a>
{%- endfor %}
{%- else %}
{{ kana_entry(firstname) }}
{%- endif %}
{% endmacro %}
{% block body %}
<h1 id="index">{{ _('Index') }}</h1>
<div class="genindex-jumpbox">
{% for key, dummy in genindexentries -%}
<a href="#{{ key }}"><strong>{{ key }}</strong></a>
{% if not loop.last %}| {% endif %}
{%- endfor %}
</div>
{%- for key, entries in genindexentries %}
<h2 id="{{ key }}">{{ key }}</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
{%- for column in entries|slice_index(2) if column %}
<td style="width: 33%; vertical-align: top;"><ul>
{%- for entryname, (links, subitems, _) in column %}
<li>{{ indexentries(entryname, links) }}
{%- if subitems %}
<ul>
{%- for subentryname, subentrylinks in subitems %}
<li>{{ indexentries(subentryname, subentrylinks) }}</li>
{%- endfor %}
</ul>
{%- endif -%}</li>
{%- endfor %}
</ul></td>
{%- endfor %}
</tr></table>
{% endfor %}
{% endblock %}
{% block sidebarrel %}
{% if split_index %}
<h4>{{ _('Index') }}</h4>
<p>{% for key, dummy in genindexentries -%}
<a href="{{ pathto('genindex-' + key) }}"><strong>{{ key }}</strong></a>
{% if not loop.last %}| {% endif %}
{%- endfor %}</p>
<p><a href="{{ pathto('genindex-all') }}"><strong>{{ _('Full index on one page') }}</strong></a></p>
{% endif %}
{{ super() }}
{% endblock %}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file sphinxcontrib.kana_text-0.17.5.tar.gz
.
File metadata
- Download URL: sphinxcontrib.kana_text-0.17.5.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad7eb6ef2c4e5e1575ecc3a8f7cd4668c9c0dd6a96884667fbe8b8b251accc6f |
|
MD5 | 20479fa8e2cbc64b4b81decc3b1907f5 |
|
BLAKE2b-256 | 714b5d1f510fd71a0b7ae218a488b59494aaa4975e98fb440ae6ed1bdf8a0cf2 |