review 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +293 -6
  4. data/.rubocop_todo.yml +3 -608
  5. data/.travis.yml +6 -13
  6. data/README.md +5 -3
  7. data/Rakefile +6 -6
  8. data/bin/review-catalog-converter +2 -2
  9. data/bin/review-check +1 -1
  10. data/bin/review-compile +1 -2
  11. data/bin/review-init +6 -3
  12. data/bin/review-validate +3 -3
  13. data/bin/review-vol +2 -1
  14. data/doc/NEWS.ja.md +138 -25
  15. data/doc/NEWS.md +137 -25
  16. data/doc/config.yml.sample +2 -2
  17. data/doc/config.yml.sample-simple +1 -1
  18. data/doc/format.ja.md +86 -5
  19. data/doc/format.md +67 -2
  20. data/doc/makeindex.ja.md +95 -0
  21. data/doc/makeindex.md +97 -0
  22. data/doc/sample.css +214 -0
  23. data/lib/epubmaker.rb +6 -6
  24. data/lib/epubmaker/epubcommon.rb +19 -47
  25. data/lib/epubmaker/epubv2.rb +3 -1
  26. data/lib/epubmaker/epubv3.rb +4 -26
  27. data/lib/epubmaker/producer.rb +46 -46
  28. data/lib/epubmaker/zip_exporter.rb +86 -0
  29. data/lib/review/book/base.rb +13 -15
  30. data/lib/review/book/chapter.rb +2 -1
  31. data/lib/review/book/compilable.rb +9 -9
  32. data/lib/review/book/image_finder.rb +13 -13
  33. data/lib/review/book/index.rb +2 -2
  34. data/lib/review/book/volume.rb +2 -2
  35. data/lib/review/builder.rb +57 -1
  36. data/lib/review/catalog.rb +2 -2
  37. data/lib/review/compiler.rb +15 -7
  38. data/lib/review/configure.rb +11 -0
  39. data/lib/review/epubmaker.rb +403 -401
  40. data/lib/review/ewbbuilder.rb +16 -16
  41. data/lib/review/htmlbuilder.rb +42 -58
  42. data/lib/review/htmltoc.rb +1 -1
  43. data/lib/review/htmlutils.rb +50 -4
  44. data/lib/review/i18n.rb +2 -2
  45. data/lib/review/idgxmlbuilder.rb +30 -47
  46. data/lib/review/latexbuilder.rb +86 -41
  47. data/lib/review/latexutils.rb +19 -19
  48. data/lib/review/markdownbuilder.rb +16 -4
  49. data/lib/review/md2inaobuilder.rb +0 -9
  50. data/lib/review/pdfmaker.rb +91 -48
  51. data/lib/review/preprocessor.rb +1 -1
  52. data/lib/review/rstbuilder.rb +763 -0
  53. data/lib/review/sec_counter.rb +7 -9
  54. data/lib/review/tocparser.rb +3 -3
  55. data/lib/review/tocprinter.rb +5 -5
  56. data/lib/review/topbuilder.rb +48 -56
  57. data/lib/review/version.rb +1 -1
  58. data/lib/review/webmaker.rb +6 -7
  59. data/review.gemspec +1 -0
  60. data/templates/latex/layout.tex.erb +27 -2
  61. data/test/assets/test_template.tex +10 -1
  62. data/test/book_test_helper.rb +1 -2
  63. data/test/run_test.rb +10 -0
  64. data/test/sample-book/src/style.css +215 -0
  65. data/test/sample-book/src/vendor/jumoline/lppl.txt +416 -0
  66. data/test/test_book.rb +0 -1
  67. data/test/test_catalog.rb +1 -0
  68. data/test/test_converter.rb +1 -1
  69. data/test/test_epub3maker.rb +44 -51
  70. data/test/test_epubmaker.rb +82 -38
  71. data/test/test_epubmaker_cmd.rb +1 -1
  72. data/test/test_extentions_hash.rb +8 -1
  73. data/test/test_htmlbuilder.rb +411 -18
  74. data/test/test_i18n.rb +17 -0
  75. data/test/test_idgxmlbuilder.rb +88 -3
  76. data/test/test_image_finder.rb +18 -0
  77. data/test/test_index.rb +2 -0
  78. data/test/test_latexbuilder.rb +96 -8
  79. data/test/test_makerhelper.rb +2 -2
  80. data/test/test_markdownbuilder.rb +22 -1
  81. data/test/test_md2inaobuilder.rb +0 -5
  82. data/test/test_pdfmaker.rb +54 -36
  83. data/test/test_pdfmaker_cmd.rb +1 -1
  84. data/test/test_rstbuilder.rb +356 -0
  85. data/test/test_textutils.rb +14 -4
  86. data/test/test_topbuilder.rb +23 -4
  87. data/test/test_zip_exporter.rb +113 -0
  88. metadata +28 -2
@@ -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: "pygments"
177
+ # html: "rouge"
178
178
  # latex: "listings"
179
179
 
180
180
  # カタログファイル名を指定する
@@ -51,7 +51,7 @@ colophon: true
51
51
  ## Syntax Highlighting
52
52
 
53
53
  highlight:
54
- html: "pygments"
54
+ html: "rouge"
55
55
  latex: "listings"
56
56
 
57
57
  ## for HTML
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` ブロック命令または `@<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`」のいずれかが入り、(複数のビルダにまたがる指定が必要かは別として)「,」で区切って複数指定することも可能です。「バックスラッシュ+n」は改行に変換されます。該当のビルダを使用しているときのみ、内容が出力されます。
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
- `//raw` および `@<raw>` は、HTML、XML や TeX の文書構造を容易に壊す可能性があります。使用には十分に注意してください。
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 `}` and `\\` 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)
@@ -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.