Permalink
Browse files

add MeCab index test

  • Loading branch information...
1 parent f3fb336 commit 0929387bb92d6d2947c824eb8c74f76062ad8937 @kmuto committed Jan 9, 2017
Showing with 20 additions and 3 deletions.
  1. +7 −3 lib/review/latexbuilder.rb
  2. +13 −0 test/test_latexbuilder.rb
@@ -39,9 +39,15 @@ def builder_init_file
@ol_num = nil
@first_line_num = nil
@sec_counter = SecCounter.new(5, @chapter)
+ setup_index
+ initialize_metachars(@book.config["texcommand"])
+ end
+ private :builder_init_file
+
+ def setup_index
@index_db = {}
@index_mecab = nil
- if @book.config["makeindex"]
+ if @book.config["pdfmaker"]["makeindex"]
@index_db = load_idxdb(@book.config["pdfmaker"]["makeindex_dic"]) if @book.config["pdfmaker"]["makeindex_dic"]
if @book.config["pdfmaker"]["makeindex_mecab"]
begin
@@ -52,9 +58,7 @@ def builder_init_file
end
end
end
- initialize_metachars(@book.config["texcommand"])
end
- private :builder_init_file
def load_idxdb(file)
table = {}
@@ -210,6 +210,19 @@ def test_inline_idx
assert_equal %Q|\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}, \\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}|, actual
end
+ def test_inline_idx_yomi
+ begin
+ require 'MeCab'
+ rescue LoadError
+ $stderr.puts "skip test_inline_idx_yomi (cannot find MeCab)"
+ return true
+ end
+ @book.config["pdfmaker"]["makeindex"] = true
+ @builder.setup_index
+ actual = compile_inline("@<hidx>{漢字}@<hidx>{項目@1<<>>項目@2}")
+ assert_equal %Q|\\index{かんじ@漢字}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}|, actual
+ end
+
def test_jis_x_0201_kana
# uplatex can handle half-width kana natively
actual = compile_inline("foo・カンジ、テスト")

0 comments on commit 0929387

Please sign in to comment.