review 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.rubocop.yml +293 -6
- data/.rubocop_todo.yml +3 -608
- data/.travis.yml +6 -13
- data/README.md +5 -3
- data/Rakefile +6 -6
- data/bin/review-catalog-converter +2 -2
- data/bin/review-check +1 -1
- data/bin/review-compile +1 -2
- data/bin/review-init +6 -3
- data/bin/review-validate +3 -3
- data/bin/review-vol +2 -1
- data/doc/NEWS.ja.md +138 -25
- data/doc/NEWS.md +137 -25
- data/doc/config.yml.sample +2 -2
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +86 -5
- data/doc/format.md +67 -2
- data/doc/makeindex.ja.md +95 -0
- data/doc/makeindex.md +97 -0
- data/doc/sample.css +214 -0
- data/lib/epubmaker.rb +6 -6
- data/lib/epubmaker/epubcommon.rb +19 -47
- data/lib/epubmaker/epubv2.rb +3 -1
- data/lib/epubmaker/epubv3.rb +4 -26
- data/lib/epubmaker/producer.rb +46 -46
- data/lib/epubmaker/zip_exporter.rb +86 -0
- data/lib/review/book/base.rb +13 -15
- data/lib/review/book/chapter.rb +2 -1
- data/lib/review/book/compilable.rb +9 -9
- data/lib/review/book/image_finder.rb +13 -13
- data/lib/review/book/index.rb +2 -2
- data/lib/review/book/volume.rb +2 -2
- data/lib/review/builder.rb +57 -1
- data/lib/review/catalog.rb +2 -2
- data/lib/review/compiler.rb +15 -7
- data/lib/review/configure.rb +11 -0
- data/lib/review/epubmaker.rb +403 -401
- data/lib/review/ewbbuilder.rb +16 -16
- data/lib/review/htmlbuilder.rb +42 -58
- data/lib/review/htmltoc.rb +1 -1
- data/lib/review/htmlutils.rb +50 -4
- data/lib/review/i18n.rb +2 -2
- data/lib/review/idgxmlbuilder.rb +30 -47
- data/lib/review/latexbuilder.rb +86 -41
- data/lib/review/latexutils.rb +19 -19
- data/lib/review/markdownbuilder.rb +16 -4
- data/lib/review/md2inaobuilder.rb +0 -9
- data/lib/review/pdfmaker.rb +91 -48
- data/lib/review/preprocessor.rb +1 -1
- data/lib/review/rstbuilder.rb +763 -0
- data/lib/review/sec_counter.rb +7 -9
- data/lib/review/tocparser.rb +3 -3
- data/lib/review/tocprinter.rb +5 -5
- data/lib/review/topbuilder.rb +48 -56
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +6 -7
- data/review.gemspec +1 -0
- data/templates/latex/layout.tex.erb +27 -2
- data/test/assets/test_template.tex +10 -1
- data/test/book_test_helper.rb +1 -2
- data/test/run_test.rb +10 -0
- data/test/sample-book/src/style.css +215 -0
- data/test/sample-book/src/vendor/jumoline/lppl.txt +416 -0
- data/test/test_book.rb +0 -1
- data/test/test_catalog.rb +1 -0
- data/test/test_converter.rb +1 -1
- data/test/test_epub3maker.rb +44 -51
- data/test/test_epubmaker.rb +82 -38
- data/test/test_epubmaker_cmd.rb +1 -1
- data/test/test_extentions_hash.rb +8 -1
- data/test/test_htmlbuilder.rb +411 -18
- data/test/test_i18n.rb +17 -0
- data/test/test_idgxmlbuilder.rb +88 -3
- data/test/test_image_finder.rb +18 -0
- data/test/test_index.rb +2 -0
- data/test/test_latexbuilder.rb +96 -8
- data/test/test_makerhelper.rb +2 -2
- data/test/test_markdownbuilder.rb +22 -1
- data/test/test_md2inaobuilder.rb +0 -5
- data/test/test_pdfmaker.rb +54 -36
- data/test/test_pdfmaker_cmd.rb +1 -1
- data/test/test_rstbuilder.rb +356 -0
- data/test/test_textutils.rb +14 -4
- data/test/test_topbuilder.rb +23 -4
- data/test/test_zip_exporter.rb +113 -0
- metadata +28 -2
data/doc/config.yml.sample
CHANGED
@@ -172,9 +172,9 @@ secnolevel: 2
|
|
172
172
|
# fontdir内から取り込まれる対象となるファイル拡張子。省略した場合は以下
|
173
173
|
# font_ext: ["ttf", "woff", "otf"]
|
174
174
|
|
175
|
-
# ソースコードハイライトを利用する (pygmentsには外部gemが必要)
|
175
|
+
# ソースコードハイライトを利用する (rouge,pygmentsには外部gemが必要)
|
176
176
|
# highlight:
|
177
|
-
# html: "
|
177
|
+
# html: "rouge"
|
178
178
|
# latex: "listings"
|
179
179
|
|
180
180
|
# カタログファイル名を指定する
|
data/doc/format.ja.md
CHANGED
@@ -221,6 +221,20 @@ puts "hello world!"
|
|
221
221
|
|
222
222
|
他章のリストを参照するには、後述の「章ID」を指定し、たとえば `@<list>{advanced|main}`(`advanced.re` ファイルの章にあるリスト `main` を参照する)と記述します。
|
223
223
|
|
224
|
+
### 行番号の指定
|
225
|
+
|
226
|
+
行番号を指定した番号から始めるには、`//firstlinenum`を使います。
|
227
|
+
|
228
|
+
例:
|
229
|
+
|
230
|
+
```review
|
231
|
+
//firstlinenum[100]
|
232
|
+
//listnum[hello][ハローワールド][ruby]{
|
233
|
+
puts "hello world!"
|
234
|
+
//}
|
235
|
+
```
|
236
|
+
|
237
|
+
|
224
238
|
### ソースコード専用の引用
|
225
239
|
|
226
240
|
ソースコードを引用するには次のように記述します。
|
@@ -366,6 +380,20 @@ DISPLAY X Window Systemのデフォルトディスプレイ
|
|
366
380
|
|
367
381
|
表のセル内でもインライン命令は有効です。
|
368
382
|
|
383
|
+
### 表の列幅
|
384
|
+
|
385
|
+
LaTeX および IDGXML のビルダを利用する場合、表の各列の幅を `//tsize` ブロック命令で指定できます。
|
386
|
+
|
387
|
+
```
|
388
|
+
//tsize[|ビルダ|1列目の幅,2列目の幅,……]
|
389
|
+
```
|
390
|
+
|
391
|
+
* 列の幅は mm 単位で指定します。
|
392
|
+
* IDGXML の場合、3列のうち1列目だけ指定したとすると、省略した残りの2列目・3列目は紙面版面の幅の残りを等分した幅になります。1列目と3列目だけを指定する、といった指定方法はできません。
|
393
|
+
* LaTeX の場合、すべての列について漏れなく幅を指定する必要があります。
|
394
|
+
* LaTeX の場合、「`//tsize[|latex||p{20mm}cr|]`」のように LaTeX の table マクロの列情報パラメータを直接指定することもできます。
|
395
|
+
* その他のビルダ (HTML など) においては、この命令は単に無視されます。
|
396
|
+
|
369
397
|
### 複雑な表
|
370
398
|
|
371
399
|
現時点では表のセルの結合や、中央寄せ・右寄せなどの表現はできません。
|
@@ -589,7 +617,9 @@ Web ハイパーリンクを記述するには、リンクに `@<href>`、アン
|
|
589
617
|
|
590
618
|
## 生データ行
|
591
619
|
|
592
|
-
Re:VIEW のタグ範囲を超えて何か特別な行を挿入したい場合、`//raw`
|
620
|
+
Re:VIEW のタグ範囲を超えて何か特別な行を挿入したい場合、`//raw` ブロック命令や`//embed`ブロック命令、または `@<raw>` インライン命令や `@<embed>` インライン命令を使います。
|
621
|
+
|
622
|
+
### `//raw`行
|
593
623
|
|
594
624
|
例:
|
595
625
|
|
@@ -597,9 +627,9 @@ Re:VIEW のタグ範囲を超えて何か特別な行を挿入したい場合、
|
|
597
627
|
//raw[|html|<div class="special">\nここは特別な行です。\n</div>]
|
598
628
|
```
|
599
629
|
|
600
|
-
ブロック命令は1
|
630
|
+
ブロック命令は1つだけオプションをとり、「|ビルダ名|そのまま出力させる内容」という書式です。`\n`は改行文字に変換されます。
|
601
631
|
|
602
|
-
ビルダ名には「`html`」「`latex`」「`idgxml`」「`top
|
632
|
+
ビルダ名には「`html`」「`latex`」「`idgxml`」「`markdown`」「`top`」のいずれかが入ります。ビルダ名は「,」で区切って複数指定することも可能です。該当のビルダを使用しているときのみ、内容が出力されます。
|
603
633
|
|
604
634
|
例:
|
605
635
|
|
@@ -614,7 +644,55 @@ Re:VIEW のタグ範囲を超えて何か特別な行を挿入したい場合、
|
|
614
644
|
|
615
645
|
インライン命令は、`@<raw>{|ビルダ名|〜}` という書式で、記述はブロック命令に同じです。
|
616
646
|
|
617
|
-
`//
|
647
|
+
### `//embed`ブロック
|
648
|
+
|
649
|
+
例:
|
650
|
+
|
651
|
+
```
|
652
|
+
//embed{
|
653
|
+
<div class="special">
|
654
|
+
ここは特別なブロックとして扱われます。
|
655
|
+
</div>
|
656
|
+
//}
|
657
|
+
|
658
|
+
//embed[html,markdown]{
|
659
|
+
<div class="special">
|
660
|
+
ここはHTMLとMarkdownでは特別なブロックとして扱われます。
|
661
|
+
</div>
|
662
|
+
//}
|
663
|
+
```
|
664
|
+
|
665
|
+
`//embed`ブロック命令はブロック内の文字列をそのまま文書中に埋め込みます。エスケープされる文字はありません。
|
666
|
+
|
667
|
+
オプションとして、ビルダ名を指定できます。ビルダ名には「`html`」「`latex`」「`idgxml`」「`markdown`」「`top`」のいずれかが入ります。ビルダ名は「,」で区切って複数指定することも可能です。該当のビルダを使用しているときのみ、内容が出力されます。異なるビルダを使用している場合は無視されます。
|
668
|
+
|
669
|
+
オプションを省略した場合、すべてのビルダで文字列が埋め込まれます。
|
670
|
+
|
671
|
+
例:
|
672
|
+
|
673
|
+
HTMLビルダを使用している場合:
|
674
|
+
|
675
|
+
```html
|
676
|
+
<div class="special">
|
677
|
+
ここは特別なブロックとして扱われます。
|
678
|
+
</div>
|
679
|
+
|
680
|
+
<div class="special">
|
681
|
+
ここはHTMLとMarkdownでは特別なブロックとして扱われます。
|
682
|
+
</div>
|
683
|
+
```
|
684
|
+
|
685
|
+
LaTeXビルダを使用している場合:
|
686
|
+
|
687
|
+
```tex
|
688
|
+
<div class="special">
|
689
|
+
ここは特別なブロックとして扱われます
|
690
|
+
</div>
|
691
|
+
|
692
|
+
```
|
693
|
+
|
694
|
+
|
695
|
+
`//raw`、`//embed`、`@<raw>` および `@<embed>` は、HTML、XML や TeX の文書構造を容易に壊す可能性があります。使用には十分に注意してください。
|
618
696
|
|
619
697
|
## インライン命令
|
620
698
|
主なインライン命令を次に示します。
|
@@ -653,7 +731,10 @@ Re:VIEW のタグ範囲を超えて何か特別な行を挿入したい場合、
|
|
653
731
|
* `@<href>{URL}`, `@<href>{URL, 文字表現}` : ハイパーリンクを作成します(後述)。
|
654
732
|
* `@<icon>{識別子}` : インラインの画像を出力します。
|
655
733
|
* `@<m>{数式}` : インラインの数式を出力します。
|
656
|
-
* `@<raw>{|ビルダ|〜}` :
|
734
|
+
* `@<raw>{|ビルダ|〜}` : 生の文字列を出力します。`\}`は`}`に、`\\`は`\`に、`\n`は改行に置き換えられます。
|
735
|
+
* `@<embed>{|ビルダ|〜}` : 生の文字列を埋め込みます。`\}`は`}`に、`\\`は`\`に置き換えられます(`\n`はそのままです)。
|
736
|
+
* `@<idx>{文字列}` : 文字列を出力するとともに、索引として登録します。索引の使い方については、makeindex.ja.md を参照してください。
|
737
|
+
* `@<hidx>{文字列}` : 索引として登録します (idx と異なり、紙面内に出力はしません)。`親索引文字列<<>>子索引文字列` のように親子関係にある索引も定義できます。
|
657
738
|
|
658
739
|
## 著者用タグ(プリプロセッサ命令)
|
659
740
|
|
data/doc/format.md
CHANGED
@@ -252,6 +252,20 @@ such as `@<list>{main}`.
|
|
252
252
|
|
253
253
|
When you refer a list in the other chapter, you can use an ID with chapter ID, such like `@<list>{advanced|main}`, to refer a list `main` in `advanced.re`.
|
254
254
|
|
255
|
+
### define line number of first line in code block
|
256
|
+
|
257
|
+
If you want to start with specified number as line number, you can use `firstlinenum` command.
|
258
|
+
|
259
|
+
Usage:
|
260
|
+
|
261
|
+
```review
|
262
|
+
//firstlinenum[100]
|
263
|
+
//listnum[hello][helloworld][ruby]{
|
264
|
+
puts "hello world!"
|
265
|
+
//}
|
266
|
+
```
|
267
|
+
|
268
|
+
|
255
269
|
### Quoting Source Code
|
256
270
|
|
257
271
|
`//source` is for quoting source code. filename is mandatory.
|
@@ -411,6 +425,19 @@ When you want to write "see table X", you can write `@<table>{envvars}`.
|
|
411
425
|
|
412
426
|
You can use inline markup in the tables.
|
413
427
|
|
428
|
+
### Column width of table
|
429
|
+
When using LaTeX or IDGXML builder, you can specify each column width of the table with `//tsize` block command.
|
430
|
+
|
431
|
+
```
|
432
|
+
//tsize[|builder|width-of-column1,width-of-column2,...]
|
433
|
+
```
|
434
|
+
|
435
|
+
* The collumn width is specified in mm.
|
436
|
+
* For IDGXML, if only 1st of the three columns is specified, the remaining 2nd and 3rd columns will be the width of the remainder of the live area width equally divided. It is not possible to specify that only the 1st and 3rd columns are specified.
|
437
|
+
* For LaTeX, you have to specify all column widths.
|
438
|
+
* For LaTeX, you can also directly specify the column parameter of LaTeX table macro like `//tsize[|latex||p{20mm}cr|]`.
|
439
|
+
* In other builders such as HTML, this command is simply ignored.
|
440
|
+
|
414
441
|
### Complex Table
|
415
442
|
|
416
443
|
If you want to use complex tables, you can use `imgtable` block command with an image of the table. `imgtable` supports numbering and `@<table>`.
|
@@ -661,7 +688,9 @@ Usage:
|
|
661
688
|
|
662
689
|
## Raw Data Block
|
663
690
|
|
664
|
-
When you want to write non-Re:VIEW line, use `//raw`.
|
691
|
+
When you want to write non-Re:VIEW line, use `//raw` or `//embed`.
|
692
|
+
|
693
|
+
### `//raw` block
|
665
694
|
|
666
695
|
Usage:
|
667
696
|
|
@@ -688,6 +717,39 @@ this is a special line.
|
|
688
717
|
|
689
718
|
Note: `//raw` and `@<raw>` may break structured document easily.
|
690
719
|
|
720
|
+
### `//embed` block
|
721
|
+
|
722
|
+
Usage:
|
723
|
+
|
724
|
+
```
|
725
|
+
//embed{
|
726
|
+
<div class="special">
|
727
|
+
this is a special line.
|
728
|
+
</div>
|
729
|
+
//}
|
730
|
+
|
731
|
+
//embed[html,markdown]{
|
732
|
+
<div class="special">
|
733
|
+
this is a special line.
|
734
|
+
</div>
|
735
|
+
//}
|
736
|
+
```
|
737
|
+
|
738
|
+
In above line, `html` and `markdown` is a builder name that handle raw data.
|
739
|
+
|
740
|
+
Output:
|
741
|
+
|
742
|
+
(In HTML:)
|
743
|
+
|
744
|
+
```
|
745
|
+
<div class="special">
|
746
|
+
this is a special line.
|
747
|
+
</div>
|
748
|
+
```
|
749
|
+
|
750
|
+
(In other formats, it is just ignored.)
|
751
|
+
|
752
|
+
|
691
753
|
## Inline Commands
|
692
754
|
|
693
755
|
### Styles
|
@@ -730,7 +792,10 @@ Note: `//raw` and `@<raw>` may break structured document easily.
|
|
730
792
|
@<href>{http://www.google.com/, google}:: hyper link(URL)
|
731
793
|
@<icon>{samplephoto}:: inline image
|
732
794
|
@<m>{a + \alpha}:: TeX inline equation
|
733
|
-
@<raw>{|html|<span>ABC</span>}:: inline raw data inline. `\}` is `}
|
795
|
+
@<raw>{|html|<span>ABC</span>}:: inline raw data inline. `\}` is `}`, `\\` is `\`, and `\n` is newline.
|
796
|
+
@<embed>{|html|<span>ABC</span>}:: inline raw data inline. `\}` is `}` and `\\` is `\`.
|
797
|
+
@<idx>{string}:: output a string and register it as an index. See makeindex.md.
|
798
|
+
@<hidx>{string}:: register a string as an index. A leveled index is expressed like `parent<<>>child`
|
734
799
|
```
|
735
800
|
|
736
801
|
## Commands for Authors (pre-processor commands)
|
data/doc/makeindex.ja.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# 索引の使い方
|
2
|
+
インラインタグ `@<idx>` および `@<hidx>` を用いて、索引単語を埋め込むことができます。索引を整列するにはその索引単語の「読み」が必要ですが、LaTeX ビルダにおいては、用意した辞書や形態素解析を使い、読み順に整列して紙面化します。
|
3
|
+
|
4
|
+
## 注意
|
5
|
+
* LaTeX の mendex コマンドの実装に依存しているため、 現時点では英語または日本語以外の挙動は不明です。
|
6
|
+
* 形態素解析は、外部ソフトウェアの MeCab (http://taku910.github.io/mecab/)、その辞書である IPA 辞書、MeCab の Ruby バインドである mecab に依存しています。
|
7
|
+
* LaTeX ビルダ以外のビルダでは、埋め込んだ索引を利用する手法を提供していません。後述のヒントを参照してください。
|
8
|
+
* LaTeX ビルダでの索引生成機能は、デフォルトで無効にしています。設定 YAML ファイルで明示的に有効にする必要があります。
|
9
|
+
|
10
|
+
## MeCab のセットアップ
|
11
|
+
形態素解析による自動読みを使用する場合、MeCab (http://taku910.github.io/mecab/) およびその辞書、Ruby バインドライブラリの mecab をインストールしておく必要があります。
|
12
|
+
|
13
|
+
Debian GNU/Linux あるいは Ubuntu の環境では、次のようにパッケージをインストールします。
|
14
|
+
|
15
|
+
```
|
16
|
+
apt install mecab mecab-ipadic-utf8 ruby-mecab
|
17
|
+
```
|
18
|
+
|
19
|
+
MeCab 標準の辞書としては IPA 辞書と Juman 辞書がありますが、本機能の自動読みのためには「-Oyomi」オプションがサポートされている必要があり、これに対応しているのは IPA 辞書のみです。
|
20
|
+
|
21
|
+
## 設定
|
22
|
+
review-pdfmaker での索引作成を有効にするため、config.yml (別の設定ファイルを使う場合はその YAML ファイル) に、次のように追加します。
|
23
|
+
|
24
|
+
```
|
25
|
+
pdfmaker:
|
26
|
+
makeindex: true
|
27
|
+
```
|
28
|
+
|
29
|
+
re ファイル内に、`@<idx>` または `@<hidx>` インラインタグを使って索引を埋め込みます。`@<idx>` は、指定の文字列をそのまま紙面に出力するとともに索引とします。`@<hidx>` (hidden index) は、指定の文字列を索引とするのみで、紙面には出力しません。`@<hidx>` の場合は文字列内を `<<>>` で区切り、`親索引語<<>>子索引語`、`親索引語<<>>子索引語<<>>孫索引語` とレベル分けした索引を指定できます。
|
30
|
+
|
31
|
+
```
|
32
|
+
@<idx>{表示もする索引}です
|
33
|
+
↓
|
34
|
+
表示もする索引です
|
35
|
+
|
36
|
+
[索引]
|
37
|
+
ひ
|
38
|
+
表示もする索引です....1
|
39
|
+
```
|
40
|
+
|
41
|
+
```
|
42
|
+
@<hidx>{表示しない索引}です@<hidx>{親<<>>子}
|
43
|
+
↓
|
44
|
+
です
|
45
|
+
|
46
|
+
[索引]
|
47
|
+
お
|
48
|
+
親
|
49
|
+
子................1
|
50
|
+
|
51
|
+
|
52
|
+
ひ
|
53
|
+
表示もする索引です....1
|
54
|
+
```
|
55
|
+
|
56
|
+
## 読み辞書
|
57
|
+
形態素解析は万能ではなく、特に短い単語は音読み・訓読みの違いで期待と異なる結果になりやすく、また辞書に載っていない専門的な単語は読みを解釈できずにおかしな結果になります。
|
58
|
+
|
59
|
+
内部で使用している mendex プログラムに与える読み辞書を用意すれば、まずその辞書でのマッチングを試み、マッチングしなかったときに形態素解析を試みる、という手順をとることができます。また、MeCab を利用できない環境でも、すべての索引単語を解決できる読み辞書を用意すれば、索引機能を利用できます。
|
60
|
+
|
61
|
+
辞書は次のように熟語と読みのペアをタブまたはスペースで区切ったテキストファイルとして作成します。
|
62
|
+
|
63
|
+
```
|
64
|
+
漢字 かんじ
|
65
|
+
読み よみ
|
66
|
+
α あるふぁ
|
67
|
+
```
|
68
|
+
|
69
|
+
このファイルを config.yml 設定ファイルで指定します (以下では my.dic を指定)。
|
70
|
+
|
71
|
+
```
|
72
|
+
pdfmaker:
|
73
|
+
makeindex: true
|
74
|
+
makeindex_dic: my.dic
|
75
|
+
```
|
76
|
+
|
77
|
+
なお、mendex のアルゴリズム上、辞書や形態素解析の適用は常にうまくいくとは限りません。たとえば「表 (ひょう、おもて)」のように 2 通りの読み方があるような語を使い分けたいというときには、review-pdfmaker のフック機能を使い、LaTeX のソースファイルに変換したところで LaTeX の索引命令に読みを明示する (たとえば `\index{おもて@表}`) といった対処が必要になるでしょう。LaTeX の索引命令の詳細については、mendex コマンドのオンラインマニュアルを参照してください。
|
78
|
+
|
79
|
+
## カスタマイズ
|
80
|
+
`pdfmaker:` 以下に記述可能な YAML 設定を以下にまとめます。
|
81
|
+
|
82
|
+
* `makeindex`: `true` で索引を作成 (デフォルト: `null`=作成しない)
|
83
|
+
* `makeindex_command`: 索引作成の支援コマンド (デフォルト: `mendex`)
|
84
|
+
* `makeindex_options`: 支援コマンドのオプション (デフォルト: `-f -r -I utf8`)
|
85
|
+
* `makeindex_sty`: 支援コマンドで使うスタイルファイル (デフォルト: `null`)
|
86
|
+
* `makeindex_dic`: 支援コマンドで使う読み辞書ファイル (デフォルト: `null`)
|
87
|
+
* `makeindex_mecab`: MeCab による形態素解析を試みる (デフォルト: `true`=使用する)
|
88
|
+
* `makeindex_mecab_opts`: MeCab で読みを取得するオプション (デフォルト: `-Oyomi`)
|
89
|
+
|
90
|
+
たとえば索引ページの見た目の表現は mendex コマンドのデフォルトのものが使われますが、設定をファイルで用意し、`makeindex_sty` にそのファイルを指定すれば変更できます。設定については mendex コマンドのオンラインマニュアルを参照してください。
|
91
|
+
|
92
|
+
## ヒント
|
93
|
+
「注意」で述べたとおり、LaTeX ビルダ以外のビルダでそれを活用する方法は提供していません。というのも、ほかのビルダでは、索引を読み順に並べ替えたり、それを表現したりといった方法についての一般的な解が存在しないからです。
|
94
|
+
|
95
|
+
EPUB (HTML ビルダ) では `<!-- IDX:索引文字列 -->` のコメントで、IDGXML ビルダでは `<index value="索引文字列">` の XML 要素で、それぞれ索引は埋め込まれます。たとえばこれらを拾い出して、独自の辞書読み・整列ツール (LaTeX の mendex コマンドを流用するなど) を用意する方法が考えられるでしょう。
|
data/doc/makeindex.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# How to use index
|
2
|
+
You can embed an index with using inline tags `@<idx>` and `@<hidx>`. In order to sort the index containing Kanji, "syllabary" of the Kanji is necessary. LaTeX builder can sort and layout them using a dictionary or morphological analysis.
|
3
|
+
|
4
|
+
## Notice
|
5
|
+
* Since it depends on mendex of LaTeX, it may work only in English or Japanese at present.
|
6
|
+
* Morphological analysis relies on external software MeCab (http://taku910.github.io/mecab/), IPA dictionary, and mecab Ruby binding.
|
7
|
+
* Other builders don't provide a method to use indexes. (see the hint.)
|
8
|
+
* The index generation is disabled by default. You have to explicitly enable in the onfiguration YAML file.
|
9
|
+
|
10
|
+
## Setting up MeCab
|
11
|
+
When using morphological analytics, it is necessary to install MeCab (http://taku910.github.io/mecab/), its dictionary, and mecab of Ruby binding library.
|
12
|
+
|
13
|
+
On Debian GNU/Linux or Ubuntu:
|
14
|
+
|
15
|
+
```
|
16
|
+
apt install mecab mecab-ipadic-utf8 ruby-mecab
|
17
|
+
```
|
18
|
+
|
19
|
+
There are 2 standard dictionaries for MeCab, "IPA" and "Juman", but use "IPA". Because only IPA supports "-Oyomi" option.
|
20
|
+
|
21
|
+
## Configuration
|
22
|
+
To enable index generation in review-pdfmaker, add a configuration to config.yml.
|
23
|
+
|
24
|
+
```
|
25
|
+
pdfmaker:
|
26
|
+
makeindex: true
|
27
|
+
```
|
28
|
+
|
29
|
+
Embed the indexes in Re:VIEW re files using inline tags `@<idx>` or `@<hidx>`.
|
30
|
+
`@<idx>` outputs the word and sets it as an index. `@<hidx>` (hidden index) only indexes the word (no output). By separating strings with `<<>>` in `@<hidx>`, like `parentindex<<>>childindex` or `parentindex<<>>childindex<<>>grandchildindex`, you can define a leveled index.
|
31
|
+
|
32
|
+
```
|
33
|
+
I @<idx>{display} it.
|
34
|
+
↓
|
35
|
+
I display it.
|
36
|
+
|
37
|
+
[Index]
|
38
|
+
D
|
39
|
+
display....1
|
40
|
+
```
|
41
|
+
|
42
|
+
```
|
43
|
+
I @<hidx>{display} it.@<hidx>{Country<<>>Japan}
|
44
|
+
↓
|
45
|
+
I it.
|
46
|
+
|
47
|
+
[Index]
|
48
|
+
C
|
49
|
+
Country
|
50
|
+
Japan....1
|
51
|
+
|
52
|
+
|
53
|
+
D
|
54
|
+
display....1
|
55
|
+
```
|
56
|
+
|
57
|
+
## Dictionary for Kanji
|
58
|
+
Morphological analysis is not a silver bullet. It frequently misreads.
|
59
|
+
By providing a dictionary, mendex program will try to match the word with priority. Also even in environments where MeCab can't be used, you can use the index generation by using a dictionary to resolve Kanji words.
|
60
|
+
|
61
|
+
Dictionary file is a text file in which Kanji and Kana pairs are separated by tabs or spaces.
|
62
|
+
|
63
|
+
```
|
64
|
+
漢字 かんじ
|
65
|
+
読み よみ
|
66
|
+
α あるふぁ
|
67
|
+
```
|
68
|
+
|
69
|
+
Specify the above file (e.g. my.dic) in config.yml.
|
70
|
+
|
71
|
+
```
|
72
|
+
pdfmaker:
|
73
|
+
makeindex: true
|
74
|
+
makeindex_dic: my.dic
|
75
|
+
```
|
76
|
+
|
77
|
+
Due to mendex's algorithm, automatic Kanji sorting will not always succeed.
|
78
|
+
In complicated case, you will need to modify a LaTeX source using review-pdfmaker's hook feature. See online manual of mendex for details.
|
79
|
+
|
80
|
+
## Customize
|
81
|
+
The following is an index setting that can be described under `pdfmaker:` in config.yml.
|
82
|
+
|
83
|
+
* `makeindex`: if `true`, generate index page (default: `null` = don't generate)
|
84
|
+
* `makeindex_command`: command path of the index tool (default: `mendex`)
|
85
|
+
* `makeindex_options`: options of the index tool (default: `-f -r -I utf8`)
|
86
|
+
* `makeindex_sty`: style file path of the index tool (default: `null`)
|
87
|
+
* `makeindex_dic`: dictionary file path of the index tool (default: `null`)
|
88
|
+
* `makeindex_mecab`: use MeCab (default: `true` = yes, I use)
|
89
|
+
* `makeindex_mecab_opts`: options of MeCab (default: `-Oyomi`)
|
90
|
+
|
91
|
+
For example, if you want to change the appearance of the index page, specify the style file to `makeindex_sty`. See online manual of mendex for details.
|
92
|
+
|
93
|
+
## Hint
|
94
|
+
The builders other than LaTeX builder don't provide a method to use indexes. Because the targets of other builders don't have a general way of sorting or outputting indexes.
|
95
|
+
|
96
|
+
In EPUB (HTML builder), the index is embeded as `<!-- IDX:indexword -->` comment. In IDGXML builder, it is embeded as `<index value="indexword">` XML element.
|
97
|
+
You can probably pick up them and prepare your own tool to sort (by using LaTeX mendex command, e.g.) and output.
|