Skip to content

Commit

Permalink
add MeCab index test
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Jan 9, 2017
1 parent f3fb336 commit 0929387
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/review/latexbuilder.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ def builder_init_file
@ol_num = nil @ol_num = nil
@first_line_num = nil @first_line_num = nil
@sec_counter = SecCounter.new(5, @chapter) @sec_counter = SecCounter.new(5, @chapter)
setup_index
initialize_metachars(@book.config["texcommand"])
end
private :builder_init_file

def setup_index
@index_db = {} @index_db = {}
@index_mecab = nil @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"] @index_db = load_idxdb(@book.config["pdfmaker"]["makeindex_dic"]) if @book.config["pdfmaker"]["makeindex_dic"]
if @book.config["pdfmaker"]["makeindex_mecab"] if @book.config["pdfmaker"]["makeindex_mecab"]
begin begin
Expand All @@ -52,9 +58,7 @@ def builder_init_file
end end
end end
end end
initialize_metachars(@book.config["texcommand"])
end end
private :builder_init_file


def load_idxdb(file) def load_idxdb(file)
table = {} table = {}
Expand Down
13 changes: 13 additions & 0 deletions test/test_latexbuilder.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 assert_equal %Q|\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}, \\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}|, actual
end 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 def test_jis_x_0201_kana
# uplatex can handle half-width kana natively # uplatex can handle half-width kana natively
actual = compile_inline("foo・カンジ、テスト") actual = compile_inline("foo・カンジ、テスト")
Expand Down

0 comments on commit 0929387

Please sign in to comment.