'
+
+ if !caption_top?('list') && caption.present?
+ puts %Q(
#{compile_inline(caption)}
)
+ end
+
puts '
'
end
@@ -530,12 +553,13 @@ def talk(lines)
def texequation(lines, id = nil, caption = '')
if id
puts %Q(
)
- texequation_header(id, caption)
+ texequation_header(id, caption) if caption_top?('equation')
end
texequation_body(lines)
if id
+ texequation_header(id, caption) unless caption_top?('equation')
puts '
'
end
end
@@ -603,20 +627,22 @@ def result_metric(array)
def image_image(id, caption, metric)
metrics = parse_metric('html', metric)
puts %Q(
)
begin
- if caption.present?
+ if caption_top?('table') && caption.present?
+ table_header(id, caption)
+ end
+
+ imgtable_image(id, caption, metric)
+
+ if !caption_top?('table') && caption.present?
table_header(id, caption)
end
rescue KeyError
error "no such table: #{id}"
end
- imgtable_image(id, caption, metric)
-
puts '
EOS
assert_equal expected, actual
@@ -1220,6 +1281,20 @@ def test_source
buz
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+
+
foo
+bar
+
+buz
+
+
foo/bar/test.rb
+
EOS
assert_equal expected, actual
end
@@ -1257,6 +1332,18 @@ def test_box
bar
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+
+
foo
+bar
+
+
FOO
+
EOS
assert_equal expected, actual
end
@@ -1301,6 +1388,18 @@ def test_emlist_caption
lineB
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+
+
lineA
+lineB
+
+
cap1
+
EOS
assert_equal expected, actual
end
@@ -1341,6 +1440,18 @@ def test_emlistnum_lang
2: lineB
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+
+
1: lineA
+ 2: lineB
+
+
cap
+
EOS
assert_equal expected, actual
end
@@ -1413,6 +1524,18 @@ def test_cmd_caption
lineB
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+
+
lineA
+lineB
+
+
cap1
+
EOS
assert_equal expected, actual
end
@@ -2074,6 +2197,19 @@ def test_table
ccc
ddd<>&
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+
+
+
aaa
bbb
+
ccc
ddd<>&
+
+
表1.1: FOO
+
EOS
assert_equal expected, actual
end
@@ -2110,6 +2246,25 @@ def test_emtable
ccc
ddd<>&
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+
+
+
aaa
bbb
+
ccc
ddd<>&
+
+
foo
+
+
+
+
aaa
bbb
+
ccc
ddd<>&
+
+
EOS
assert_equal expected, actual
end
@@ -2127,6 +2282,16 @@ def @chapter.image(_id)
表1.1: test for imgtable
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
+ expected = <<-EOS
+
+
+
表1.1: test for imgtable
+
EOS
assert_equal expected, actual
end
@@ -2383,6 +2548,20 @@ def test_texequation_with_caption
+EOS
+ actual = compile_block(src)
+ assert_equal expected, actual
+
+ @config['caption_position']['equation'] = 'bottom'
+ expected = <<-EOS
+
式1.1
+
+
+
e=mc^2
+
+
+
式1.1: The Equivalence of Mass and Energy
+
EOS
actual = compile_block(src)
assert_equal expected, actual
diff --git a/test/test_idgxmlbuilder.rb b/test/test_idgxmlbuilder.rb
index aebe13651..cac822da6 100644
--- a/test/test_idgxmlbuilder.rb
+++ b/test/test_idgxmlbuilder.rb
@@ -100,6 +100,27 @@ def test_inline_in_table_without_header_and_cellwidth
assert_equal %Q(
1\t2
3\t4<>&
), actual
end
+ def test_table
+ actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS.chomp
+
aaa
bbb
ccc
ddd<>&
+EOS
+ assert_equal expected, actual
+
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS.chomp
+
表1.1 FOO
aaa
bbb
ccc
ddd<>&
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS.chomp
+
aaa
bbb
ccc
ddd<>&
表1.1 FOO
+EOS
+ assert_equal expected, actual
+ end
+
def test_customize_cellwidth
actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
assert_equal %Q(
A
B
C
), actual
@@ -144,6 +165,10 @@ def test_empty_table
def test_emtable
actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
assert_equal %Q(
foo
A
A
), actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
+ assert_equal %Q(
A
foo
A
), actual
end
def test_table_row_separator
@@ -329,11 +354,19 @@ def test_point_without_caption
def test_emlist
actual = compile_block("//emlist[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q(
this is test<&>_
test1\ntest1.5\n\ntest2\n
), actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlist[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ assert_equal %Q(
test1\ntest1.5\n\ntest2\n
this is test<&>_
), actual
end
def test_emlistnum
actual = compile_block("//emlistnum[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
assert_equal %Q(
this is test<&>_
1: test1\n 2: test1.5\n 3: \n 4: test2\n
), actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlistnum[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ assert_equal %Q(
1: test1\n 2: test1.5\n 3: \n 4: test2\n
this is test<&>_
), actual
end
def test_emlist_listinfo
@@ -385,6 +418,17 @@ def @chapter.list(_id)
test2
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//list[samplelist][this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ expected = <<-EOS.chomp
+
test1
+test1.5
+
+test2
+
リスト1.1 this is test<&>_
EOS
assert_equal expected, actual
end
@@ -400,6 +444,17 @@ def @chapter.list(_id)
3: 4: test2
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//listnum[samplelist][this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ expected = <<-EOS.chomp
+
1: test1
+ 2: test1.5
+ 3:
+ 4: test2
+
リスト1.1 this is test<&>_
EOS
assert_equal expected, actual
end
@@ -415,6 +470,17 @@ def @chapter.list(_id)
102: 103: test2
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ expected = <<-EOS.chomp
+
100: test1
+101: test1.5
+102:
+103: test2
+
リスト1.1 this is test<&>_
EOS
assert_equal expected, actual
end
@@ -431,6 +497,17 @@ def @chapter.list(_id)
test2
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//list[samplelist][this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ expected = <<-EOS.chomp
+
test1
+test1.5
+
+test2
+
リスト1.1 this is test<&>_
EOS
assert_equal expected, actual
end
@@ -449,6 +526,15 @@ def test_cmd
cap1
lineA
lineB
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS.chomp
+
lineA
+lineB
+
cap1
EOS
assert_equal expected, actual
end
@@ -461,6 +547,17 @@ def test_source
buz
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS.chomp
+
EOS
assert_equal expected, actual
end
@@ -498,6 +595,17 @@ def test_insn
test2
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//insn[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ expected = <<-EOS.chomp
+test1
+test1.5
+
+test2
+this is test<&>_
EOS
assert_equal expected, actual
end
@@ -511,6 +619,17 @@ def test_box
test2
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//box[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ expected = <<-EOS.chomp
+test1
+test1.5
+
+test2
+
this is test<&>_
EOS
assert_equal expected, actual
end
@@ -524,6 +643,17 @@ def test_box_non_listinfo
test2
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//box[this is @{test}<&>_]{\ntest1\ntest1.5\n\ntest@{2}\n//}\n")
+ expected = <<-EOS.chomp
+test1
+test1.5
+
+test2
+
this is test<&>_
EOS
assert_equal expected, actual
end
@@ -569,6 +699,10 @@ def @chapter.image(_id)
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
assert_equal %Q(
図1.1 sample photo
), actual
+
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
+ assert_equal %Q(
図1.1 sample photo
), actual
end
def test_image_with_metric
@@ -602,6 +736,10 @@ def @chapter.image(_id)
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
assert_equal %Q(
sample photo
), actual
+
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
+ assert_equal %Q(
sample photo
), actual
end
def test_indepimage_without_caption
@@ -972,5 +1110,10 @@ def test_texequation_with_caption
expected = %Q(
式1.1
式1.1 The Equivalence of Mass and Energy
e=mc^2
)
actual = compile_block(src)
assert_equal expected, actual
+
+ @config['caption_position']['equation'] = 'bottom'
+ expected = %Q(
式1.1
e=mc^2
式1.1 The Equivalence of Mass and Energy
)
+ actual = compile_block(src)
+ assert_equal expected, actual
end
end
diff --git a/test/test_latexbuilder.rb b/test/test_latexbuilder.rb
index 4350d2359..d728d438d 100644
--- a/test/test_latexbuilder.rb
+++ b/test/test_latexbuilder.rb
@@ -432,6 +432,22 @@ def test_cmd_caption
buz
\\end{reviewcmd}
\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+
+\\begin{reviewlistblock}
+\\begin{reviewcmd}
+foo
+bar
+
+buz
+\\end{reviewcmd}
+\\reviewcmdcaption{cap1}
+\\end{reviewlistblock}
EOS
assert_equal expected, actual
end
@@ -507,6 +523,22 @@ def test_emlist_caption
buz
\\end{reviewemlist}
\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+
+\\begin{reviewlistblock}
+\\begin{reviewemlist}
+foo
+bar
+
+buz
+\\end{reviewemlist}
+\\reviewemlistcaption{cap1}
+\\end{reviewlistblock}
EOS
assert_equal expected, actual
end
@@ -573,6 +605,22 @@ def test_emlistnum_caption
4: buz
\\end{reviewemlist}
\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+
+\\begin{reviewlistblock}
+\\begin{reviewemlist}
+ 1: foo
+ 2: bar
+ 3:
+ 4: buz
+\\end{reviewemlist}
+\\reviewemlistcaption{cap1}
+\\end{reviewlistblock}
EOS
assert_equal expected, actual
end
@@ -589,6 +637,21 @@ def test_list
buz
\\end{reviewlist}
\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistblock}
+\\begin{reviewlist}
+foo
+bar
+
+buz
+\\end{reviewlist}
+\\reviewlistcaption{リスト1.1: cap1}
+\\end{reviewlistblock}
EOS
assert_equal expected, actual
end
@@ -601,6 +664,16 @@ def test_list_lst
\\begin{reviewlistlst}[caption={cap1},language={sql}]
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
\\end{reviewlistlst}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ # XXX: caption_position won't work with highlight
+ actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistlst}[caption={cap1},language={sql}]
+SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
+\\end{reviewlistlst}
EOS
assert_equal expected, actual
end
@@ -633,6 +706,24 @@ def test_listnum
7: end
\\end{reviewlist}
\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistblock}
+\\begin{reviewlist}
+ 1: class Foo
+ 2: def foo
+ 3: bar
+ 4:
+ 5: buz
+ 6: end
+ 7: end
+\\end{reviewlist}
+\\reviewlistcaption{リスト1.1: ruby}
+\\end{reviewlistblock}
EOS
assert_equal expected, actual
end
@@ -670,6 +761,22 @@ def foo
end
end
\\end{reviewlistnumlst}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ # XXX: caption_position won't work with highlight
+ actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistnumlst}[caption={ruby},language={}]
+class Foo
+ def foo
+ bar
+
+ buz
+ end
+end
+\\end{reviewlistnumlst}
EOS
assert_equal expected, actual
end
@@ -704,6 +811,21 @@ def test_source
buz
\\end{reviewsource}
\\end{reviewlistblock}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+\\begin{reviewlistblock}
+\\begin{reviewsource}
+foo
+bar
+
+buz
+\\end{reviewsource}
+\\reviewsourcecaption{foo/bar/test.rb}
+\\end{reviewlistblock}
EOS
assert_equal expected, actual
end
@@ -732,6 +854,19 @@ def test_source_lst
foo
bar
+buz
+\\end{reviewsourcelst}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ # XXX: caption_position won't work with highlight
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
+foo
+bar
+
buz
\\end{reviewsourcelst}
EOS
@@ -888,6 +1023,18 @@ def @chapter.image(_id)
actual = compile_block("//image[sampleimg][sample photo][]{\n//}\n")
assert_equal expected, actual
+
+ @book.config['pdfmaker']['use_original_image_size'] = nil
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
+ expected = <<-EOS
+\\begin{reviewimage}%%sampleimg
+\\reviewimagecaption{sample photo}
+\\label{image:chap1:sampleimg}
+\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
+\\end{reviewimage}
+EOS
+ assert_equal expected, actual
end
def test_image_with_metric
@@ -1008,6 +1155,17 @@ def @chapter.image(_id)
actual = compile_block("//indepimage[sampleimg][sample photo][]\n")
assert_equal expected, actual
+
+ @book.config['pdfmaker']['use_original_image_size'] = nil
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
+ expected = <<-EOS
+\\begin{reviewimage}%%sampleimg
+\\reviewindepimagecaption{図: sample photo}
+\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
+\\end{reviewimage}
+EOS
+ assert_equal expected, actual
end
def test_indepimage_without_caption
@@ -1134,6 +1292,21 @@ def test_table
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
\\end{reviewtable}
\\end{table}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+\\begin{table}%%foo
+\\begin{reviewtable}{|l|l|}
+\\hline
+\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
+ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
+\\end{reviewtable}
+\\reviewtablecaption{FOO}
+\\label{table:chap1:foo}
+\\end{table}
EOS
assert_equal expected, actual
end
@@ -1240,6 +1413,26 @@ def test_emtable
\\end{reviewtable}
\\end{table}
+\\begin{reviewtable}{|l|l|}
+\\hline
+\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
+ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
+\\end{reviewtable}
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+\\begin{table}%%
+\\begin{reviewtable}{|l|l|}
+\\hline
+\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
+ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
+\\end{reviewtable}
+\\reviewtablecaption*{foo}
+\\end{table}
+
\\begin{reviewtable}{|l|l|}
\\hline
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
@@ -1285,6 +1478,21 @@ def @chapter.image(_id)
actual = compile_block("//imgtable[sampleimg][test for imgtable][]{\n//}\n")
assert_equal expected, actual
+
+ @book.config['pdfmaker']['use_original_image_size'] = nil
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
+
+ expected = <<-EOS
+\\begin{table}[h]%%sampleimg
+\\label{table:chap1:sampleimg}
+\\begin{reviewimage}%%sampleimg
+\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
+\\end{reviewimage}
+\\reviewimgtablecaption{test for imgtable}
+\\end{table}
+EOS
+ assert_equal expected, actual
end
def test_imgtable_with_metrics
@@ -2039,6 +2247,21 @@ def test_texequation_with_caption
e=mc^2
\\end{equation*}
\\end{reviewequationblock}
+EOS
+ actual = compile_block(src)
+ assert_equal expected, actual
+
+ @config['caption_position']['equation'] = 'bottom'
+ expected = <<-EOS
+
+\\reviewequationref{1.1}
+
+\\begin{reviewequationblock}
+\\begin{equation*}
+e=mc^2
+\\end{equation*}
+\\reviewequationcaption{式1.1: The Equivalence of Mass \\reviewit{and} Energy}
+\\end{reviewequationblock}
EOS
actual = compile_block(src)
assert_equal expected, actual
diff --git a/test/test_plaintextbuilder.rb b/test/test_plaintextbuilder.rb
index 03c255dc9..e27497cfa 100644
--- a/test/test_plaintextbuilder.rb
+++ b/test/test_plaintextbuilder.rb
@@ -249,6 +249,17 @@ def @chapter.list(_id)
foo
bar
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//list[samplelist][this is @{test}<&>_]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+foo
+bar
+
+リスト1.1 this is test<&>_
+
EOS
assert_equal expected, actual
end
@@ -264,6 +275,17 @@ def @chapter.list(_id)
1: foo
2: bar
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//listnum[test][this is @{test}<&>_]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+ 1: foo
+ 2: bar
+
+リスト1.1 this is test<&>_
+
EOS
assert_equal expected, actual
end
@@ -277,6 +299,18 @@ def test_source
buz
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+foo
+bar
+
+buz
+foo/bar/test.rb
+
EOS
assert_equal expected, actual
end
@@ -308,6 +342,16 @@ def test_box
foo
bar
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+foo
+bar
+FOO
+
EOS
assert_equal expected, actual
end
@@ -327,6 +371,16 @@ def test_cmd
lineA
lineB
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+lineA
+lineB
+cap1
+
EOS
assert_equal expected, actual
end
@@ -348,6 +402,16 @@ def test_emlist_caption
lineA
lineB
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+lineA
+lineB
+cap1
+
EOS
assert_equal expected, actual
end
@@ -359,6 +423,16 @@ def test_emlistnum
1: foo
2: bar
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlistnum[this is @{test}<&>_]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+ 1: foo
+ 2: bar
+this is test<&>_
+
EOS
assert_equal expected, actual
end
@@ -387,6 +461,16 @@ def test_table
aaa\tbbb
ccc\tddd<>&
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+aaa\tbbb
+ccc\tddd<>&
+
+表1.1 FOO
EOS
assert_equal expected, actual
end
@@ -521,6 +605,10 @@ def @chapter.image(_id)
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
assert_equal %Q(図1.1 sample photo\n\n), actual
+
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
+ assert_equal %Q(図1.1 sample photo\n\n), actual
end
def test_image_with_metric
@@ -649,6 +737,17 @@ def test_texequation_with_caption
式1.1 The Equivalence of Mass and Energy
e=mc^2
+EOS
+ actual = compile_block(src)
+ assert_equal expected, actual
+
+ @config['caption_position']['equation'] = 'bottom'
+ expected = <<-EOS
+式1.1
+
+e=mc^2
+式1.1 The Equivalence of Mass and Energy
+
EOS
actual = compile_block(src)
assert_equal expected, actual
diff --git a/test/test_topbuilder.rb b/test/test_topbuilder.rb
index 3a0332760..97e2ad7ad 100644
--- a/test/test_topbuilder.rb
+++ b/test/test_topbuilder.rb
@@ -295,6 +295,19 @@ def @chapter.list(_id)
2: bar
◆→終了:リスト←◆
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//listnum[test][this is @{test}<&>_]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+◆→開始:リスト←◆
+ 1: foo
+ 2: bar
+
+リスト1.1 this is ★test☆<&>_
+◆→終了:リスト←◆
+
EOS
assert_equal expected, actual
end
@@ -310,6 +323,20 @@ def test_source
buz
◆→終了:ソースコードリスト←◆
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
+ expected = <<-EOS
+◆→開始:ソースコードリスト←◆
+foo
+bar
+
+buz
+■foo/bar/test.rb
+◆→終了:ソースコードリスト←◆
+
EOS
assert_equal expected, actual
end
@@ -347,6 +374,18 @@ def test_box
bar
◆→終了:書式←◆
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+◆→開始:書式←◆
+foo
+bar
+■FOO
+◆→終了:書式←◆
+
EOS
assert_equal expected, actual
end
@@ -370,6 +409,18 @@ def test_cmd
lineB
◆→終了:コマンド←◆
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+◆→開始:コマンド←◆
+lineA
+lineB
+■cap1
+◆→終了:コマンド←◆
+
EOS
assert_equal expected, actual
end
@@ -395,6 +446,18 @@ def test_emlist_caption
lineB
◆→終了:インラインリスト←◆
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
+ expected = <<-EOS
+◆→開始:インラインリスト←◆
+lineA
+lineB
+■cap1
+◆→終了:インラインリスト←◆
+
EOS
assert_equal expected, actual
end
@@ -408,6 +471,18 @@ def test_emlistnum
2: bar
◆→終了:インラインリスト←◆
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['list'] = 'bottom'
+ actual = compile_block("//emlistnum[this is @{test}<&>_]{\nfoo\nbar\n//}\n")
+ expected = <<-EOS
+◆→開始:インラインリスト←◆
+ 1: foo
+ 2: bar
+■this is ★test☆<&>_
+◆→終了:インラインリスト←◆
+
EOS
assert_equal expected, actual
end
@@ -440,6 +515,19 @@ def test_table
ccc\tddd<>&
◆→終了:表←◆
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['table'] = 'bottom'
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
+ expected = <<-EOS
+◆→開始:表←◆
+★aaa☆\t★bbb☆
+ccc\tddd<>&
+
+表1.1 FOO
+◆→終了:表←◆
+
EOS
assert_equal expected, actual
end
@@ -657,6 +745,18 @@ def @chapter.image(_id)
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
expected = <<-EOS
◆→開始:図←◆
+◆→./images/chap1-sampleimg.png←◆
+
+図1.1 sample photo
+◆→終了:図←◆
+
+EOS
+ assert_equal expected, actual
+
+ @config['caption_position']['image'] = 'top'
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
+ expected = <<-EOS
+◆→開始:図←◆
図1.1 sample photo
◆→./images/chap1-sampleimg.png←◆
@@ -676,9 +776,9 @@ def @chapter.image(_id)
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
expected = <<-EOS
◆→開始:図←◆
-図1.1 sample photo
-
◆→./images/chap1-sampleimg.png scale=1.2←◆
+
+図1.1 sample photo
◆→終了:図←◆
EOS
@@ -829,6 +929,20 @@ def test_texequation_with_caption
e=mc^2
◆→終了:TeX式←◆
+EOS
+ actual = compile_block(src)
+ assert_equal expected, actual
+
+ @config['caption_position']['equation'] = 'bottom'
+
+ expected = <<-EOS
+式1.1
+
+◆→開始:TeX式←◆
+e=mc^2
+式1.1 The Equivalence of Mass ▲and☆ Energy
+◆→終了:TeX式←◆
+
EOS
actual = compile_block(src)
assert_equal expected, actual