review 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/.travis.yml +1 -2
  2. data/ChangeLog +65 -0
  3. data/Gemfile +5 -0
  4. data/README.rdoc +6 -1
  5. data/Rakefile +14 -28
  6. data/bin/review-check +9 -21
  7. data/bin/review-compile +45 -12
  8. data/bin/review-epubmaker +477 -220
  9. data/bin/review-epubmaker-ng +5 -14
  10. data/bin/review-index +4 -2
  11. data/bin/review-init +94 -0
  12. data/bin/review-pdfmaker +70 -287
  13. data/bin/review-preproc +5 -2
  14. data/bin/review-vol +4 -11
  15. data/debian/changelog +3 -3
  16. data/debian/copyright +5 -3
  17. data/debian/docs +1 -0
  18. data/doc/format.rdoc +57 -11
  19. data/doc/quickstart.rdoc +4 -4
  20. data/doc/sample.yaml +11 -7
  21. data/lib/epubmaker.rb +1 -1
  22. data/lib/epubmaker/epubv2.rb +26 -27
  23. data/lib/epubmaker/epubv3.rb +13 -13
  24. data/lib/epubmaker/producer.rb +1 -1
  25. data/lib/review.rb +3 -4
  26. data/lib/review/book.rb +17 -581
  27. data/lib/review/book/base.rb +247 -0
  28. data/lib/review/book/chapter.rb +81 -0
  29. data/lib/review/book/compilable.rb +163 -0
  30. data/lib/review/book/index.rb +339 -0
  31. data/lib/review/book/page_metric.rb +38 -0
  32. data/lib/review/book/parameters.rb +97 -0
  33. data/lib/review/book/part.rb +44 -0
  34. data/lib/review/book/volume.rb +65 -0
  35. data/lib/review/builder.rb +34 -40
  36. data/lib/review/compiler.rb +32 -13
  37. data/lib/review/configure.rb +38 -0
  38. data/lib/review/ewbbuilder.rb +23 -21
  39. data/lib/review/extentions.rb +3 -0
  40. data/lib/review/extentions/object.rb +9 -0
  41. data/lib/review/{compat.rb → extentions/string.rb} +11 -0
  42. data/lib/review/htmlbuilder.rb +162 -74
  43. data/lib/review/htmlutils.rb +28 -1
  44. data/lib/review/i18n.yaml +11 -0
  45. data/lib/review/idgxmlbuilder.rb +119 -35
  46. data/lib/review/inaobuilder.rb +355 -0
  47. data/lib/review/latexbuilder.rb +133 -59
  48. data/lib/review/latexutils.rb +15 -6
  49. data/lib/review/makerhelper.rb +59 -0
  50. data/lib/review/markdownbuilder.rb +129 -0
  51. data/lib/review/preprocessor.rb +20 -7
  52. data/lib/review/review.tex.erb +250 -0
  53. data/lib/review/textutils.rb +28 -3
  54. data/lib/review/tocparser.rb +20 -12
  55. data/lib/review/tocprinter.rb +7 -3
  56. data/lib/review/topbuilder.rb +44 -27
  57. data/lib/review/version.rb +3 -0
  58. data/review.gemspec +20 -117
  59. data/test/book_test_helper.rb +35 -0
  60. data/test/sample-book/README.md +5 -0
  61. data/test/sample-book/src/CHAPS +2 -0
  62. data/test/sample-book/src/PREDEF +1 -0
  63. data/test/sample-book/src/Rakefile +26 -0
  64. data/test/sample-book/src/_cover.html +3 -0
  65. data/test/sample-book/src/ch01.re +71 -0
  66. data/test/sample-book/src/ch02.re +3 -0
  67. data/test/sample-book/src/config.yml +55 -0
  68. data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
  69. data/test/sample-book/src/images/cover.jpg +0 -0
  70. data/test/sample-book/src/main.css +251 -0
  71. data/test/sample-book/src/preface.re +15 -0
  72. data/test/sample-book/src/sty/jumoline.sty +310 -0
  73. data/test/sample-book/src/sty/samplemacro.sty +21 -0
  74. data/test/sample-book/src/vendor/jumoline/README +29 -0
  75. data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
  76. data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
  77. data/test/test_book.rb +26 -646
  78. data/test/test_book_chapter.rb +418 -0
  79. data/test/test_book_parameter.rb +42 -0
  80. data/test/test_book_part.rb +53 -0
  81. data/test/test_builder.rb +17 -10
  82. data/test/test_compiler.rb +46 -0
  83. data/test/test_epubmaker.rb +1 -1
  84. data/test/test_epubmaker_cmd.rb +36 -0
  85. data/test/test_helper.rb +17 -0
  86. data/test/test_htmlbuilder.rb +156 -24
  87. data/test/test_htmlutils.rb +4 -0
  88. data/test/test_i18n.rb +6 -2
  89. data/test/test_idgxmlbuilder.rb +33 -11
  90. data/test/test_inaobuilder.rb +247 -0
  91. data/test/test_index.rb +31 -0
  92. data/test/test_latexbuilder.rb +115 -35
  93. data/test/test_makerhelper.rb +50 -0
  94. data/test/test_pdfmaker_cmd.rb +36 -0
  95. data/test/test_preprocessor.rb +7 -7
  96. data/test/test_topbuilder.rb +6 -7
  97. data/test/test_uuid.rb +1 -0
  98. metadata +117 -12
  99. data/lib/review/index.rb +0 -323
  100. data/lib/review/volume.rb +0 -66
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'test_helper'
2
3
  require 'review/compiler'
