tmtms-review 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +9 -0
  3. data/COPYING +515 -0
  4. data/ChangeLog +2083 -0
  5. data/README.rdoc +50 -0
  6. data/Rakefile +56 -0
  7. data/VERSION +1 -0
  8. data/bin/review-check +178 -0
  9. data/bin/review-checkdep +63 -0
  10. data/bin/review-compile +205 -0
  11. data/bin/review-epubmaker +661 -0
  12. data/bin/review-epubmaker-ng +176 -0
  13. data/bin/review-index +118 -0
  14. data/bin/review-pdfmaker +208 -0
  15. data/bin/review-preproc +142 -0
  16. data/bin/review-validate +51 -0
  17. data/bin/review-vol +102 -0
  18. data/debian/README.Debian +12 -0
  19. data/debian/README.source +5 -0
  20. data/debian/changelog +5 -0
  21. data/debian/compat +1 -0
  22. data/debian/control +22 -0
  23. data/debian/copyright +62 -0
  24. data/debian/docs +6 -0
  25. data/debian/manpage.1.ex +59 -0
  26. data/debian/patches/path.diff +91 -0
  27. data/debian/patches/series +1 -0
  28. data/debian/review.install +13 -0
  29. data/debian/review.links +4 -0
  30. data/debian/rules +13 -0
  31. data/debian/source/format +1 -0
  32. data/doc/format.rdoc +582 -0
  33. data/doc/format_idg.rdoc +180 -0
  34. data/doc/libepubmaker/sample.yaml +90 -0
  35. data/doc/quickstart.rdoc +188 -0
  36. data/doc/ruby-uuid/README +11 -0
  37. data/doc/ruby-uuid/README.ja +34 -0
  38. data/doc/sample.css +108 -0
  39. data/doc/sample.yaml +62 -0
  40. data/lib/epubmaker.rb +28 -0
  41. data/lib/epubmaker/content.rb +82 -0
  42. data/lib/epubmaker/epubv2.rb +418 -0
  43. data/lib/epubmaker/epubv3.rb +249 -0
  44. data/lib/epubmaker/producer.rb +204 -0
  45. data/lib/epubmaker/resource.rb +66 -0
  46. data/lib/lineinput.rb +155 -0
  47. data/lib/review.rb +3 -0
  48. data/lib/review/book.rb +46 -0
  49. data/lib/review/book/base.rb +235 -0
  50. data/lib/review/book/chapter.rb +81 -0
  51. data/lib/review/book/compilable.rb +159 -0
  52. data/lib/review/book/index.rb +339 -0
  53. data/lib/review/book/page_metric.rb +38 -0
  54. data/lib/review/book/parameters.rb +97 -0
  55. data/lib/review/book/part.rb +44 -0
  56. data/lib/review/book/volume.rb +65 -0
  57. data/lib/review/builder.rb +444 -0
  58. data/lib/review/compiler.rb +550 -0
  59. data/lib/review/configure.rb +38 -0
  60. data/lib/review/epubbuilder.rb +18 -0
  61. data/lib/review/exception.rb +21 -0
  62. data/lib/review/extentions.rb +3 -0
  63. data/lib/review/extentions/object.rb +9 -0
  64. data/lib/review/extentions/string.rb +33 -0
  65. data/lib/review/htmlbuilder.rb +1097 -0
  66. data/lib/review/htmllayout.rb +19 -0
  67. data/lib/review/htmlutils.rb +36 -0
  68. data/lib/review/i18n.rb +30 -0
  69. data/lib/review/i18n.yaml +34 -0
  70. data/lib/review/idgxmlbuilder.rb +1145 -0
  71. data/lib/review/latexbuilder.rb +815 -0
  72. data/lib/review/latexindex.rb +35 -0
  73. data/lib/review/latexutils.rb +79 -0
  74. data/lib/review/preprocessor.rb +563 -0
  75. data/lib/review/review.tex.erb +232 -0
  76. data/lib/review/textbuilder.rb +17 -0
  77. data/lib/review/textutils.rb +66 -0
  78. data/lib/review/tocparser.rb +342 -0
  79. data/lib/review/tocprinter.rb +221 -0
  80. data/lib/review/topbuilder.rb +785 -0
  81. data/lib/review/unfold.rb +138 -0
  82. data/lib/uuid.rb +312 -0
  83. data/review.gemspec +141 -0
  84. data/test/CHAPS +2 -0
  85. data/test/bib.re +13 -0
  86. data/test/book_test_helper.rb +35 -0
  87. data/test/test.re +43 -0
  88. data/test/test_book.rb +598 -0
  89. data/test/test_book_chapter.rb +418 -0
  90. data/test/test_book_parameter.rb +42 -0
  91. data/test/test_book_part.rb +50 -0
  92. data/test/test_builder.rb +144 -0
  93. data/test/test_compiler.rb +44 -0
  94. data/test/test_epubmaker.rb +507 -0
  95. data/test/test_helper.rb +27 -0
  96. data/test/test_htmlbuilder.rb +554 -0
  97. data/test/test_htmlutils.rb +28 -0
  98. data/test/test_i18n.rb +64 -0
  99. data/test/test_idgxmlbuilder.rb +589 -0
  100. data/test/test_index.rb +31 -0
  101. data/test/test_latexbuilder.rb +656 -0
  102. data/test/test_lineinput.rb +198 -0
  103. data/test/test_preprocessor.rb +23 -0
  104. data/test/test_textutils.rb +68 -0
  105. data/test/test_topbuilder.rb +244 -0
  106. data/test/test_uuid.rb +156 -0
  107. metadata +161 -0
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+ require 'review/htmlutils'
3
+
4
+ class HTMLUtilsTest < Test::Unit::TestCase
5
+ include ReVIEW::HTMLUtils
6
+
7
+ def test_escape_html
8
+ assert_equal '&lt;', escape_html('<')
9
+ assert_equal '&lt;&lt;', escape_html('<<')
10
+ assert_equal '_&lt;_&lt;_', escape_html('_<_<_')
11
+ end
12
+
13
+ def test_escape_html_ex
14
+ keys = ESC.keys
15
+ ESC['.'] = 'X'
16
+ ESC.each_pair do |ch, ref|
17
+ if keys.include?(ch)
18
+ assert_equal ref, escape_html(ch)
19
+ else
20
+ assert_equal ch, escape_html(ch)
21
+ end
22
+ end
23
+ end
24
+
25
+ def test_strip_html
26
+ assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
27
+ end
28
+ end
@@ -0,0 +1,64 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test_helper'
3
+ require 'review/i18n'
4
+
5
+ class I18nTest < Test::Unit::TestCase
6
+ include ReVIEW
7
+
8
+ def test_ja
9
+ I18n.i18n "ja"
10
+ assert_equal I18n.t("image"), "図"
11
+ assert_equal I18n.t("table"), "表"
12
+ assert_equal I18n.t("chapter", 1), "第1章"
13
+ assert_equal I18n.t("etc"), "etc"
14
+ end
15
+
16
+ def test_ja_with_user_i18n
17
+ I18n.i18n "ja", {"image" => "ず"}
18
+ assert_equal I18n.t("image"), "ず"
19
+ assert_equal I18n.t("table"), "表"
20
+ assert_equal I18n.t("chapter", 1), "第1章"
21
+ assert_equal I18n.t("etc"), "etc"
22
+ end
23
+
24
+ def test_en
25
+ I18n.i18n "en"
26
+ assert_equal I18n.t("image"), "Figure "
27
+ assert_equal I18n.t("table"), "Table "
28
+ assert_equal I18n.t("chapter", 1), "Chapter 1"
29
+ assert_equal I18n.t("etc"), "etc"
30
+ end
31
+
32
+ def test_nil
33
+ I18n.i18n "nil"
34
+ assert_equal I18n.t("image"), "image"
35
+ assert_equal I18n.t("table"), "table"
36
+ assert_equal I18n.t("etc"), "etc"
37
+ end
38
+
39
+ def test_htmlbuilder
40
+ _setup_htmlbuilder
41
+ @builder.headline(1,"test","this is test.")
42
+ assert_equal %Q|<h1 id="test"><a id="h1"></a>Chapter 1. this is test.</h1>\n|, @builder.raw_result
43
+ end
44
+
45
+ def _setup_htmlbuilder
46
+ I18n.i18n "en"
47
+ @builder = HTMLBuilder.new()
48
+ @param = {
49
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
50
+ "inencoding" => "UTF-8",
51
+ "outencoding" => "UTF-8",
52
+ "stylesheet" => nil, # for HTMLBuilder
53
+ }
54
+ ReVIEW.book.param = @param
55
+ @compiler = ReVIEW::Compiler.new(@builder)
56
+ @chapter = Book::Chapter.new(nil, 1, '-', nil, StringIO.new)
57
+ location = Location.new(nil, nil)
58
+ @builder.bind(@compiler, @chapter, location)
59
+ end
60
+
61
+ def teardown
62
+ I18n.i18n "ja"
63
+ end
64
+ end
@@ -0,0 +1,589 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'review/compiler'
5
+ require 'review/book'
6
+ require 'review/idgxmlbuilder'
7
+
8
+ class IDGXMLBuidlerTest < Test::Unit::TestCase
9
+ include ReVIEW
10
+
11
+ def setup
12
+ @builder = IDGXMLBuilder.new()
13
+ @param = {
14
+ "secnolevel" => 2,
15
+ "inencoding" => "UTF-8",
16
+ "outencoding" => "UTF-8",
17
+ "nolf" => true,
18
+ "tableopt" => "10",
19
+ "subdirmode" => nil,
20
+ }
21
+ ReVIEW.book.param = @param
22
+ @compiler = ReVIEW::Compiler.new(@builder)
23
+ @chapter = Book::Chapter.new(nil, 1, '-', nil, StringIO.new)
24
+ location = Location.new(nil, nil)
25
+ @builder.bind(@compiler, @chapter, location)
26
+ end
27
+
28
+ def test_headline_level1
29
+ @builder.headline(1,"test","this is test.")
30
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h1">第1章 this is test.</title><?dtp level="1" section="第1章 this is test."?>|, @builder.raw_result
31
+ end
32
+
33
+ def test_headline_level1_without_secno
34
+ @param["secnolevel"] = 0
35
+ @builder.headline(1,"test","this is test.")
36
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h1">this is test.</title><?dtp level="1" section="this is test."?>|, @builder.raw_result
37
+ end
38
+
39
+ def test_headline_level2
40
+ @builder.headline(2,"test","this is test.")
41
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h2">1.1 this is test.</title><?dtp level="2" section="1.1 this is test."?>|, @builder.raw_result
42
+ end
43
+
44
+ def test_headline_level3
45
+ @builder.headline(3,"test","this is test.")
46
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h3">this is test.</title><?dtp level="3" section="this is test."?>|, @builder.raw_result
47
+ end
48
+
49
+
50
+ def test_headline_level3_with_secno
51
+ @param["secnolevel"] = 3
52
+ @builder.headline(3,"test","this is test.")
53
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h3">1.0.1 this is test.</title><?dtp level="3" section="1.0.1 this is test."?>|, @builder.raw_result
54
+ end
55
+
56
+ def test_label
57
+ @builder.label("label_test")
58
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><label id='label_test' />|, @builder.raw_result
59
+ end
60
+
61
+ def test_inline_ref
62
+ ret = @builder.compile_inline("@<ref>{外部参照<>&}")
63
+ assert_equal %Q|<ref idref='外部参照&lt;&gt;&amp;'>「●● 外部参照&lt;&gt;&amp;」</ref>|, ret
64
+ end
65
+
66
+ def test_href
67
+ ret = @builder.compile_href("http://github.com", "GitHub")
68
+ assert_equal %Q|<a linkurl='http://github.com'>GitHub</a>|, ret
69
+ end
70
+
71
+ def test_href_without_label
72
+ ret = @builder.compile_href("http://github.com",nil)
73
+ assert_equal %Q|<a linkurl='http://github.com'>http://github.com</a>|, ret
74
+ end
75
+
76
+ def test_inline_href
77
+ ret = @builder.inline_href("http://github.com, Git\\,Hub")
78
+ assert_equal %Q|<a linkurl='http://github.com'>Git,Hub</a>|, ret
79
+ end
80
+
81
+ def test_inline_raw
82
+ ret = @builder.inline_raw("@<tt>{inline}")
83
+ assert_equal %Q|@<tt>{inline}|, ret
84
+ end
85
+
86
+ def test_inline_in_table
87
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
88
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><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>&lt;&gt;&amp;</td></tbody></table>|, @builder.raw_result
89
+ end
90
+
91
+ def test_inline_in_table_without_header
92
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
93
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><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>&lt;&gt;&amp;</td></tbody></table>|, @builder.raw_result
94
+ end
95
+
96
+ def test_inline_in_table_without_cellwidth
97
+ @param["tableopt"] = nil
98
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
99
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody><tr type="header"><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i>&lt;&gt;&amp;</tr></tbody></table>|, @builder.raw_result
100
+ @param["tableopt"] = 10
101
+ end
102
+
103
+ def test_inline_in_table_without_header_and_cellwidth
104
+ @param["tableopt"] = nil
105
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
106
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody><tr><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i>&lt;&gt;&amp;</tr></tbody></table>|, @builder.raw_result
107
+ @param["tableopt"] = 10
108
+ end
109
+
110
+ def test_inline_br
111
+ ret = @builder.inline_br("")
112
+ assert_equal %Q|\n|, ret
113
+ end
114
+
115
+ def test_inline_uchar
116
+ ret = @builder.compile_inline("test @<uchar>{2460} test2")
117
+ assert_equal %Q|test &#x2460; test2|, ret
118
+ end
119
+
120
+ def test_inline_ruby
121
+ ret = @builder.compile_ruby("coffin", "bed")
122
+ assert_equal %Q|<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>coffin</aid:rb><aid:rt>bed</aid:rt></aid:ruby></GroupRuby>|, ret
123
+ end
124
+
125
+ def test_inline_kw
126
+ ret = @builder.compile_inline("@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}")
127
+ assert_equal %Q|<keyword>ISO(International Organization for Standardization)</keyword><index value="ISO" /><index value="International Organization for Standardization" /> <keyword>Ruby&lt;&gt;</keyword><index value="Ruby&lt;&gt;" />|, ret
128
+ end
129
+
130
+ def test_inline_maru
131
+ ret = @builder.compile_inline("@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}")
132
+ assert_equal %Q|&#x2460;&#x2473;&#x24b6;&#x24e9;|, ret
133
+ end
134
+
135
+ def test_inline_ttb
136
+ ret = @builder.inline_ttb("test * <>\"")
137
+ assert_equal %Q|<tt style='bold'>test * &lt;&gt;&quot;</tt><index value='test ESCAPED_ASTERISK &lt;&gt;&quot;' />|, ret
138
+ end
139
+
140
+ def test_inline_ttbold
141
+ ret = @builder.inline_ttbold("test * <>\"")
142
+ assert_equal %Q|<tt style='bold'>test * &lt;&gt;&quot;</tt><index value='test ESCAPED_ASTERISK &lt;&gt;&quot;' />|, ret
143
+ end
144
+
145
+ def test_inline_balloon
146
+ ret = @builder.inline_balloon("@maru[1]test")
147
+ assert_equal %Q|<balloon>&#x2460;test</balloon>|, ret
148
+ end
149
+
150
+ def test_inline_m
151
+ ret = @builder.compile_inline("@<m>{\\sin} @<m>{\\frac{1\\}{2\\}}")
152
+ assert_equal %Q|<replace idref="texinline-1"><pre>\\sin</pre></replace> <replace idref="texinline-2"><pre>\\frac{1}{2}</pre></replace>|, ret
153
+ end
154
+
155
+ def test_paragraph
156
+ lines = ["foo","bar"]
157
+ @builder.paragraph(lines)
158
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p>foobar</p>|, @builder.raw_result
159
+ end
160
+
161
+ def test_tabbed_paragraph
162
+ lines = ["\tfoo","bar"]
163
+ @builder.paragraph(lines)
164
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p inlist="1">foobar</p>|, @builder.raw_result
165
+ end
166
+
167
+ def test_quote
168
+ lines = ["foo","bar","","buz"]
169
+ @builder.quote(lines)
170
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><quote><p>foobar</p><p>buz</p></quote>|, @builder.raw_result
171
+ end
172
+
173
+ def test_quote_deprecated
174
+ lines = ["foo","","buz"]
175
+ ReVIEW.book.param["deprecated-blocklines"] = true
176
+ @builder.quote(lines)
177
+ ReVIEW.book.param["deprecated-blocklines"] = nil
178
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><quote>foo\n\nbuz</quote>|, @builder.raw_result
179
+ end
180
+
181
+ def test_note
182
+ @builder.note(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
183
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><note><title aid:pstyle='note-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></note>|, @builder.raw_result
184
+ end
185
+
186
+ def test_memo
187
+ @builder.memo(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
188
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><memo><title aid:pstyle='memo-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></memo>|, @builder.raw_result
189
+ end
190
+
191
+ def test_term
192
+ @builder.term(["test1", "test1.5", "", "test<i>2</i>"])
193
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><term><p>test1test1.5</p><p>test<i>2</i></p></term>|, @builder.raw_result
194
+ end
195
+
196
+ def test_term_deprecated
197
+ ReVIEW.book.param["deprecated-blocklines"] = true
198
+ @builder.term(["test1", "test1.5", "", "test<i>2</i>"])
199
+ ReVIEW.book.param["deprecated-blocklines"] = nil
200
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><term>test1\ntest1.5\n\ntest<i>2</i></term>|, @builder.raw_result
201
+ end
202
+
203
+ def test_notice
204
+ @builder.notice(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
205
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><notice-t><title aid:pstyle='notice-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></notice-t>|, @builder.raw_result
206
+ end
207
+
208
+ def test_notice_without_caption
209
+ @builder.notice(["test1", "test1.5", "", "test<i>2</i>"], nil)
210
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><notice><p>test1test1.5</p><p>test<i>2</i></p></notice>|, @builder.raw_result
211
+ end
212
+
213
+ def test_point
214
+ @builder.point(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
215
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><point-t><title aid:pstyle='point-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></point-t>|, @builder.raw_result
216
+ end
217
+
218
+ def test_point_without_caption
219
+ @builder.point(["test1", "test1.5", "", "test<i>2</i>"], nil)
220
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><point><p>test1test1.5</p><p>test<i>2</i></p></point>|, @builder.raw_result
221
+ end
222
+
223
+ def test_emlist
224
+ @builder.emlist(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
225
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>|, @builder.raw_result
226
+ end
227
+
228
+ def test_emlist_listinfo
229
+ @param["listinfo"] = true
230
+ @builder.emlist(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
231
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></pre></list>|, @builder.raw_result
232
+ end
233
+
234
+ def test_emlist_with_tab
235
+ @builder.emlist(["\ttest1", "\t\ttest1.5", "", "\ttest<i>2</i>"], "this is @<b>{test}<&>_")
236
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre> test1\n test1.5\n\n test<i>2</i>\n</pre></list>|, @builder.raw_result
237
+ end
238
+
239
+ def test_emlist_with_4tab
240
+ @builder.instance_eval{@tabwidth=4}
241
+ @builder.emlist(["\ttest1", "\t\ttest1.5", "", "\ttest<i>2</i>"], "this is @<b>{test}<&>_")
242
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre> test1\n test1.5\n\n test<i>2</i>\n</pre></list>|, @builder.raw_result
243
+ end
244
+
245
+ def test_list
246
+ def @chapter.list(id)
247
+ Book::ListIndex::Item.new("samplelist",1)
248
+ end
249
+ @builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_")
250
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></codelist>|, @builder.raw_result
251
+ end
252
+
253
+ def test_list_listinfo
254
+ def @chapter.list(id)
255
+ Book::ListIndex::Item.new("samplelist",1)
256
+ end
257
+ @param["listinfo"] = true
258
+ @builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_")
259
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></pre></codelist>|, @builder.raw_result
260
+ end
261
+
262
+ def test_insn
263
+ @param["listinfo"] = true
264
+ @builder.insn(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
265
+ @param["listinfo"] = nil
266
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><insn><floattitle type="insn">this is <b>test</b>&lt;&amp;&gt;_</floattitle><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></insn>|, @builder.raw_result
267
+ end
268
+
269
+ def test_box
270
+ @param["listinfo"] = true
271
+ @builder.box(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
272
+ @param["listinfo"] = nil
273
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><box><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></box>|, @builder.raw_result
274
+ end
275
+
276
+ def test_flushright
277
+ @builder.flushright(["foo", "bar", "","buz"])
278
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p align='right'>foobar</p><p align='right'>buz</p>|, @builder.raw_result
279
+ end
280
+
281
+ def test_centering
282
+ @builder.centering(["foo", "bar", "","buz"])
283
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p align='center'>foobar</p><p align='center'>buz</p>|, @builder.raw_result
284
+ end
285
+
286
+ def test_noindent
287
+ @builder.noindent
288
+ @builder.paragraph(["foo", "bar"])
289
+ @builder.paragraph(["foo2", "bar2"])
290
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>|, @builder.raw_result
291
+ end
292
+
293
+ def test_image
294
+ def @chapter.image(id)
295
+ item = Book::ImageIndex::Item.new("sampleimg",1)
296
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
297
+ item
298
+ end
299
+
300
+ @builder.image_image("sampleimg","sample photo",nil)
301
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result
302
+ end
303
+
304
+ def test_image_with_metric
305
+ def @chapter.image(id)
306
+ item = Book::ImageIndex::Item.new("sampleimg",1)
307
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
308
+ item
309
+ end
310
+
311
+ @builder.image_image("sampleimg","sample photo","scale=1.2")
312
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result
313
+ end
314
+
315
+ def test_image_with_metric2
316
+ def @chapter.image(id)
317
+ item = Book::ImageIndex::Item.new("sampleimg",1)
318
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
319
+ item
320
+ end
321
+
322
+ @builder.image_image("sampleimg","sample photo","scale=1.2, html::class=\"sample\", latex::ignore=params, idgxml::ostyle=object")
323
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result
324
+ end
325
+
326
+ def test_indepimage
327
+ def @chapter.image(id)
328
+ item = Book::ImageIndex::Item.new("sampleimg",1)
329
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
330
+ item
331
+ end
332
+
333
+ @builder.indepimage("sampleimg","sample photo",nil)
334
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>|, @builder.raw_result
335
+ end
336
+
337
+ def test_indepimage_without_caption
338
+ def @chapter.image(id)
339
+ item = Book::ImageIndex::Item.new("sampleimg",1)
340
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
341
+ item
342
+ end
343
+
344
+ @builder.indepimage("sampleimg",nil,nil)
345
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /></img>|, @builder.raw_result
346
+ end
347
+
348
+ def test_indepimage_with_metric
349
+ def @chapter.image(id)
350
+ item = Book::ImageIndex::Item.new("sampleimg",1)
351
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
352
+ item
353
+ end
354
+
355
+ @builder.indepimage("sampleimg","sample photo","scale=1.2")
356
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>|, @builder.raw_result
357
+ end
358
+
359
+ def test_indepimage_with_metric2
360
+ def @chapter.image(id)
361
+ item = Book::ImageIndex::Item.new("sampleimg",1)
362
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
363
+ item
364
+ end
365
+
366
+ @builder.indepimage("sampleimg","sample photo","scale=1.2, html::class=\"sample\", latex::ignore=params, idgxml::ostyle=\"object\"")
367
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>sample photo</caption></img>|, @builder.raw_result
368
+ end
369
+
370
+ def test_indepimage_without_caption_but_with_metric
371
+ def @chapter.image(id)
372
+ item = Book::ImageIndex::Item.new("sampleimg",1)
373
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
374
+ item
375
+ end
376
+
377
+ @builder.indepimage("sampleimg",nil,"scale=1.2")
378
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /></img>|, @builder.raw_result
379
+ end
380
+
381
+ def column_helper(review)
382
+ chap_singleton = class << @chapter; self; end
383
+ chap_singleton.send(:define_method, :content) { review }
384
+ @compiler.compile(@chapter)
385
+ end
386
+
387
+ def test_column_1
388
+ review =<<-EOS
389
+ ===[column] prev column
390
+
391
+ inside prev column
392
+
393
+ ===[column] test
394
+
395
+ inside column
396
+
397
+ ===[/column]
398
+ EOS
399
+ expect =<<-EOS
400
+ <?xml version="1.0" encoding="UTF-8"?>
401
+ <doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column><title aid:pstyle="column-title">prev column</title><p>inside prev column</p></column><column><title aid:pstyle="column-title">test</title><p>inside column</p></column></doc>
402
+ EOS
403
+ assert_equal expect, column_helper(review)
404
+ end
405
+
406
+ def test_column_2
407
+ review =<<-EOS
408
+ ===[column] test
409
+
410
+ inside column
411
+
412
+ === next level
413
+ EOS
414
+ expect =<<-EOS
415
+ <?xml version="1.0" encoding="UTF-8"?>
416
+ <doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column><title aid:pstyle="column-title">test</title><p>inside column</p></column><title aid:pstyle=\"h3\">next level</title><?dtp level="3" section="next level"?></doc>
417
+ EOS
418
+
419
+ assert_equal expect, column_helper(review)
420
+ end
421
+
422
+ def test_column_3
423
+ review =<<-EOS
424
+ ===[column] test
425
+
426
+ inside column
427
+
428
+ ===[/column_dummy]
429
+ EOS
430
+ assert_raise(ReVIEW::CompileError) do
431
+ column_helper(review)
432
+ end
433
+ end
434
+
435
+ def test_ul
436
+ src =<<-EOS
437
+ * AAA
438
+ * BBB
439
+ EOS
440
+
441
+ expect =<<-EOS
442
+ <?xml version="1.0" encoding="UTF-8"?>
443
+ <doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><ul><li aid:pstyle="ul-item">AAA</li><li aid:pstyle="ul-item">BBB</li></ul>
444
+ EOS
445
+ ul_helper(src, expect.chomp)
446
+ end
447
+
448
+ def test_ul_cont
449
+ src =<<-EOS
450
+ * AAA
451
+ -AA
452
+ * BBB
453
+ -BB
454
+ EOS
455
+
456
+ expect =<<-EOS
457
+ <?xml version="1.0" encoding="UTF-8"?>
458
+ <doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
459
+ EOS
460
+ ul_helper(src, expect.chomp)
461
+ end
462
+
463
+ def test_ul_nest1
464
+ src =<<-EOS
465
+ * AAA
466
+ ** AA
467
+ EOS
468
+
469
+ expect =<<-EOS
470
+ <?xml version="1.0" encoding="UTF-8"?>
471
+ <doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li></ul>
472
+ EOS
473
+ ul_helper(src, expect.chomp)
474
+ end
475
+
476
+ def test_ul_nest2
477
+ src =<<-EOS
478
+ * AAA
479
+ ** AA
480
+ * BBB
481
+ ** BB
482
+ EOS
483
+
484
+ expect =<<-EOS
485
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li><li aid:pstyle="ul-item">BBB<ul2><li aid:pstyle="ul-item">BB</li></ul2></li></ul>
486
+ EOS
487
+ ul_helper(src, expect.chomp)
488
+ end
489
+
490
+ def test_ul_nest3
491
+ src =<<-EOS
492
+ ** AAA
493
+ * AA
494
+ * BBB
495
+ ** BB
496
+ EOS
497
+
498
+ expect =<<-EOS
499
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><ul><li aid:pstyle="ul-item"><ul2><li aid:pstyle="ul-item">AAA</li></ul2></li><li aid:pstyle="ul-item">AA</li><li aid:pstyle="ul-item">BBB<ul2><li aid:pstyle="ul-item">BB</li></ul2></li></ul>
500
+ EOS
501
+ ul_helper(src, expect.chomp)
502
+ end
503
+
504
+ def test_ul_nest4
505
+ src =<<-EOS
506
+ * A
507
+ ** B
508
+ ** C
509
+ *** D
510
+ ** E
511
+ * F
512
+ ** G
513
+ EOS
514
+
515
+ expect =<<-EOS
516
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><ul><li aid:pstyle="ul-item">A<ul2><li aid:pstyle="ul-item">B</li><li aid:pstyle="ul-item">C<ul3><li aid:pstyle="ul-item">D</li></ul3></li><li aid:pstyle="ul-item">E</li></ul2></li><li aid:pstyle="ul-item">F<ul2><li aid:pstyle="ul-item">G</li></ul2></li></ul>
517
+ EOS
518
+ ul_helper(src, expect.chomp)
519
+ end
520
+
521
+ def test_inline_raw0
522
+ assert_equal "normal", @builder.inline_raw("normal")
523
+ end
524
+
525
+ def test_inline_raw1
526
+ assert_equal "body", @builder.inline_raw("|idgxml|body")
527
+ end
528
+
529
+ def test_inline_raw2
530
+ assert_equal "body", @builder.inline_raw("|idgxml, latex|body")
531
+ end
532
+
533
+ def test_inline_raw3
534
+ assert_equal "", @builder.inline_raw("|latex, html|body")
535
+ end
536
+
537
+ def test_inline_raw4
538
+ assert_equal "|idgxml body", @builder.inline_raw("|idgxml body")
539
+ end
540
+
541
+ def test_inline_raw5
542
+ assert_equal "nor\nmal", @builder.inline_raw("|idgxml|nor\\nmal")
543
+ end
544
+
545
+ def test_block_raw0
546
+ @builder.raw("<>!\"\\n& ")
547
+ expect =<<-EOS
548
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!"
549
+ &
550
+ EOS
551
+ assert_equal expect.chomp, @builder.raw_result
552
+ end
553
+
554
+ def test_block_raw1
555
+ @builder.raw("|idgxml|<>!\"\\n& ")
556
+ expect =<<-EOS
557
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!"
558
+ &
559
+ EOS
560
+ assert_equal expect.chomp, @builder.raw_result
561
+ end
562
+
563
+ def test_block_raw2
564
+ @builder.raw("|idgxml, latex|<>!\"\\n& ")
565
+ expect =<<-EOS
566
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"
567
+ &
568
+ EOS
569
+ assert_equal expect.chomp, @builder.raw_result
570
+ end
571
+
572
+ def test_block_raw3
573
+ @builder.raw("|latex, html|<>!\"\\n& ")
574
+ expect =<<-EOS
575
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">
576
+ EOS
577
+ assert_equal expect.chomp, @builder.raw_result
578
+ end
579
+
580
+ def test_block_raw4
581
+ @builder.raw("|idgxml <>!\"\\n& ")
582
+ expect =<<-EOS
583
+ <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">|idgxml <>!\"
584
+ &
585
+ EOS
586
+ assert_equal expect.chomp, @builder.raw_result
587
+ end
588
+
589
+ end