-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfurigana.html
89 lines (74 loc) · 5.02 KB
/
furigana.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{% capture furigana_workspace %}
{% comment %}
MIT License
Copyright (c) 2021 gledos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{% endcomment %}
{% comment %}
Version 0.2.0
https://github.com/gledos/jekyll-furigana
Liquid is really quite complete, simple word processing can basically be achieved,
the main function of this template is Phonetic.
Liquid 真的是相当完备,简单的文字处理基本都可以实现,这个模板主要功能是标音(Phonetic)
Due to the incomplete support of the <rtc> <rb> tag browser, the Zhuyin implemented by
this Liquid template will not include these two tags.
由于 <rtc> <rb> 标签浏览器支持度不全,所以本 Liquid 模板所实现的注音不会包含这两个标签
Usage / 使用方法:
{% include furigana.html text="测试" furigana="test" %}
You can freely modify this template to any name, such as ruby.html etc.
你可以自由的修改本模板为任意名称,比如 ruby.html、yinbiao.html、zhuyin.html 等等
Parameters / 必要参数:
* text (string) : "no_text" - Text in Kana or Chinese characters to be annotated
- 需要用旁注标记标注的文字
* furigana (string) : "no_furigana" - Hiragana, romanization or other transcription; shown above the Base text
- 文字上方的注音
Optional Parameters / 可选参数:
* class (string) : "null" - ruby_null CSS class
"default" - a CSS class to the furigana
"big" - Enlarge the text by 150%. / 将文字放大 150%
"bigger" - Enlarge the text by 200%. / 将文字放大 200%
"large" - Enlarge the text by 250%. / 将文字放大 250%
"larger" - Enlarge the text by 300%. / 将文字放大 300%
* type (string) : "A" - single word single furigana
"B" - more word more furigana
Output:
According to the needs of the display effect, you need to pay attention to the spaces before and after the template
根据显示效果的需求,需要留意模板前后空格
{% endcomment %}
{% assign ruby_text = include.text | default: "no_text" %}
{% assign ruby_furigana = include.furigana | default: "no_furigana" %}
{% assign css_class = include.class | default: "null" %}
{% assign rubt_type = include.type | default: "A" %}
{% assign loop_num = 0 %}
{% capture l_bracket %}<rp>(</rp><rt>{% endcapture %}
{% capture r_bracket %}</rt><rp>)</rp>{% endcapture %}
{% capture jekyll_furigana %}<ruby class=ruby_{{ css_class }}>{% endcapture %}
{% case rubt_type %}
{% when "A" %}
{% capture jekyll_furigana %}{{ jekyll_furigana }}{{ ruby_text }}{{ l_bracket }}{{ ruby_furigana }}{{ r_bracket }}{% endcapture %}
{% capture jekyll_furigana %}{{ jekyll_furigana }}</ruby>{% endcapture %}
{% when "B" %}
{% assign ruby_text_list = ruby_text | split: ',' %}
{% assign ruby_furigana_list = ruby_furigana | split: ',' %}
{% for item in ruby_furigana_list %}
{% capture jekyll_furigana %}{{ jekyll_furigana }}{{ ruby_text_list | slice: loop_num }}{{ l_bracket }}{{ ruby_furigana_list | slice: loop_num }}{{ r_bracket }}{% endcapture %}
{% assign loop_num = loop_num | plus:1 %}
{% endfor}
{% else %}
{% capture jekyll_furigana %}type error{% endcapture %}
{% endcase %}
{% endcapture %}{% assign furigana_workspace = "" %}{{ jekyll_furigana }}