3
4
  require 'review/book'
@@ -10,6 +11,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
10
11
  @builder = LATEXBuilder.new()
11
12
  @param = {
12
13
  "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
14
+ "toclevel" => 2,
13
15
  "inencoding" => "UTF-8",
14
16
  "outencoding" => "UTF-8",
15
17
  "subdirmode" => nil,
@@ -17,7 +19,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
17
19
  }
18
20
  ReVIEW.book.param = @param
19
21
  @compiler = ReVIEW::Compiler.new(@builder)
20
- @chapter = Chapter.new(nil, 1, 'chap1', nil, StringIO.new)
22
+ @chapter = Book::Chapter.new(nil, 1, 'chap1', nil, StringIO.new)
21
23
  location = Location.new(nil, nil)
22
24
  @builder.bind(@compiler, @chapter, location)
23
25
  end
@@ -30,12 +32,12 @@ class LATEXBuidlerTest < Test::Unit::TestCase
30
32
  def test_headline_level1_without_secno
31
33
  @param["secnolevel"] = 0
32
34
  @builder.headline(1,"test","this is test.")
33
- assert_equal %Q|\\chapter*{this is test.}\n\\label{chap:chap1}\n|, @builder.result
35
+ assert_equal %Q|\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n|, @builder.result
34
36
  end
35
37
 
36
38
  def test_headline_level1_with_inlinetag
37
39
  @builder.headline(1,"test","this @<b>{is} test.<&\"_>")
