Skip to content

Commit

Permalink
fix #465; //list: show caption without highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Dec 8, 2015
1 parent a248da4 commit 89fc757
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def list(lines, id, caption, lang = nil)
if highlight_listings?
common_code_block_lst(id, lines, 'reviewlistlst', 'caption', caption, lang)
else
common_code_block(id, lines, 'reviewlist', nil, lang) do |line, idx|
common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx|
detab(line) + "\n"
end
end
Expand Down
20 changes: 20 additions & 0 deletions test/test_latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,26 @@ def test_emlist_with_tab4
assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, actual
end

def test_list
actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|\\reviewlistcaption{リスト1.1: cap1}\n\\begin{reviewlist}\nfoo\nbar\n\nbuz\n\\end{reviewlist}\n|, actual
end

def test_list_lst
@book.config["highlight"] = {}
@book.config["highlight"]["latex"] = "listings"
actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
assert_equal %Q|\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n|, actual
end

def test_list_lst_with_lang
@book.config["highlight"] = {}
@book.config["highlight"]["latex"] = "listings"
@book.config["highlight"]["lang"] = "sql"
actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
assert_equal %Q|\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n|, actual
end

def test_listnum
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual
Expand Down

0 comments on commit 89fc757

Please sign in to comment.