test/test_idgxmlbuilder.rb in review-3.2.0 vs test/test_idgxmlbuilder.rb in review-4.0.0
- old
+ new
@@ -197,20 +197,32 @@
end
def test_paragraph
actual = compile_block("foo\nbar\n")
assert_equal '<p>foobar</p>', actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("foo\nbar\n")
+ assert_equal '<p>foo bar</p>', actual
end
def test_tabbed_paragraph
actual = compile_block("\tfoo\nbar\n")
assert_equal %Q(<p inlist="1">foobar</p>), actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("\tfoo\nbar\n")
+ assert_equal %Q(<p inlist="1">foo bar</p>), actual
end
def test_quote
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal '<quote><p>foobar</p><p>buz</p></quote>', actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
+ assert_equal '<quote><p>foo bar</p><p>buz</p></quote>', actual
end
def test_major_blocks
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
expected = %Q(<note><p>A</p><p>B</p></note><note><title aid:pstyle='note-title'>caption</title><p>A</p></note>)
@@ -247,20 +259,32 @@
end
def test_term
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal '<term><p>test1test1.5</p><p>test<i>2</i></p></term>', actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
+ assert_equal '<term><p>test1 test1.5</p><p>test<i>2</i></p></term>', actual
end
def test_point
actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q(<point-t><title aid:pstyle='point-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></point-t>), actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
+ assert_equal %Q(<point-t><title aid:pstyle='point-title'>this is <b>test</b><&>_</title><p>test1 test1.5</p><p>test<i>2</i></p></point-t>), actual
end
def test_point_without_caption
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal '<point><p>test1test1.5</p><p>test<i>2</i></p></point>', actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
+ assert_equal '<point><p>test1 test1.5</p><p>test<i>2</i></p></point>', actual
end
def test_emlist
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q(<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>), actual
@@ -309,11 +333,11 @@
assert_equal expected, actual
end
def test_list
def @chapter.list(_id)
- Book::ListIndex::Item.new('samplelist', 1)
+ Book::Index::Item.new('samplelist', 1)
end
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
expected = <<-EOS.chomp
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre>test1
test1.5
@@ -324,11 +348,11 @@
assert_equal expected, actual
end
def test_listnum
def @chapter.list(_id)
- Book::ListIndex::Item.new('samplelist', 1)
+ Book::Index::Item.new('samplelist', 1)
end
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
expected = <<-EOS.chomp
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1
<span type='lineno'> 2: </span>test1.5
@@ -339,11 +363,11 @@
assert_equal expected, actual
end
def test_listnum_linenum
def @chapter.list(_id)
- Book::ListIndex::Item.new('samplelist', 1)
+ Book::Index::Item.new('samplelist', 1)
end
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
expected = <<-EOS.chomp
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'>100: </span>test1
<span type='lineno'>101: </span>test1.5
@@ -354,11 +378,11 @@
assert_equal expected, actual
end
def test_list_listinfo
def @chapter.list(_id)
- Book::ListIndex::Item.new('samplelist', 1)
+ Book::Index::Item.new('samplelist', 1)
end
@config['listinfo'] = true
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
expected = <<-EOS.chomp
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1
@@ -452,107 +476,119 @@
end
def test_flushright
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(<p align='right'>foobar</p><p align='right'>buz</p>), actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
+ assert_equal %Q(<p align='right'>foo bar</p><p align='right'>buz</p>), actual
end
def test_centering
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q(<p align='center'>foobar</p><p align='center'>buz</p>), actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
+ assert_equal %Q(<p align='center'>foo bar</p><p align='center'>buz</p>), actual
end
def test_blankline
actual = compile_block("//blankline\nfoo\n")
assert_equal %Q(<p/><p>foo</p>), actual
end
def test_noindent
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>), actual
+
+ @book.config['join_lines_by_lang'] = true
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
+ assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foo bar</p><p>foo2 bar2</p>), actual
end
def test_image
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>), actual
end
def test_image_with_metric
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>), actual
end
def test_image_with_metric2
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block("//image[sampleimg][sample photo][scale=1.2, html::class=sample, latex::ignore=params, idgxml::ostyle=object]{\n//}\n")
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>図1.1 sample photo</caption></img>), actual
end
def test_indepimage
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>), actual
end
def test_indepimage_without_caption
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block("//indepimage[sampleimg]\n")
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /></img>), actual
end
def test_indepimage_with_metric
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>), actual
end
def test_indepimage_with_metric2
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample", latex::ignore=params, idgxml::ostyle="object"]\n))
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>sample photo</caption></img>), actual
end
def test_indepimage_without_caption_but_with_metric
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
@@ -626,11 +662,11 @@
assert_equal expected, column_helper(review)
end
def test_column_in_aother_chapter_ref
def @chapter.column_index
- items = [Book::ColumnIndex::Item.new('chap1|column', 1, 'column_cap')]
+ items = [Book::Index::Item.new('chap1|column', 1, 'column_cap')]
Book::ColumnIndex.new(items)
end
actual = compile_inline('test @<column>{chap1|column} test2')
expected = 'test コラム「column_cap」 test2'
@@ -655,16 +691,22 @@
* AAA
-AA
* BBB
-BB
EOS
-
expected = <<-EOS.chomp
<ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
EOS
actual = compile_block(src)
assert_equal expected, actual
+
+ @book.config['join_lines_by_lang'] = true
+ expected = <<-EOS.chomp
+<ul><li aid:pstyle="ul-item">AAA -AA</li><li aid:pstyle="ul-item">BBB -BB</li></ul>
+EOS
+ actual = compile_block(src)
+ assert_equal expected, actual
end
def test_ul_nest1
src = <<-EOS
* AAA
@@ -775,27 +817,27 @@
assert_equal "nor\nmal", compile_inline('@<raw>{|idgxml|nor\\nmal}')
end
def test_inline_imgref
def @chapter.image(_id)
- item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
+ item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
- actual = compile_block "@<imgref>{sampleimg}\n"
+ actual = compile_block("@<imgref>{sampleimg}\n")
expected = %Q(<p><span type='image'>図1.1「sample photo」</span></p>)
assert_equal expected, actual
end
def test_inline_imgref2
def @chapter.image(_id)
- item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
+ item = Book::Index::Item.new('sampleimg', 1)
item.instance_eval { @path = './images/chap1-sampleimg.png' }
item
end
- actual = compile_block "@<imgref>{sampleimg}\n"
+ actual = compile_block("@<imgref>{sampleimg}\n")
expected = %Q(<p><span type='image'>図1.1</span></p>)
assert_equal expected, actual
end
def test_block_raw0