38
- assert_equal %Q|\\chapter{this \\textbf{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n|, @builder.result
40
+ assert_equal %Q|\\chapter{this \\textbf{is} test.\\textless{}\\&\"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n|, @builder.result
39
41
  end
40
42
 
41
43
  def test_headline_level2
@@ -80,6 +82,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
80
82
  assert_equal %Q|\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}|, ret
81
83
  end
82
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
+
83
90
  def test_inline_br
84
91
  ret = @builder.inline_br("")
85
92
  assert_equal %Q|\\\\\n|, ret
@@ -141,12 +148,12 @@ class LATEXBuidlerTest < Test::Unit::TestCase
141
148
  end
142
149
  def test_inline_em
143
150
  ret = @builder.compile_inline("abc@<em>{def}")
144
- assert_equal %Q|abc\\textbf{def}|, ret
151
+ assert_equal %Q|abc\\reviewem{def}|, ret
145
152
  end
146
153
 
147
154
  def test_inline_strong
148
155
  ret = @builder.compile_inline("abc@<strong>{def}")
149
- assert_equal %Q|abc\\textbf{def}|, ret
156
+ assert_equal %Q|abc\\reviewstrong{def}|, ret
150
157
  end
151
158
 
152
159
  def test_inline_u
@@ -166,7 +173,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
166
173
 
167
174
  def test_inline_tt_endash
168
175
  ret = @builder.compile_inline("test @<tt>{in-line --test ---foo ----bar -----buz} --test2")
169
- assert_equal %Q|test \\texttt{in-line {-}{-}test {-}{-}-foo {-}{-}{-}{-}bar {-}{-}{-}{-}-buz} --test2|, ret
176
+ assert_equal %Q|test \\texttt{in{-}line {-}{-}test {-}{-}{-}foo {-}{-}{-}{-}bar {-}{-}{-}{-}{-}buz} {-}{-}test2|, ret
170
177
  end
171
178
 
172
179
  def test_inline_tti
@@ -179,11 +186,26 @@ class LATEXBuidlerTest < Test::Unit::TestCase
179
186
  assert_equal %Q|test \\texttt{\\textbf{inline test}} test2|, ret
180
187
  end
181
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
+
182
199
  def test_inline_uchar
183
200
  ret = @builder.compile_inline("test @<uchar>{2460} test2")
184
201
  assert_equal %Q|test \\UTF{2460} test2|, ret
185
202
  end
186
203
 
204
+ def test_jis_x_0201_kana
205
+ ret = @builder.compile_inline("foo・カンジ、テスト")
206
+ assert_equal %Q|foo\\aj半角{・}\\aj半角{カ}\\aj半角{ン}\\aj半角{シ}\\aj半角{゛}\\aj半角{、}テスト|, ret
207
+ end
208
+
187
209
  def test_dlist
188
210
  @builder.dl_begin
189
211
  @builder.dt "foo"
@@ -192,28 +214,49 @@ class LATEXBuidlerTest < Test::Unit::TestCase
192
214
  assert_equal %Q|\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\nbar.\n\\end{description}\n|, @builder.result
193
215
  end
194
216
 
217
+ def test_dlist_with_bracket
218
+ @builder.dl_begin
219
+ @builder.dt "foo[bar]"
220
+ @builder.dd ["foo.\n", "bar.\n"]
221
+ @builder.dl_end
222
+ assert_equal %Q|\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.\nbar.\n\\end{description}\n|, @builder.result
223
+ end
224
+
195
225
  def test_cmd
196
226
  lines = ["foo", "bar", "","buz"]
197
227
  @builder.cmd(lines)
198
- assert_equal %Q|\n\\begin{reviewcmd}\n\\begin{alltt}\nfoo\nbar\n\nbuz\n\\end{alltt}\n\\end{reviewcmd}\n|, @builder.result
228
+ assert_equal %Q|\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, @builder.result
199
229
  end
200
230
 
201
231
  def test_cmd_caption
202
232
  lines = ["foo", "bar", "","buz"]
203
233
  @builder.cmd(lines, "cap1")
204
- 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
234
+ assert_equal %Q|\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, @builder.result
205
235
  end
206
236
 
207
237
  def test_emlist
208
238
  lines = ["foo", "bar", "","buz"]
209
239
  @builder.emlist(lines)
210
- assert_equal %Q|\n\\begin{reviewemlist}\n\\begin{alltt}\nfoo\nbar\n\nbuz\n\\end{alltt}\n\\end{reviewemlist}\n|, @builder.result
240
+ assert_equal %Q|\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, @builder.result
211
241
  end
212
242
 
213
243
  def test_emlist_caption
214
244
  lines = ["foo", "bar", "","buz"]
215
245
  @builder.emlist(lines, "cap1")
216
- 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
246
+ assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, @builder.result
247
+ end
248
+
249
+ def test_emlist_with_tab
250
+ lines = ["\tfoo", "\t\tbar", "","\tbuz"]
251
+ @builder.emlist(lines)
252
+ assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, @builder.result
253
+ end
254
+
255
+ def test_emlist_with_tab4
256
+ lines = ["\tfoo", "\t\tbar", "","\tbuz"]
257
+ @builder.instance_eval{@tabwidth=4}
258
+ @builder.emlist(lines)
259
+ assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, @builder.result
217
260
  end
218
261
 
219
262
  def test_quote
@@ -232,6 +275,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
232
275
  assert_equal %Q|\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n|, @builder.raw_result
233
276
  end
234
277
 
278
+ def test_centering
279
+ @builder.centering(["foo", "bar", "","buz"])
280
+ assert_equal %Q|\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n|, @builder.raw_result
281
+ end
282
+
235
283
  def test_noindent
236
284
  @builder.noindent
237
285
  @builder.paragraph(["foo", "bar"])
@@ -241,52 +289,51 @@ class LATEXBuidlerTest < Test::Unit::TestCase
241
289
 
242
290
  def test_image
243
291
  def @chapter.image(id)
244
- item = ImageIndex::Item.new("sampleimg",1)
292
+ item = Book::ImageIndex::Item.new("sampleimg",1)
245
293
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
246
294
  item
247
295
  end
248
296
 
249
297
  @builder.image_image("sampleimg","sample photo",nil)
250
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\label{image:chap1:sampleimg}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
298
+ 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
251
299
  end
252
300
 
253
301
  def test_image_with_metric
254
302
  def @chapter.image(id)
255
- item = ImageIndex::Item.new("sampleimg",1)
303
+ item = Book::ImageIndex::Item.new("sampleimg",1)
256
304
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
257
305
  item
258
306
  end
259
307
 
260
308
  @builder.image_image("sampleimg","sample photo","scale=1.2")
261
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\label{image:chap1:sampleimg}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
309
+ 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
262
310
  end
263
311
 
264
312
  def test_image_with_metric2
265
313
  def @chapter.image(id)
266
- item = ImageIndex::Item.new("sampleimg",1)
314
+ item = Book::ImageIndex::Item.new("sampleimg",1)
267
315
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
268
316
  item
269
317
  end
270
318
 
271
319
  @builder.image_image("sampleimg","sample photo","scale=1.2, html::class=\"sample\", latex::height=3cm")
272
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,height=3cm]{./images/chap1-sampleimg.png}\n\\label{image:chap1:sampleimg}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
320
+ 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
273
321
  end
274
322
 
275
323
  def test_indepimage
276
324
  def @chapter.image(id)
277
- item = ImageIndex::Item.new("sampleimg",1)
325
+ item = Book::ImageIndex::Item.new("sampleimg",1)
278
326
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
279
327
  item
280
328
  end
281
329
 
282
- # FIXME: indepimage's caption should not be with a counter.
283
330
  @builder.indepimage("sampleimg","sample photo",nil)
284
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
331
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
285
332
  end
286
333
 
287
334
  def test_indepimage_without_caption
288
335
  def @chapter.image(id)
289
- item = ImageIndex::Item.new("sampleimg",1)
336
+ item = Book::ImageIndex::Item.new("sampleimg",1)
290
337
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
291
338
  item
292
339
  end
@@ -298,31 +345,29 @@ class LATEXBuidlerTest < Test::Unit::TestCase
298
345
 
299
346
  def test_indepimage_with_metric
300
347
  def @chapter.image(id)
301
- item = ImageIndex::Item.new("sampleimg",1)
348
+ item = Book::ImageIndex::Item.new("sampleimg",1)
302
349
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
303
350
  item
304
351
  end
305
352
 
306
- # FIXME: indepimage's caption should not be with a counter.
307
353
  @builder.indepimage("sampleimg","sample photo","scale=1.2")
308
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
354
+ 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
309
355
  end
310
356
 
311
357
  def test_indepimage_with_metric2
312
358
  def @chapter.image(id)
313
- item = ImageIndex::Item.new("sampleimg",1)
359
+ item = Book::ImageIndex::Item.new("sampleimg",1)
314
360
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
315
361
  item
316
362
  end
317
363
 
318
- # FIXME: indepimage's caption should not be with a counter.
319
364
  @builder.indepimage("sampleimg","sample photo","scale=1.2, latex::height=3cm, html::class=\"sample\"")
320
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,height=3cm]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
365
+ 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
321
366
  end
