Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add \begin{reviewlistblock}...\end{reviewlistblock} for lists #1049

Merged
merged 2 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ def cmd(lines, caption = nil, lang = nil)

def common_code_block(id, lines, command, caption, _lang)
@doc_status[:caption] = true
unless @book.config.check_version('2', exception: false)
puts '\\begin{reviewlistblock}'
end
if caption.present?
if command =~ /emlist/ || command =~ /cmd/ || command =~ /source/
puts macro(command + 'caption', compile_inline(caption))
Expand All @@ -384,6 +387,9 @@ def common_code_block(id, lines, command, caption, _lang)
puts macro('begin', command)
print body
puts macro('end', command)
unless @book.config.check_version('2', exception: false)
puts '\\end{reviewlistblock}'
end
blank
end

Expand Down
2 changes: 2 additions & 0 deletions templates/latex/review-jsbook/review-basemacros.sty
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
\end{alltt}\end{center}
\end{figure}}

\newenvironment{reviewlistblock}{}{}

\newenvironment{reviewemlist}{%
\medskip\small\begin{shaded}\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
\end{alltt}\end{shaded}}
Expand Down
28 changes: 15 additions & 13 deletions test/test_latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ def test_dlist_beforeulol

def test_cmd
actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n\\end{reviewlistblock}\n), actual
end

def test_cmd_caption
actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n\\end{reviewlistblock}\n), actual
end

def test_cmd_lst
Expand All @@ -307,7 +307,7 @@ def test_cmd_lst

def test_emlist
actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
end

def test_emlist_lst
Expand All @@ -327,33 +327,33 @@ def test_emlist_lst_without_lang

def test_emlist_caption
actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
end

def test_emlist_empty_caption
actual = compile_block("//emlist[]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
end

def test_emlist_with_tab
actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
assert_equal %Q(\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
end

def test_emlist_with_tab4
@config['tabwidth'] = 4
actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
assert_equal %Q(\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n\\end{reviewlistblock}\n), actual
end

def test_emlistnum_caption
actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n 1: foo\n 2: bar\n 3: \n 4: buz\n\\end{reviewemlist}\n), actual
assert_equal %Q(\n\\begin{reviewlistblock}\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n 1: foo\n 2: bar\n 3: \n 4: buz\n\\end{reviewemlist}\n\\end{reviewlistblock}\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
assert_equal %Q(\\begin{reviewlistblock}\n\\reviewlistcaption{リスト1.1: cap1}\n\\begin{reviewlist}\nfoo\nbar\n\nbuz\n\\end{reviewlist}\n\\end{reviewlistblock}\n), actual
end

def test_list_lst
Expand All @@ -373,12 +373,12 @@ def test_list_lst_with_lang

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
assert_equal %Q(\\begin{reviewlistblock}\n\\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\\end{reviewlistblock}\n), actual
end

def test_listnum_linenum
actual = compile_block("//firstlinenum[100]\n//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}\n100: class Foo\n101: def foo\n102: bar\n103: \n104: buz\n105: end\n106: end\n\\end{reviewlist}\n), actual
assert_equal %Q(\\begin{reviewlistblock}\n\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n100: class Foo\n101: def foo\n102: bar\n103: \n104: buz\n105: end\n106: end\n\\end{reviewlist}\n\\end{reviewlistblock}\n), actual
end

def test_listnum_lst
Expand All @@ -397,12 +397,12 @@ def test_listnum_lst_linenum

def test_source
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\\reviewsourcecaption{foo/bar/test.rb}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n), actual
assert_equal %Q(\\begin{reviewlistblock}\n\\reviewsourcecaption{foo/bar/test.rb}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n\\end{reviewlistblock}\n), actual
end

def test_source_empty_caption
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n), actual
assert_equal %Q(\\begin{reviewlistblock}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n\\end{reviewlistblock}\n), actual
end

def test_source_lst
Expand Down Expand Up @@ -1048,9 +1048,11 @@ def on_appendix?

\\reviewlistref{A.1}

\\begin{reviewlistblock}
\\reviewlistcaption{リストA.1: FOO}
\\begin{reviewlist}
\\end{reviewlist}
\\end{reviewlistblock}
EOS
actual = compile_block(src)
assert_equal expected, actual
Expand Down