test/test_idgxmlbuilder.rb in review-2.0.0.beta1 vs test/test_idgxmlbuilder.rb in review-2.0.0
- old
+ new
@@ -12,13 +12,10 @@
def setup
@builder = IDGXMLBuilder.new()
@config = ReVIEW::Configure.values
@config.merge!({
"secnolevel" => 2,
- "inencoding" => "UTF-8",
- "outencoding" => "UTF-8",
- "nolf" => true,
"tableopt" => "10"
})
@book = Book::Base.new(nil)
@book.config = @config
@compiler = ReVIEW::Compiler.new(@builder)
@@ -86,32 +83,54 @@
assert_equal %Q|@<tt>{inline}|, actual
end
def test_inline_in_table
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
- assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i><>&</td></tbody></table>|, actual
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><b>1</b></td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>2</i></td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><b>3</b></td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>4</i><>&</td></tbody></table>|, actual
end
def test_inline_in_table_without_header
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
- assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td xyh="1,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td xyh="2,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i><>&</td></tbody></table>|, actual
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><b>1</b></td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>2</i></td><td xyh="1,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><b>3</b></td><td xyh="2,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>4</i><>&</td></tbody></table>|, actual
end
def test_inline_in_table_without_cellwidth
@config["tableopt"] = nil
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
assert_equal %Q|<table><tbody><tr type="header"><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i><>&</tr></tbody></table>|, actual
- @config["tableopt"] = 10
end
def test_inline_in_table_without_header_and_cellwidth
@config["tableopt"] = nil
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
assert_equal %Q|<table><tbody><tr><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i><>&</tr></tbody></table>|, actual
- @config["tableopt"] = 10
end
+ def test_customize_cellwidth
+ actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="8.503">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">C</td></tbody></table>|, actual
+
+ actual = compile_block("//tsize[2,3]\n//table{\nA\tB\tC\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="8.503">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">C</td></tbody></table>|, actual
+
+ actual = compile_block("//tsize[2]\n//table{\nA\tB\tC\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">C</td></tbody></table>|, actual
+ end
+
+ def test_customize_mmtopt
+ actual = compile_block("//table{\nA\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>|, actual
+
+ @config["pt_to_mm_unit"] = 0.3514
+ actual = compile_block("//table{\nA\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.458">A</td></tbody></table>|, actual
+
+ @config["pt_to_mm_unit"] = "0.3514"
+ actual = compile_block("//table{\nA\n//}\n")
+ assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.458">A</td></tbody></table>|, actual
+ end
+
def test_inline_br
actual = compile_inline("@<br>{}")
assert_equal %Q|\n|, actual
end
@@ -168,51 +187,50 @@
def test_quote
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|<quote><p>foobar</p><p>buz</p></quote>|, actual
end
- def test_quote_deprecated
- @book.config["deprecated-blocklines"] = true
- actual = compile_block("//quote{\nfoo\n\nbuz\n//}\n")
- @book.config["deprecated-blocklines"] = nil
- assert_equal %Q|<quote>foo\n\nbuz</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>)
+ assert_equal expected, actual
- ## XXX block content should be escaped.
- def test_note
- actual = compile_block("//note[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
- assert_equal %Q|<note><title aid:pstyle='note-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></note>|, actual
- end
+ actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
+ expected = %Q(<memo><p>A</p><p>B</p></memo><memo><title aid:pstyle='memo-title'>caption</title><p>A</p></memo>)
+ assert_equal expected, actual
- ## XXX block content should be escaped.
- def test_memo
- actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
- assert_equal %Q|<memo><title aid:pstyle='memo-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></memo>|, actual
+ actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
+ expected = %Q(<info><p>A</p><p>B</p></info><info><title aid:pstyle='info-title'>caption</title><p>A</p></info>)
+ assert_equal expected, actual
+
+ actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
+ expected = %Q(<important><p>A</p><p>B</p></important><important><title aid:pstyle='important-title'>caption</title><p>A</p></important>)
+ assert_equal expected, actual
+
+ actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
+ expected = %Q(<caution><p>A</p><p>B</p></caution><caution><title aid:pstyle='caution-title'>caption</title><p>A</p></caution>)
+ assert_equal expected, actual
+
+ # notice uses special tag notice-t if it includes caption
+ actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
+ expected = %Q(<notice><p>A</p><p>B</p></notice><notice-t><title aid:pstyle='notice-title'>caption</title><p>A</p></notice-t>)
+ assert_equal expected, actual
+
+ actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
+ expected = %Q(<warning><p>A</p><p>B</p></warning><warning><title aid:pstyle='warning-title'>caption</title><p>A</p></warning>)
+ assert_equal expected, actual
+
+ actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
+ expected = %Q(<tip><p>A</p><p>B</p></tip><tip><title aid:pstyle='tip-title'>caption</title><p>A</p></tip>)
+ assert_equal expected, actual
end
def test_term
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
assert_equal %Q|<term><p>test1test1.5</p><p>test<i>2</i></p></term>|, actual
end
- def test_term_deprecated
- @book.config["deprecated-blocklines"] = true
- actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
- @book.config["deprecated-blocklines"] = nil
- assert_equal %Q|<term>test1test1.5\n\ntest<i>2</i></term>|, actual
- end
-
- def test_notice
- actual = compile_block("//notice[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
- assert_equal %Q|<notice-t><title aid:pstyle='notice-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></notice-t>|, actual
- end
-
- def test_notice_without_caption
- actual = compile_block("//notice{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
- assert_equal %Q|<notice><p>test1test1.5</p><p>test<i>2</i></p></notice>|, 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
end
@@ -605,6 +623,7 @@
def test_block_raw4
actual = compile_block("//raw[|idgxml <>!\"\\n& ]\n")
expected = %Q(|idgxml <>!\"\n& )
assert_equal expected.chomp, actual
end
+
end