322
367
 
323
368
  def test_indepimage_without_caption_but_with_metric
324
369
  def @chapter.image(id)
325
- item = ImageIndex::Item.new("sampleimg",1)
370
+ item = Book::ImageIndex::Item.new("sampleimg",1)
326
371
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
327
372
  item
328
373
  end
@@ -334,28 +379,28 @@ class LATEXBuidlerTest < Test::Unit::TestCase
334
379
 
335
380
  def test_bib
336
381
  def @chapter.bibpaper(id)
337
- BibpaperIndex::Item.new("samplebib",1,"sample bib")
382
+ Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
338
383
  end
339
384
 
340
- assert_equal "[1]", @builder.inline_bib("samplebib")
385
+ assert_equal "\\reviewbibref{[1]}{bib:samplebib}", @builder.inline_bib("samplebib")
341
386
  end
342
387
 
343
388
  def test_bibpaper
344
389
  def @chapter.bibpaper(id)
345
- BibpaperIndex::Item.new("samplebib",1,"sample bib")
390
+ Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
346
391
  end
347
392
 
348
393
  @builder.bibpaper(["a", "b"], "samplebib", "sample bib @<b>{bold}")
349
- assert_equal %Q|[1] sample bib \\textbf{bold}\n\na\nb\n\n|, @builder.raw_result
394
+ assert_equal %Q|[1] sample bib \\textbf{bold}\n\\label{bib:samplebib}\n\nab\n|, @builder.raw_result
350
395
  end
