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,31 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'review/book'
5
+ require 'review/book/index'
6
+
7
+ class IndexTest < Test::Unit::TestCase
8
+ include ReVIEW
9
+ def test_footnote_index
10
+ fn = Book::FootnoteIndex.parse(['//footnote[foo][bar]'])
11
+ items = fn.to_a
12
+ item = items[0]
13
+ assert_equal 'foo', item.id
14
+ assert_equal 'bar', item.content
15
+ end
16
+ def test_footnote_index_with_escape
17
+ fn = Book::FootnoteIndex.parse(['//footnote[foo][bar[\]buz]'])
18
+ items = fn.to_a
19
+ item = items[0]
20
+ assert_equal 'foo', item.id
21
+ assert_equal 'bar[]buz', item.content
22
+ end
23
+ def test_footnote_index_with_escape2
24
+ fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
25
+ items = fn.to_a
26
+ item = items[0]
27
+ assert_equal 'foo', item.id
28
+ assert_equal 'bar\\a\\$buz', item.content
29
+ end
30
+ end
31
+
@@ -0,0 +1,656 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test_helper'
3
+ require 'review/compiler'
4
+ require 'review/book'
5
+ require 'review/latexbuilder'
6
+
7
+ class LATEXBuidlerTest < Test::Unit::TestCase
8
+ include ReVIEW
9
+
10
+ def setup
11
+ @builder = LATEXBuilder.new()
12
+ @param = {
13
+ "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
14
+ "toclevel" => 2,
15
+ "inencoding" => "UTF-8",
16
+ "outencoding" => "UTF-8",
17
+ "subdirmode" => nil,
18
+ "stylesheet" => nil, # for EPUBBuilder
19
+ }
20
+ ReVIEW.book.param = @param
21
+ @compiler = ReVIEW::Compiler.new(@builder)
22
+ @chapter = Book::Chapter.new(nil, 1, 'chap1', nil, StringIO.new)
23
+ location = Location.new(nil, nil)
24
+ @builder.bind(@compiler, @chapter, location)
25
+ end
26
+
27
+ def test_headline_level1
28
+ @builder.headline(1,"test","this is test.")
29
+ assert_equal %Q|\\chapter{this is test.}\n\\label{chap:chap1}\n|, @builder.result
30
+ end
31
+
32
+ def test_headline_level1_without_secno
33
+ @param["secnolevel"] = 0
34
+ @builder.headline(1,"test","this is test.")
35
+ assert_equal %Q|\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n|, @builder.result
36
+ end
37
+
38
+ def test_headline_level1_with_inlinetag
39
+ @builder.headline(1,"test","this @<b>{is} test.<&\"_>")
40
+ assert_equal %Q|\\chapter{this \\textbf{is} test.\\textless{}\\&\"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n|, @builder.result
41
+ end
42
+
43
+ def test_headline_level2
44
+ @builder.headline(2,"test","this is test.")
45
+ assert_equal %Q|\\section{this is test.}\n|, @builder.result
46
+ end
47
+
48
+ def test_headline_level3
49
+ @builder.headline(3,"test","this is test.")
50
+ assert_equal %Q|\\subsection*{this is test.}\n|, @builder.result
51
+ end
52
+
53
+
54
+ def test_headline_level3_with_secno
55
+ @param["secnolevel"] = 3
56
+ @builder.headline(3,"test","this is test.")
57
+ assert_equal %Q|\\subsection{this is test.}\n|, @builder.result
58
+ end
59
+
60
+ def test_label
61
+ @builder.label("label_test")
62
+ assert_equal %Q|\\label{label_test}\n|, @builder.result
63
+ end
64
+
65
+ def test_href
66
+ ret = @builder.compile_inline('@<href>{http://github.com,GitHub}')
67
+ assert_equal %Q|\\href{http://github.com}{GitHub}|, ret
68
+ end
69
+
70
+ def test_inline_href
71
+ ret = @builder.compile_inline('@<href>{http://github.com,Git\\,Hub}')
72
+ assert_equal %Q|\\href{http://github.com}{Git,Hub}|, ret
73
+ end
74
+
75
+ def test_href_without_label
76
+ ret = @builder.compile_inline('@<href>{http://github.com}')
77
+ assert_equal %Q|\\url{http://github.com}|, ret
78
+ end
79
+
80
+ def test_href_with_underscore
81
+ ret = @builder.compile_inline('@<href>{http://example.com/aaa/bbb, AAA_BBB}')
82
+ assert_equal %Q|\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}|, ret
83
+ end
84
+
85
+ def test_href_mailto
86
+ ret = @builder.compile_inline('@<href>{mailto:takahashim@example.com, takahashim@example.com}')
87
+ assert_equal %Q|\\href{mailto:takahashim@example.com}{takahashim@example.com}|, ret
88
+ end
89
+
90
+ def test_inline_br
91
+ ret = @builder.inline_br("")
92
+ assert_equal %Q|\\\\\n|, ret
93
+ end
94
+
95
+ def test_inline_br_with_other_strings
96
+ ret = @builder.compile_inline("abc@<br>{}def")
97
+ assert_equal %Q|abc\\\\\ndef|, ret
98
+ end
99
+
100
+ def test_inline_u
101
+ ret = @builder.compile_inline("abc@<u>{def}ghi")
102
+ assert_equal %Q|abc\\Underline{def}ghi|, ret
103
+ end
104
+
105
+ def test_inline_i
106
+ ret = @builder.compile_inline("abc@<i>{def}ghi")
107
+ assert_equal %Q|abc\\textit{def}ghi|, ret
108
+ end
109
+
110
+ def test_inline_i_and_escape
111
+ ret = @builder.compile_inline("test @<i>{inline<&;\\ test} test2")
112
+ assert_equal %Q|test \\textit{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, ret
113
+ end
114
+
115
+ def test_inline_dtp
116
+ ret = @builder.compile_inline("abc@<dtp>{def}ghi")
117
+ assert_equal %Q|abcghi|, ret
118
+ end
119
+
120
+ def test_inline_code
121
+ ret = @builder.compile_inline("abc@<code>{def}ghi")
122
+ assert_equal %Q|abc\\texttt{def}ghi|, ret
123
+ end
124
+
125
+ def test_inline_raw
126
+ ret = @builder.compile_inline("@<raw>{@<tt>{inline!$%\\}}")
127
+ assert_equal "@<tt>{inline!$%}", ret
128
+ end
129
+
130
+ def test_inline_sup
131
+ ret = @builder.compile_inline("abc@<sup>{def}")
132
+ assert_equal %Q|abc\\textsuperscript{def}|, ret
133
+ end
134
+
135
+ def test_inline_sub
136
+ ret = @builder.compile_inline("abc@<sub>{def}")
137
+ assert_equal %Q|abc\\textsubscript{def}|, ret
138
+ end
139
+
140
+ def test_inline_b
141
+ ret = @builder.compile_inline("abc@<b>{def}")
142
+ assert_equal %Q|abc\\textbf{def}|, ret
143
+ end
144
+
145
+ def test_inline_b_and_escape
146
+ ret = @builder.compile_inline("test @<b>{inline<&;\\ test} test2")
147
+ assert_equal %Q|test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, ret
148
+ end
149
+ def test_inline_em
150
+ ret = @builder.compile_inline("abc@<em>{def}")
151
+ assert_equal %Q|abc\\reviewem{def}|, ret
152
+ end
153
+
154
+ def test_inline_strong
155
+ ret = @builder.compile_inline("abc@<strong>{def}")
156
+ assert_equal %Q|abc\\reviewstrong{def}|, ret
157
+ end
158
+
159
+ def test_inline_u
160
+ ret = @builder.compile_inline("abc@<u>{def}ghi")
161
+ assert_equal %Q|abc\\Underline{def}ghi|, ret
162
+ end
163
+
164
+ def test_inline_m
165
+ ret = @builder.compile_inline("abc@<m>{\\alpha^n = \inf < 2}ghi")
166
+ assert_equal "abc $\\alpha^n = inf < 2$ ghi", ret
167
+ end
168
+
169
+ def test_inline_tt
170
+ ret = @builder.compile_inline("test @<tt>{inline test} test2")
171
+ assert_equal %Q|test \\texttt{inline test} test2|, ret
172
+ end
173
+
174
+ def test_inline_tt_endash
175
+ ret = @builder.compile_inline("test @<tt>{in-line --test ---foo ----bar -----buz} --test2")
176
+ assert_equal %Q|test \\texttt{in{-}line {-}{-}test {-}{-}{-}foo {-}{-}{-}{-}bar {-}{-}{-}{-}{-}buz} {-}{-}test2|, ret
177
+ end
178
+
179
+ def test_inline_tti
180
+ ret = @builder.compile_inline("test @<tti>{inline test} test2")
181
+ assert_equal %Q|test \\texttt{\\textit{inline test}} test2|, ret
182
+ end
183
+
184
+ def test_inline_ttb
185
+ ret = @builder.compile_inline("test @<ttb>{inline test} test2")
186
+ assert_equal %Q|test \\texttt{\\textbf{inline test}} test2|, ret
187
+ end
188
+
189
+ def test_inline_hd_chap
190
+ def @chapter.headline_index
191
+ items = [Book::HeadlineIndex::Item.new("chap1|test", [1, 1], "te_st")]
192
+ Book::HeadlineIndex.new(items, self)
193
+ end
194
+
195
+ ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
196
+ assert_equal %Q|test 「1.1.1 te\\textunderscore{}st」 test2|, ret
197
+ end
198
+
199
+ def test_inline_uchar
200
+ ret = @builder.compile_inline("test @<uchar>{2460} test2")
201
+ assert_equal %Q|test \\UTF{2460} test2|, ret
202
+ end
203
+
204
+ def test_dlist
205
+ @builder.dl_begin
206
+ @builder.dt "foo"
207
+ @builder.dd ["foo.\n", "bar.\n"]
208
+ @builder.dl_end
209
+ assert_equal %Q|\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\nbar.\n\\end{description}\n|, @builder.result
210
+ end
211
+
212
+ def test_dlist_with_bracket
213
+ @builder.dl_begin
214
+ @builder.dt "foo[bar]"
215
+ @builder.dd ["foo.\n", "bar.\n"]
216
+ @builder.dl_end
217
+ assert_equal %Q|\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.\nbar.\n\\end{description}\n|, @builder.result
218
+ end
219
+
220
+ def test_cmd
221
+ lines = ["foo", "bar", "","buz"]
222
+ @builder.cmd(lines)
223
+ assert_equal %Q|\n\\begin{reviewcmd}\n\\begin{alltt}\nfoo\nbar\n\nbuz\n\\end{alltt}\n\\end{reviewcmd}\n|, @builder.result
224
+ end
225
+
226
+ def test_cmd_caption
227
+ lines = ["foo", "bar", "","buz"]
228
+ @builder.cmd(lines, "cap1")
229
+ assert_equal %Q|\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\n\\begin{alltt}\nfoo\nbar\n\nbuz\n\\end{alltt}\n\\end{reviewcmd}\n|, @builder.result
230
+ end
231
+
232
+ def test_emlist
233
+ lines = ["foo", "bar", "","buz"]
234
+ @builder.emlist(lines)
235
+ assert_equal %Q|\n\\begin{reviewemlist}\n\\begin{alltt}\nfoo\nbar\n\nbuz\n\\end{alltt}\n\\end{reviewemlist}\n|, @builder.result
236
+ end
237
+
238
+ def test_emlist_caption
239
+ lines = ["foo", "bar", "","buz"]
240
+ @builder.emlist(lines, "cap1")
241
+ assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n\\begin{alltt}\nfoo\nbar\n\nbuz\n\\end{alltt}\n\\end{reviewemlist}\n|, @builder.result
242
+ end
243
+
244
+ def test_emlist_with_tab
245
+ lines = ["\tfoo", "\t\tbar", "","\tbuz"]
246
+ @builder.emlist(lines)
247
+ assert_equal %Q|\n\\begin{reviewemlist}\n\\begin{alltt}\n foo\n bar\n\n buz\n\\end{alltt}\n\\end{reviewemlist}\n|, @builder.result
248
+ end
249
+
250
+ def test_emlist_with_tab4
251
+ lines = ["\tfoo", "\t\tbar", "","\tbuz"]
252
+ @builder.instance_eval{@tabwidth=4}
253
+ @builder.emlist(lines)
254
+ assert_equal %Q|\n\\begin{reviewemlist}\n\\begin{alltt}\n foo\n bar\n\n buz\n\\end{alltt}\n\\end{reviewemlist}\n|, @builder.result
255
+ end
256
+
257
+ def test_quote
258
+ lines = ["foo", "bar", "","buz"]
259
+ @builder.quote(lines)
260
+ assert_equal %Q|\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n|, @builder.result
261
+ end
262
+
263
+ def test_memo
264
+ @builder.memo(["test1", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
265
+ assert_equal %Q|\\begin{reviewminicolumn}\n\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}\ntest1\n\ntest<i>2</i>\n\\end{reviewminicolumn}\n|, @builder.result
266
+ end
267
+
268
+ def test_flushright
269
+ @builder.flushright(["foo", "bar", "","buz"])
270
+ assert_equal %Q|\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n|, @builder.raw_result
271
+ end
272
+
273
+ def test_centering
274
+ @builder.centering(["foo", "bar", "","buz"])
275
+ assert_equal %Q|\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n|, @builder.raw_result
276
+ end
277
+
278
+ def test_noindent
279
+ @builder.noindent
280
+ @builder.paragraph(["foo", "bar"])
281
+ @builder.paragraph(["foo2", "bar2"])
282
+ assert_equal %Q|\\noindent\nfoo\nbar\n\nfoo2\nbar2\n|, @builder.raw_result
283
+ end
284
+
285
+ def test_image
286
+ def @chapter.image(id)
287
+ item = Book::ImageIndex::Item.new("sampleimg",1)
288
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
289
+ item
290
+ end
291
+
292
+ @builder.image_image("sampleimg","sample photo",nil)
293
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, @builder.raw_result
294
+ end
295
+
296
+ def test_image_with_metric
297
+ def @chapter.image(id)
298
+ item = Book::ImageIndex::Item.new("sampleimg",1)
299
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
300
+ item
301
+ end
302
+
303
+ @builder.image_image("sampleimg","sample photo","scale=1.2")
304
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, @builder.raw_result
305
+ end
306
+
307
+ def test_image_with_metric2
308
+ def @chapter.image(id)
309
+ item = Book::ImageIndex::Item.new("sampleimg",1)
310
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
311
+ item
312
+ end
313
+
314
+ @builder.image_image("sampleimg","sample photo","scale=1.2, html::class=\"sample\", latex::height=3cm")
315
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,height=3cm]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, @builder.raw_result
316
+ end
317
+
318
+ def test_indepimage
319
+ def @chapter.image(id)
320
+ item = Book::ImageIndex::Item.new("sampleimg",1)
321
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
322
+ item
323
+ end
324
+
325
+ @builder.indepimage("sampleimg","sample photo",nil)
326
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
327
+ end
328
+
329
+ def test_indepimage_without_caption
330
+ def @chapter.image(id)
331
+ item = Book::ImageIndex::Item.new("sampleimg",1)
332
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
333
+ item
334
+ end
335
+
336
+ # FIXME: indepimage's caption should not be with a counter.
337
+ @builder.indepimage("sampleimg",nil,nil)
338
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, @builder.raw_result
339
+ end
340
+
341
+ def test_indepimage_with_metric
342
+ def @chapter.image(id)
343
+ item = Book::ImageIndex::Item.new("sampleimg",1)
344
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
345
+ item
346
+ end
347
+
348
+ @builder.indepimage("sampleimg","sample photo","scale=1.2")
349
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
350
+ end
351
+
352
+ def test_indepimage_with_metric2
353
+ def @chapter.image(id)
354
+ item = Book::ImageIndex::Item.new("sampleimg",1)
355
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
356
+ item
357
+ end
358
+
359
+ @builder.indepimage("sampleimg","sample photo","scale=1.2, latex::height=3cm, html::class=\"sample\"")
360
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,height=3cm]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
361
+ end
362
+
363
+ def test_indepimage_without_caption_but_with_metric
364
+ def @chapter.image(id)
365
+ item = Book::ImageIndex::Item.new("sampleimg",1)
366
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
367
+ item
368
+ end
369
+
370
+ # FIXME: indepimage's caption should not be with a counter.
371
+ @builder.indepimage("sampleimg",nil,"scale=1.2")
372
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, @builder.raw_result
373
+ end
374
+
375
+ def test_bib
376
+ def @chapter.bibpaper(id)
377
+ Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
378
+ end
379
+
380
+ assert_equal "[1]", @builder.inline_bib("samplebib")
381
+ end
382
+
383
+ def test_bibpaper
384
+ def @chapter.bibpaper(id)
385
+ Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
386
+ end
387
+
388
+ @builder.bibpaper(["a", "b"], "samplebib", "sample bib @<b>{bold}")
389
+ assert_equal %Q|[1] sample bib \\textbf{bold}\n\na\nb\n\n|, @builder.raw_result
390
+ end
391
+
392
+ def test_bibpaper_without_body
393
+ def @chapter.bibpaper(id)
394
+ Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
395
+ end
396
+
397
+ @builder.bibpaper([], "samplebib", "sample bib")
398
+ assert_equal %Q|[1] sample bib\n\n|, @builder.raw_result
399
+ end
400
+
401
+ def column_helper(review)
402
+ chap_singleton = class << @chapter; self; end
403
+ chap_singleton.send(:define_method, :content) { review }
404
+ @compiler.compile(@chapter)
405
+ end
406
+
407
+ def test_column_1
408
+ review =<<-EOS
409
+ ===[column] prev column
410
+
411
+ inside prev column
412
+
413
+ ===[column] test
414
+
415
+ inside column
416
+
417
+ ===[/column]
418
+ EOS
419
+ expect =<<-EOS
420
+
421
+ \\begin{reviewcolumn}
422
+ \\reviewcolumnhead{}{prev column}
423
+
424
+ inside prev column
425
+
426
+ \\end{reviewcolumn}
427
+
428
+ \\begin{reviewcolumn}
429
+ \\reviewcolumnhead{}{test}
430
+
431
+ inside column
432
+
433
+ \\end{reviewcolumn}
434
+ EOS
435
+ assert_equal expect, column_helper(review)
436
+ end
437
+
438
+ def test_column_2
439
+ review =<<-EOS
440
+ ===[column] test
441
+
442
+ inside column
443
+
444
+ === next level
445
+ EOS
446
+ expect =<<-EOS
447
+
448
+ \\begin{reviewcolumn}
449
+ \\reviewcolumnhead{}{test}
450
+
451
+ inside column
452
+
453
+ \\end{reviewcolumn}
454
+
455
+ \\subsection*{next level}
456
+ EOS
457
+
458
+ assert_equal expect, column_helper(review)
459
+ end
460
+
461
+ def test_column_3
462
+ review =<<-EOS
463
+ ===[column] test
464
+
465
+ inside column
466
+
467
+ ===[/column_dummy]
468
+ EOS
469
+ assert_raise(ReVIEW::CompileError) do
470
+ column_helper(review)
471
+ end
472
+ end
473
+
474
+ def test_ul
475
+ src =<<-EOS
476
+ * AAA
477
+ * BBB
478
+ EOS
479
+ expect =<<-EOS
480
+
481
+ \\begin{itemize}
482
+ \\item AAA
483
+ \\item BBB
484
+ \\end{itemize}
485
+ EOS
486
+ ul_helper(src, expect)
487
+ end
488
+
489
+ def test_ul_with_bracket
490
+ src =<<-EOS
491
+ * AAA
492
+ * []BBB
493
+ EOS
494
+ expect =<<-EOS
495
+
496
+ \\begin{itemize}
497
+ \\item AAA
498
+ \\item \\lbrack{}]BBB
499
+ \\end{itemize}
500
+ EOS
501
+ ul_helper(src, expect)
502
+ end
503
+
504
+ def test_cont
505
+ src =<<-EOS
506
+ * AAA
507
+ -AA
508
+ * BBB
509
+ -BB
510
+ EOS
511
+ expect =<<-EOS
512
+
513
+ \\begin{itemize}
514
+ \\item AAA{-}AA
515
+ \\item BBB{-}BB
516
+ \\end{itemize}
517
+ EOS
518
+ ul_helper(src, expect)
519
+ end
520
+
521
+ def test_ul_nest1
522
+ src =<<-EOS
523
+ * AAA
524
+ ** AA
525
+ EOS
526
+
527
+ expect =<<-EOS
528
+
529
+ \\begin{itemize}
530
+ \\item AAA
531
+
532
+ \\begin{itemize}
533
+ \\item AA
534
+ \\end{itemize}
535
+
536
+ \\end{itemize}
537
+ EOS
538
+ ul_helper(src, expect)
539
+ end
540
+
541
+ def test_ul_nest3
542
+ src =<<-EOS
543
+ * AAA
544
+ ** AA
545
+ * BBB
546
+ ** BB
547
+ EOS
548
+
549
+ expect =<<-EOS
550
+
551
+ \\begin{itemize}
552
+ \\item AAA
553
+
554
+ \\begin{itemize}
555
+ \\item AA
556
+ \\end{itemize}
557
+
558
+ \\item BBB
559
+
560
+ \\begin{itemize}
561
+ \\item BB
562
+ \\end{itemize}
563
+
564
+ \\end{itemize}
565
+ EOS
566
+ ul_helper(src, expect)
567
+ end
568
+
569
+ def test_ol_with_bracket
570
+ src =<<-EOS
571
+ 1. AAA
572
+ 2. []BBB
573
+ EOS
574
+ expect =<<-EOS
575
+
576
+ \\begin{enumerate}
577
+ \\item AAA
578
+ \\item \\lbrack{}]BBB
579
+ \\end{enumerate}
580
+ EOS
581
+ builder_helper(src, expect, :compile_olist)
582
+ end
583
+
584
+ def test_inline_raw0
585
+ assert_equal "normal", @builder.inline_raw("normal")
586
+ end
587
+
588
+ def test_inline_raw1
589
+ assert_equal "body", @builder.inline_raw("|latex|body")
590
+ end
591
+
592
+ def test_inline_raw2
593
+ assert_equal "body", @builder.inline_raw("|html, latex|body")
594
+ end
595
+
596
+ def test_inline_raw3
597
+ assert_equal "", @builder.inline_raw("|idgxml, html|body")
598
+ end
599
+
600
+ def test_inline_raw4
601
+ assert_equal "|latex body", @builder.inline_raw("|latex body")
602
+ end
603
+
604
+ def test_inline_raw5
605
+ assert_equal "nor\nmal", @builder.inline_raw("|latex|nor\\nmal")
606
+ end
607
+
608
+ def test_inline_endash
609
+ ret = @builder.compile_inline("- -- --- ----")
610
+ assert_equal "{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}", ret
611
+ end
612
+
613
+ def test_block_raw0
614
+ @builder.raw("<>!\"\\n& ")
615
+ expect =<<-EOS
616
+ <>!"
617
+ &
618
+ EOS
619
+ assert_equal expect.chomp, @builder.raw_result
620
+ end
621
+
622
+ def test_block_raw1
623
+ @builder.raw("|latex|<>!\"\\n& ")
624
+ expect =<<-EOS
625
+ <>!"
626
+ &
627
+ EOS
628
+ assert_equal expect.chomp, @builder.raw_result
629
+ end
630
+
631
+ def test_block_raw2
632
+ @builder.raw("|html, latex|<>!\"\\n& ")
633
+ expect =<<-EOS
634
+ <>!\"
635
+ &
636
+ EOS
637
+ assert_equal expect.chomp, @builder.raw_result
638
+ end
639
+
640
+ def test_block_raw3
641
+ @builder.raw("|html, idgxml|<>!\"\\n& ")
642
+ expect =<<-EOS
643
+ EOS
644
+ assert_equal expect.chomp, @builder.raw_result
645
+ end
646
+
647
+ def test_block_raw4
648
+ @builder.raw("|latex <>!\"\\n& ")
649
+ expect =<<-EOS
650
+ |latex <>!\"
651
+ &
652
+ EOS
653
+ assert_equal expect.chomp, @builder.raw_result
654
+ end
655
+
656
+ end