├── .gitignore
├── LICENSE
├── README.md
├── index.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 潘家邦
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # hexo-ruby-character #
2 |
3 | [](https://npmjs.org/package/hexo-ruby-character)
4 | [](https://npmjs.org/package/hexo-ruby-character)
5 | [](https://npmjs.org/package/hexo-ruby-character)
6 | [](https://npmjs.org/package/hexo-ruby-character)
7 |
8 | Ruby character tag for Hexo, inspired by the [Ruby template](http://zh.moegirl.org/Template:Ruby) of [萌娘百科](http://zh.moegirl.org).
9 |
10 | ## Install ##
11 |
12 | ```
13 | npm install hexo-ruby-character --save
14 | ```
15 |
16 | ## Usage ##
17 |
18 | `{% ruby Base|top %}` → Base
19 |
20 | Specifically, if the top field is in Chinese characters, it while be converted to Chinese pinyin, because the pinyin chatater with heads are not easy to type.
21 |
22 | Followings are the examples.
23 |
24 | `{% ruby 佐天泪子|掀裙狂魔 %}` → 佐天泪子
25 |
26 | Other languages like Japanese is also supported.
27 |
28 | `{% ruby 超電磁砲|レールガン %}` → 超電磁砲
29 |
30 | ## Known issues ##
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var pinyin = require("pinyin");
2 |
3 | hexo.extend.tag.register('ruby', function(args) {
4 |
5 | var splited = args.join(' ').split('|');
6 |
7 | var origin = splited[0].trim();
8 |
9 | var ruby = origin;
10 | if (splited.length > 1) {
11 | ruby = splited[1].trim();
12 | }
13 |
14 | var pinyinic_ruby = [].concat.apply([],pinyin(ruby, {
15 | segment: true
16 | }));
17 |
18 | var ruby_result = "" + origin + ""
19 |
20 | return ruby_result;
21 | });
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hexo-ruby-character",
3 | "version": "1.0.6",
4 | "description": "Ruby charater tag for Hexo",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/JamesPan/hexo-ruby-character.git"
12 | },
13 | "keywords": [
14 | "hexo",
15 | "ruby-charater"
16 | ],
17 | "author": "Pan Jiabang",
18 | "license": "MIT",
19 | "bugs": {
20 | "url": "https://github.com/JamesPan/hexo-ruby-character/issues"
21 | },
22 | "homepage": "https://github.com/JamesPan/hexo-ruby-character",
23 | "dependencies": {
24 | "pinyin": "~2.6.2"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------