351
396
 
352
397
  def test_bibpaper_without_body
353
398
  def @chapter.bibpaper(id)
354
- BibpaperIndex::Item.new("samplebib",1,"sample bib")
399
+ Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
355
400
  end
356
401
 
357
402
  @builder.bibpaper([], "samplebib", "sample bib")
358
- assert_equal %Q|[1] sample bib\n\n|, @builder.raw_result
403
+ assert_equal %Q|[1] sample bib\n\\label{bib:samplebib}\n\n|, @builder.raw_result
359
404
  end
360
405
 
361
406
  def column_helper(review)
@@ -446,6 +491,21 @@ EOS
446
491
  ul_helper(src, expect)
447
492
  end
448
493
 
494
+ def test_ul_with_bracket
495
+ src =<<-EOS
496
+ * AAA
497
+ * []BBB
498
+ EOS
499
+ expect =<<-EOS
500
+
501
+ \\begin{itemize}
502
+ \\item AAA
503
+ \\item \\lbrack{}]BBB
504
+ \\end{itemize}
505
+ EOS
506
+ ul_helper(src, expect)
507
+ end
508
+
449
509
  def test_cont
450
510
  src =<<-EOS
451
511
  * AAA
@@ -456,8 +516,8 @@ EOS
456
516
  expect =<<-EOS
457
517
 
458
518
  \\begin{itemize}
459
- \\item AAA-AA
460
- \\item BBB-BB
519
+ \\item AAA{-}AA
520
+ \\item BBB{-}BB
461
521
  \\end{itemize}
462
522
  EOS
463
523
  ul_helper(src, expect)
@@ -511,6 +571,21 @@ EOS
511
571
  ul_helper(src, expect)
512
572
  end
513
573
 
574
+ def test_ol_with_bracket
575
+ src =<<-EOS
576
+ 1. AAA
577
+ 2. []BBB
578
+ EOS
579
+ expect =<<-EOS
580
+
581
+ \\begin{enumerate}
582
+ \\item AAA
583
+ \\item \\lbrack{}]BBB
584
+ \\end{enumerate}
585
+ EOS
586
+ builder_helper(src, expect, :compile_olist)
587
+ end
588
+
514
589
  def test_inline_raw0
515
590
  assert_equal "normal", @builder.inline_raw("normal")
516
591
  end
@@ -535,6 +610,11 @@ EOS
535
610
  assert_equal "nor\nmal", @builder.inline_raw("|latex|nor\\nmal")
536
611
  end
537
612
 
613
+ def test_inline_endash
614
+ ret = @builder.compile_inline("- -- --- ----")
615
+ assert_equal "{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}", ret
616
+ end
617
+
538
618
  def test_block_raw0
539
619
  @builder.raw("<>!\"\\n& ")
540
620
  expect =<<-EOS
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'test_helper'
4
+ require 'review/makerhelper'
5
+ require 'tmpdir'
6
+ require 'fileutils'
7
+
8
+
9
+ class MakerHelperTest < Test::Unit::TestCase
10
+ include ReVIEW
11
+
12
+ def setup
13
+ @tmpdir1 = Dir.mktmpdir
14
+ @tmpdir2 = Dir.mktmpdir
15
+ end
16
+
17
+ def teardown
18
+ FileUtils.rm_rf @tmpdir1
19
+ FileUtils.rm_rf @tmpdir2
20
+ end
21
+
22
+ def test_copy_images_to_dir
23
+ types = %w{png gif jpg jpeg svg pdf eps}
24
+ types.each do |type|
25
+ touch_file("#{@tmpdir1}/foo.#{type}")
26
+ end
27
+ FileUtils.mkdir("#{@tmpdir1}/subdir")
28
+ touch_file("#{@tmpdir1}/subdir/foo.png")
29
+
30
+ image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2)
31
+
32
+ types.each do |type|
33
+ assert File.exists?("#{@tmpdir2}/foo.#{type}"), "Copying #{type} file failed"
34
+ assert image_files.include?("#{@tmpdir1}/foo.#{type}")
35
+ end
36
+ assert File.exists?("#{@tmpdir2}/subdir/foo.png"), "Copying a image file in a subdirectory"
37
+ assert image_files.include?("#{@tmpdir1}/subdir/foo.png")
38
+ end
39
+
40
+ def test_copy_images_to_dir_convert
41
+ touch_file("#{@tmpdir1}/foo.eps")
42
+
43
+ image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2,
44
+ :convert => {:eps => :png})
45
+
46
+ assert File.exists?("#{@tmpdir2}/foo.eps.png"), "EPS to PNG conversion failed"
47
+ assert image_files.include?("#{@tmpdir1}/foo.eps.png")
48
+ end
49
+
50
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'tmpdir'
5
+ require 'fileutils'
6
+ require 'yaml'
7
+
8
+ REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker', File.dirname(__FILE__))
9
+
10
+ class PDFMakerCmdTest < Test::Unit::TestCase
11
+ def setup
12
+ @tmpdir1 = Dir.mktmpdir
13
+ @tmpdir2 = Dir.mktmpdir
14
+
15
+ @old_rubylib = ENV['RUBYLIB']
16
+ ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
17
+ end
18
+
19
+ def teardown
20
+ FileUtils.rm_rf @tmpdir1
21
+ FileUtils.rm_rf @tmpdir2
22
+ ENV['RUBYLIB'] = @old_rubylib
23
+ end
24
+
25
+ def test_pdfmaker_cmd
26
+ config = prepare_samplebook(@tmpdir1)
27
+ builddir = @tmpdir1 + "/" + config['bookname'] + '-pdf'
28
+ assert ! File.exists?(builddir)
29
+
30
+ Dir.chdir(@tmpdir1) do
31
+ system("#{REVIEW_PDFMAKER} config.yml 1>/dev/null 2>/dev/null")
32
+ end
33
+
34
+ assert File.exists?(builddir)
35
+ end
36
+ end
@@ -13,11 +13,11 @@ class PreprocessorStripTest < Test::Unit::TestCase
13
13
  assert_equal expect, actual
14
14
  end
15
15
 
16
- # def test_gets_with_comment
17
- # f = StringIO.new '#@warn(write it later)'
18
- # s = Preprocessor::Strip.new(f)
19
- # expect = '#@#' + "\n"
20
- # actual = s.gets
21
- # assert_equal expect, actual
22
- # end
16
+ def test_gets_with_comment
17
+ f = StringIO.new '#@warn(write it later)'
18
+ s = Preprocessor::Strip.new(f)
19
+ expect = '#@#' + "\n"
20
+ actual = s.gets
21
+ assert_equal expect, actual
22
+ end
23
23
  end