review 2.1.0 → 2.2.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +293 -6
  4. data/.rubocop_todo.yml +3 -608
  5. data/.travis.yml +6 -13
  6. data/README.md +5 -3
  7. data/Rakefile +6 -6
  8. data/bin/review-catalog-converter +2 -2
  9. data/bin/review-check +1 -1
  10. data/bin/review-compile +1 -2
  11. data/bin/review-init +6 -3
  12. data/bin/review-validate +3 -3
  13. data/bin/review-vol +2 -1
  14. data/doc/NEWS.ja.md +138 -25
  15. data/doc/NEWS.md +137 -25
  16. data/doc/config.yml.sample +2 -2
  17. data/doc/config.yml.sample-simple +1 -1
  18. data/doc/format.ja.md +86 -5
  19. data/doc/format.md +67 -2
  20. data/doc/makeindex.ja.md +95 -0
  21. data/doc/makeindex.md +97 -0
  22. data/doc/sample.css +214 -0
  23. data/lib/epubmaker.rb +6 -6
  24. data/lib/epubmaker/epubcommon.rb +19 -47
  25. data/lib/epubmaker/epubv2.rb +3 -1
  26. data/lib/epubmaker/epubv3.rb +4 -26
  27. data/lib/epubmaker/producer.rb +46 -46
  28. data/lib/epubmaker/zip_exporter.rb +86 -0
  29. data/lib/review/book/base.rb +13 -15
  30. data/lib/review/book/chapter.rb +2 -1
  31. data/lib/review/book/compilable.rb +9 -9
  32. data/lib/review/book/image_finder.rb +13 -13
  33. data/lib/review/book/index.rb +2 -2
  34. data/lib/review/book/volume.rb +2 -2
  35. data/lib/review/builder.rb +57 -1
  36. data/lib/review/catalog.rb +2 -2
  37. data/lib/review/compiler.rb +15 -7
  38. data/lib/review/configure.rb +11 -0
  39. data/lib/review/epubmaker.rb +403 -401
  40. data/lib/review/ewbbuilder.rb +16 -16
  41. data/lib/review/htmlbuilder.rb +42 -58
  42. data/lib/review/htmltoc.rb +1 -1
  43. data/lib/review/htmlutils.rb +50 -4
  44. data/lib/review/i18n.rb +2 -2
  45. data/lib/review/idgxmlbuilder.rb +30 -47
  46. data/lib/review/latexbuilder.rb +86 -41
  47. data/lib/review/latexutils.rb +19 -19
  48. data/lib/review/markdownbuilder.rb +16 -4
  49. data/lib/review/md2inaobuilder.rb +0 -9
  50. data/lib/review/pdfmaker.rb +91 -48
  51. data/lib/review/preprocessor.rb +1 -1
  52. data/lib/review/rstbuilder.rb +763 -0
  53. data/lib/review/sec_counter.rb +7 -9
  54. data/lib/review/tocparser.rb +3 -3
  55. data/lib/review/tocprinter.rb +5 -5
  56. data/lib/review/topbuilder.rb +48 -56
  57. data/lib/review/version.rb +1 -1
  58. data/lib/review/webmaker.rb +6 -7
  59. data/review.gemspec +1 -0
  60. data/templates/latex/layout.tex.erb +27 -2
  61. data/test/assets/test_template.tex +10 -1
  62. data/test/book_test_helper.rb +1 -2
  63. data/test/run_test.rb +10 -0
  64. data/test/sample-book/src/style.css +215 -0
  65. data/test/sample-book/src/vendor/jumoline/lppl.txt +416 -0
  66. data/test/test_book.rb +0 -1
  67. data/test/test_catalog.rb +1 -0
  68. data/test/test_converter.rb +1 -1
  69. data/test/test_epub3maker.rb +44 -51
  70. data/test/test_epubmaker.rb +82 -38
  71. data/test/test_epubmaker_cmd.rb +1 -1
  72. data/test/test_extentions_hash.rb +8 -1
  73. data/test/test_htmlbuilder.rb +411 -18
  74. data/test/test_i18n.rb +17 -0
  75. data/test/test_idgxmlbuilder.rb +88 -3
  76. data/test/test_image_finder.rb +18 -0
  77. data/test/test_index.rb +2 -0
  78. data/test/test_latexbuilder.rb +96 -8
  79. data/test/test_makerhelper.rb +2 -2
  80. data/test/test_markdownbuilder.rb +22 -1
  81. data/test/test_md2inaobuilder.rb +0 -5
  82. data/test/test_pdfmaker.rb +54 -36
  83. data/test/test_pdfmaker_cmd.rb +1 -1
  84. data/test/test_rstbuilder.rb +356 -0
  85. data/test/test_textutils.rb +14 -4
  86. data/test/test_topbuilder.rb +23 -4
  87. data/test/test_zip_exporter.rb +113 -0
  88. metadata +28 -2
data/test/test_i18n.rb CHANGED
@@ -181,6 +181,23 @@ class I18nTest < Test::Unit::TestCase
181
181
  end
182
182
  end
183
183
 
184
+ def test_format_with_mismatched_number_of_arguments
185
+ Dir.mktmpdir do |dir|
186
+ Dir.chdir(dir) do
187
+ file = File.join(dir, "locale.yml")
188
+
189
+ File.open(file, "w"){|f| f.write %Q|locale: ja\nformat_number_header: "%2$d"| }
190
+ I18n.setup("ja")
191
+ assert_equal "10", I18n.t("format_number_header", [1, 10])
192
+
193
+ File.open(file, "w"){|f| f.write %Q|locale: ja\nformat_number_header: "%2$d-%1$d"| }
194
+ I18n.setup("ja")
195
+ # ERROR: returns raw format
196
+ assert_equal "%2$d-%1$d", I18n.t("format_number_header", [1])
197
+ end
198
+ end
199
+ end
200
+
184
201
  def test_ja
185
202
  I18n.setup("ja")
186
203
  assert_equal "図", I18n.t("image")
@@ -13,9 +13,9 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
13
13
  @builder = IDGXMLBuilder.new()
14
14
  @config = ReVIEW::Configure.values
15
15
  @config.merge!({
16
- "secnolevel" => 2,
17
- "tableopt" => "10"
18
- })
16
+ "secnolevel" => 2,
17
+ "tableopt" => "10"
18
+ })
19
19
  @book = Book::Base.new(nil)
20
20
  @book.config = @config
21
21
  @compiler = ReVIEW::Compiler.new(@builder)
@@ -114,6 +114,15 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
114
114
 
115
115
  actual = compile_block("//tsize[2]\n//table{\nA\tB\tC\n//}\n")
116
116
  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
117
+
118
+ actual = compile_block("//tsize[|idgxml|2]\n//table{\nA\tB\tC\n//}\n")
119
+ 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
120
+
121
+ actual = compile_block("//tsize[|idgxml,html|2]\n//table{\nA\tB\tC\n//}\n")
122
+ 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
123
+
124
+ actual = compile_block("//tsize[|html|2]\n//table{\nA\tB\tC\n//}\n")
125
+ 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="9.448">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">C</td></tbody></table>|, actual
117
126
  end
118
127
 
119
128
  def test_customize_mmtopt
@@ -244,6 +253,11 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
244
253
  assert_equal %Q|<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>|, actual
245
254
  end
246
255
 
256
+ def test_emlistnum
257
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
258
+ assert_equal %Q|<list type='emlistnum'><caption aid:pstyle='emlistnum-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre></list>|, actual
259
+ end
260
+
247
261
  def test_emlist_listinfo
248
262
  @config["listinfo"] = true
249
263
  actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
@@ -269,6 +283,22 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
269
283
  assert_equal %Q|<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>|, actual
270
284
  end
271
285
 
286
+ def test_listnum
287
+ def @chapter.list(id)
288
+ Book::ListIndex::Item.new("samplelist",1)
289
+ end
290
+ actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
291
+ assert_equal %Q|<codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre></codelist>|, actual
292
+ end
293
+
294
+ def test_listnum_linenum
295
+ def @chapter.list(id)
296
+ Book::ListIndex::Item.new("samplelist",1)
297
+ end
298
+ actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
299
+ assert_equal %Q|<codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre><span type='lineno'>100: </span>test1\n<span type='lineno'>101: </span>test1.5\n<span type='lineno'>102: </span>\n<span type='lineno'>103: </span>test<i>2</i>\n</pre></codelist>|, actual
300
+ end
301
+
272
302
  def test_list_listinfo
273
303
  def @chapter.list(id)
274
304
  Book::ListIndex::Item.new("samplelist",1)
@@ -292,6 +322,12 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
292
322
  assert_equal %Q|<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>|, actual
293
323
  end
294
324
 
325
+ def test_box_non_listinfo
326
+ @config["listinfo"] = nil
327
+ actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
328
+ assert_equal %Q|<box><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption>test1\ntest1.5\n\ntest<i>2</i>\n</box>|, actual
329
+ end
330
+
295
331
  def test_flushright
296
332
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
297
333
  assert_equal %Q|<p align='right'>foobar</p><p align='right'>buz</p>|, actual
@@ -445,6 +481,34 @@ EOS
445
481
  end
446
482
  end
447
483
 
484
+ def test_column_ref
485
+ review =<<-EOS
486
+ ===[column]{foo} test
487
+
488
+ inside column
489
+
490
+ === next level
491
+
492
+ this is @<column>{foo}.
493
+ EOS
494
+ expected =<<-EOS.chomp
495
+ <column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle="h3">next level</title><?dtp level="3" section="next level"?><p>this is コラム「test」.</p>
496
+ EOS
497
+
498
+ assert_equal expected, column_helper(review)
499
+ end
500
+
501
+ def test_column_in_aother_chapter_ref
502
+ def @chapter.column_index
503
+ items = [Book::ColumnIndex::Item.new("chap1|column", 1, "column_cap")]
504
+ Book::ColumnIndex.new(items)
505
+ end
506
+
507
+ actual = compile_inline("test @<column>{chap1|column} test2")
508
+ expected = "test コラム「column_cap」 test2"
509
+ assert_equal expected, actual
510
+ end
511
+
448
512
  def test_ul
449
513
  src =<<-EOS
450
514
  * AAA
@@ -626,4 +690,25 @@ EOS
626
690
  assert_equal expected.chomp, actual
627
691
  end
628
692
 
693
+ def test_comment
694
+ actual = compile_block("//comment[コメント]")
695
+ assert_equal %Q||, actual
696
+ end
697
+
698
+ def test_comment_for_draft
699
+ @config["draft"] = true
700
+ actual = compile_block("//comment[コメント]")
701
+ assert_equal %Q|<msg>コメント</msg>|, actual
702
+ end
703
+
704
+ def test_inline_comment
705
+ actual = compile_inline("test @<comment>{コメント} test2")
706
+ assert_equal %Q|test test2|, actual
707
+ end
708
+
709
+ def test_inline_comment_for_draft
710
+ @config["draft"] = true
711
+ actual = compile_inline("test @<comment>{コメント} test2")
712
+ assert_equal %Q|test <msg>コメント</msg> test2|, actual
713
+ end
629
714
  end
@@ -79,4 +79,22 @@ class ImageFinderTest < Test::Unit::TestCase
79
79
  FileUtils.remove_entry_secure dir
80
80
  end
81
81
  end
82
+
83
+ def test_find_path_dir_symlink
84
+ dir = Dir.mktmpdir
85
+ begin
86
+ path_src = dir+"/src"
87
+ path_dst = dir+"/ch01"
88
+ FileUtils.mkdir_p(path_src)
89
+ FileUtils.symlink(path_src, path_dst)
90
+ path_srcimg = path_src+"/foo.jpg"
91
+ path_dstimg = path_dst+"/foo.jpg"
92
+ FileUtils.touch(path_srcimg)
93
+
94
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
95
+ assert_equal(path_dstimg, finder.find_path("foo"))
96
+ ensure
97
+ FileUtils.remove_entry_secure dir
98
+ end
99
+ end
82
100
  end
data/test/test_index.rb CHANGED
@@ -13,6 +13,7 @@ class IndexTest < Test::Unit::TestCase
13
13
  assert_equal 'foo', item.id
14
14
  assert_equal 'bar', item.content
15
15
  end
16
+
16
17
  def test_footnote_index_with_escape
17
18
  fn = Book::FootnoteIndex.parse(['//footnote[foo][bar[\]buz]'])
18
19
  items = fn.to_a
@@ -20,6 +21,7 @@ class IndexTest < Test::Unit::TestCase
20
21
  assert_equal 'foo', item.id
21
22
  assert_equal 'bar[]buz', item.content
22
23
  end
24
+
23
25
  def test_footnote_index_with_escape2
24
26
  fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
25
27
  items = fn.to_a
@@ -11,13 +11,13 @@ class LATEXBuidlerTest < Test::Unit::TestCase
11
11
  def setup
12
12
  @builder = LATEXBuilder.new()
13
13
  @config = ReVIEW::Configure.values
14
- @config.merge!( {
15
- "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
16
- "toclevel" => 2,
17
- "stylesheet" => nil, # for EPUBBuilder
18
- "image_scale2width" => false,
19
- "texcommand" => "uplatex"
20
- })
14
+ @config.merge!({
15
+ "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
16
+ "toclevel" => 2,
17
+ "stylesheet" => nil, # for EPUBBuilder
18
+ "image_scale2width" => false,
19
+ "texcommand" => "uplatex"
20
+ })
21
21
  @book = Book::Base.new(nil)
22
22
  @book.config = @config
23
23
  @compiler = ReVIEW::Compiler.new(@builder)
@@ -144,6 +144,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
144
144
  actual = compile_inline("test @<b>{inline<&;\\ test} test2")
145
145
  assert_equal %Q|test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, actual
146
146
  end
147
+
147
148
  def test_inline_em
148
149
  actual = compile_inline("abc@<em>{def}")
149
150
  assert_equal %Q|abc\\reviewem{def}|, actual
@@ -164,6 +165,13 @@ class LATEXBuidlerTest < Test::Unit::TestCase
164
165
  assert_equal "abc $\\alpha^n = inf < 2$ ghi", actual
165
166
  end
166
167
 
168
+ def test_inline_m2
169
+ ## target text: @<m>{X = \{ {x_1\},{x_2\}, \cdots ,{x_n\} \\\}}
170
+ actual = compile_inline('@<m>{X = \\{ {x_1\\},{x_2\\}, \\cdots ,{x_n\\} \\\\\\}}')
171
+ ## expected text: $X = \{ {x_1},{x_2}, \cdots ,{x_n} \}$
172
+ assert_equal ' $X = \\{ {x_1},{x_2}, \\cdots ,{x_n} \\}$ ', actual
173
+ end
174
+
167
175
  def test_inline_tt
168
176
  actual = compile_inline("test @<tt>{inline test} test2")
169
177
  assert_equal %Q|test \\texttt{inline test} test2|, actual
@@ -207,7 +215,25 @@ class LATEXBuidlerTest < Test::Unit::TestCase
207
215
 
208
216
  def test_inline_idx
209
217
  actual = compile_inline("@<idx>{__TEST%$}, @<hidx>{__TEST%$}")
210
- assert_equal %Q|\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$}, \\index{__TEST%$}|, actual
218
+ assert_equal %Q|\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}, \\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}|, actual
219
+ end
220
+
221
+ def test_inline_idx_yomi
222
+ begin
223
+ require 'MeCab'
224
+ require 'nkf'
225
+ rescue LoadError
226
+ $stderr.puts "skip test_inline_idx_yomi (cannot find MeCab)"
227
+ return true
228
+ end
229
+ tmpdir = Dir.mktmpdir
230
+ File.write("#{tmpdir}/sample.dic", "強運\tはーどらっく\n")
231
+ @book.config["pdfmaker"]["makeindex"] = true
232
+ @book.config["pdfmaker"]["makeindex_dic"] = "#{tmpdir}/sample.dic"
233
+ @builder.setup_index
234
+ actual = compile_inline("@<hidx>{漢字}@<hidx>{強運}@<hidx>{項目@1<<>>項目@2}")
235
+ FileUtils.remove_entry_secure(tmpdir)
236
+ assert_equal %Q|\\index{かんじ@漢字}\\index{はーどらっく@強運}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}|, actual
211
237
  end
212
238
 
213
239
  def test_jis_x_0201_kana
@@ -311,6 +337,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
311
337
  assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual
312
338
  end
313
339
 
340
+ def test_listnum_linenum
341
+ actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
342
+ assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n100: class Foo\n101: def foo\n102: bar\n103: \n104: buz\n105: end\n106: end\n\\end{reviewlist}\n|, actual
343
+ end
344
+
314
345
  def test_listnum_lst
315
346
  @book.config["highlight"] = {}
316
347
  @book.config["highlight"]["latex"] = "listings"
@@ -318,6 +349,25 @@ class LATEXBuidlerTest < Test::Unit::TestCase
318
349
  assert_equal %Q|\\begin{reviewlistnumlst}[caption={ruby},language={}]\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n\\end{reviewlistnumlst}\n|, actual
319
350
  end
320
351
 
352
+ def test_listnum_lst_linenum
353
+ @book.config["highlight"] = {}
354
+ @book.config["highlight"]["latex"] = "listings"
355
+ actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
356
+ assert_equal %Q|\\begin{reviewlistnumlst}[caption={ruby},language={},firstnumber=100]\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n\\end{reviewlistnumlst}\n|, actual
357
+ end
358
+
359
+ def test_source
360
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
361
+ assert_equal %Q|\\reviewsourcecaption{foo/bar/test.rb}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n|, actual
362
+ end
363
+
364
+ def test_source_lst
365
+ @book.config["highlight"] = {}
366
+ @book.config["highlight"]["latex"] = "listings"
367
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
368
+ assert_equal %Q|\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]\nfoo\nbar\n\nbuz\n\\end{reviewsourcelst}\n|, actual
369
+ end
370
+
321
371
  def test_quote
322
372
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
323
373
  assert_equal %Q|\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n|, actual
@@ -475,6 +525,23 @@ class LATEXBuidlerTest < Test::Unit::TestCase
475
525
  actual
476
526
  end
477
527
 
528
+ def test_customize_cellwidth
529
+ actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
530
+ assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
531
+
532
+ actual = compile_block("//tsize[|latex,html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
533
+ assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
534
+
535
+ actual = compile_block("//tsize[|html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
536
+ assert_equal %Q(\\begin{reviewtable}{|l|l|l|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
537
+
538
+ actual = compile_block("//tsize[|latex|2,3,5]\n//table{\nA\tB\tC\n//}\n")
539
+ assert_equal %Q(\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
540
+
541
+ actual = compile_block("//tsize[|latex||p{5mm}|cr|]\n//table{\nA\tB\tC\n//}\n")
542
+ assert_equal %Q(\\begin{reviewtable}{|p{5mm}|cr|}\n\\hline\n\\reviewth{A} & B & C \\\\ \\hline\n\\end{reviewtable}\n), actual
543
+ end
544
+
478
545
  def test_imgtable
479
546
  def @chapter.image(id)
480
547
  item = Book::ImageIndex::Item.new("sampleimg",1, 'sample img')
@@ -849,4 +916,25 @@ EOS
849
916
  assert_equal expected, actual
850
917
  end
851
918
 
919
+ def test_comment
920
+ actual = compile_block("//comment[コメント]")
921
+ assert_equal %Q||, actual
922
+ end
923
+
924
+ def test_comment_for_draft
925
+ @config["draft"] = true
926
+ actual = compile_block("//comment[コメント]")
927
+ assert_equal %Q|\\pdfcomment{コメント}\n|, actual
928
+ end
929
+
930
+ def test_inline_comment
931
+ actual = compile_inline("test @<comment>{コメント} test2")
932
+ assert_equal %Q|test test2|, actual
933
+ end
934
+
935
+ def test_inline_comment_for_draft
936
+ @config["draft"] = true
937
+ actual = compile_inline("test @<comment>{コメント} test2")
938
+ assert_equal %Q|test \\pdfcomment{コメント} test2|, actual
939
+ end
852
940
  end
@@ -38,11 +38,11 @@ class MakerHelperTest < Test::Unit::TestCase
38
38
  end
39
39
 
40
40
  def test_copy_images_to_dir_convert
41
- if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
41
+ if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM && (`convert -version` rescue nil)
42
42
  touch_file("#{@tmpdir1}/foo.eps")
43
43
 
44
44
  image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2,
45
- :convert => {:eps => :png})
45
+ :convert => {:eps => :png})
46
46
 
47
47
  assert File.exist?("#{@tmpdir2}/foo.eps.png"), "EPS to PNG conversion failed"
48
48
  assert image_files.include?("#{@tmpdir1}/foo.eps.png")
@@ -46,6 +46,17 @@ EOS
46
46
  assert_equal expected, actual
47
47
  end
48
48
 
49
+ def test_inline_comment
50
+ actual = compile_inline("test @<comment>{コメント} test2")
51
+ assert_equal %Q|test test2|, actual
52
+ end
53
+
54
+ def test_inline_comment_for_draft
55
+ @config["draft"] = true
56
+ actual = compile_inline("test @<comment>{コメント} test2")
57
+ assert_equal %Q|test <span class="red">コメント</span> test2|, actual
58
+ end
59
+
49
60
  def test_ul_nest1
50
61
  src =<<-EOS
51
62
  * AAA
@@ -62,7 +73,6 @@ EOS
62
73
  assert_equal "```shell-session\nlineA\nlineB\n```\n", actual
63
74
  end
64
75
 
65
-
66
76
  def test_dlist
67
77
  actual = compile_block(": foo\n foo.\n bar.\n")
68
78
  assert_equal %Q|<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
@@ -79,6 +89,17 @@ EOS
79
89
  assert_equal %Q|<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n|, actual
80
90
  end
81
91
 
92
+ def test_comment
93
+ actual = compile_block("//comment[コメント]")
94
+ assert_equal %Q||, actual
95
+ end
96
+
97
+ def test_comment_for_draft
98
+ @config["draft"] = true
99
+ actual = compile_block("//comment[コメント]")
100
+ assert_equal %Q|<div class="red">コメント</div>\n|, actual
101
+ end
102
+
82
103
  def test_list
83
104
  actual = compile_block(<<-EOS)
84
105
  //list[name][caption]{
@@ -57,11 +57,6 @@ BBB
57
57
  EOS
58
58
  end
59
59
 
60
- def test_comment
61
- actual = compile_block("//comment{\nHello, world!\n//}\n")
62
- assert_equal "<span class=\"red\">\nHello, world!\n</span>\n", actual
63
- end
64
-
65
60
  def test_ruby_mono
66
61
  actual = compile_block("@<ruby>{謳,うた}い文句")
67
62
  assert_equal " <span class='monoruby'>謳(うた)</span>い文句\n\n", actual
@@ -85,8 +85,8 @@ class PDFMakerTest < Test::Unit::TestCase
85
85
 
86
86
  def test_make_authors
87
87
  @config.merge!({"aut"=>["テスト太郎","テスト次郎"],
88
- "csl"=>["監修三郎"],
89
- "trl"=>["翻訳四郎","翻訳五郎",]})
88
+ "csl"=>["監修三郎"],
89
+ "trl"=>["翻訳四郎","翻訳五郎",]})
90
90
  Dir.mktmpdir do |dir|
91
91
  authors = @maker.make_authors
92
92
  assert_equal("テスト太郎、テスト次郎 著 \\\\\n監修三郎 監修 \\\\\n翻訳四郎、翻訳五郎 訳",
@@ -104,16 +104,16 @@ class PDFMakerTest < Test::Unit::TestCase
104
104
 
105
105
  def test_make_okuduke
106
106
  @config.merge!({
107
- "aut"=>["テスト太郎","テスト次郎"],
108
- "csl"=>["監修三郎"],
109
- "trl"=>["翻訳四郎","翻訳五郎"],
110
- "dsr"=>["デザイン六郎"],
111
- "ill"=>["イラスト七郎","イラスト八郎"],
112
- "cov"=>["表紙九郎"],
113
- "edt"=>["編集十郎"],
114
- "pbl"=>"テスト出版",
115
- "prt"=>"テスト印刷",
116
- })
107
+ "aut"=>["テスト太郎","テスト次郎"],
108
+ "csl"=>["監修三郎"],
109
+ "trl"=>["翻訳四郎","翻訳五郎"],
110
+ "dsr"=>["デザイン六郎"],
111
+ "ill"=>["イラスト七郎","イラスト八郎"],
112
+ "cov"=>["表紙九郎"],
113
+ "edt"=>["編集十郎"],
114
+ "pbl"=>"テスト出版",
115
+ "prt"=>"テスト印刷",
116
+ })
117
117
  Dir.mktmpdir do |dir|
118
118
  okuduke = @maker.make_colophon
119
119
  assert_equal("著 者 & テスト太郎、テスト次郎 \\\\\n監 修 & 監修三郎 \\\\\n翻 訳 & 翻訳四郎、翻訳五郎 \\\\\nデザイン & デザイン六郎 \\\\\nイラスト & イラスト七郎、イラスト八郎 \\\\\n表 紙 & 表紙九郎 \\\\\n編 集 & 編集十郎 \\\\\n発行所 & テスト出版 \\\\\n印刷所 & テスト印刷 \\\\\n",
@@ -124,13 +124,13 @@ class PDFMakerTest < Test::Unit::TestCase
124
124
 
125
125
  def test_make_okuduke_dojin
126
126
  @config.merge!({
127
- "aut"=>["テスト太郎","テスト次郎"],
128
- "csl"=>["監修三郎"],
129
- "ill"=>["イラスト七郎","イラスト八郎"],
130
- "pbl"=>"テスト出版",
131
- "prt"=>"テスト印刷",
132
- "contact"=>"tarou@example.jp",
133
- })
127
+ "aut"=>["テスト太郎","テスト次郎"],
128
+ "csl"=>["監修三郎"],
129
+ "ill"=>["イラスト七郎","イラスト八郎"],
130
+ "pbl"=>"テスト出版",
131
+ "prt"=>"テスト印刷",
132
+ "contact"=>"tarou@example.jp",
133
+ })
134
134
  Dir.mktmpdir do |dir|
135
135
  I18n.update({"prt" => "印刷所"},"ja")
136
136
  okuduke = @maker.make_colophon
@@ -150,10 +150,10 @@ class PDFMakerTest < Test::Unit::TestCase
150
150
 
151
151
  def test_gettemplate_with_backmatter
152
152
  @config.merge!({
153
- "backcover"=>"backcover.html",
154
- "profile"=>"profile.html",
155
- "advfile"=>"advfile.html",
156
- })
153
+ "backcover"=>"backcover.html",
154
+ "profile"=>"profile.html",
155
+ "advfile"=>"advfile.html",
156
+ })
157
157
  Dir.mktmpdir do |dir|
158
158
  Dir.chdir(dir) do
159
159
  profile = "\\thispagestyle{empty}\\chapter*{Profile}\nsome profile\n"
@@ -189,9 +189,9 @@ class PDFMakerTest < Test::Unit::TestCase
189
189
  @config["pht"] = ["Mrs.Smith"]
190
190
  @config.merge!({"language" => "ja",
191
191
  "history" => [[
192
- "2011-08-03 v1.0.0版発行",
193
- "2012-02-15 v1.1.0版発行",
194
- ]] })
192
+ "2011-08-03 v1.0.0版発行",
193
+ "2012-02-15 v1.1.0版発行",
194
+ ]] })
195
195
  history = @maker.make_history_list
196
196
  expect = ["2011年8月3日 v1.0.0版発行",
197
197
  "2012年2月15日 v1.1.0版発行"]
@@ -204,9 +204,9 @@ class PDFMakerTest < Test::Unit::TestCase
204
204
  @config["pht"] = ["Mrs.Smith"]
205
205
  @config.merge!({"language" => "ja",
206
206
  "history" => [[
207
- "2011-08-03",
208
- "2012-02-15",
209
- ]] })
207
+ "2011-08-03",
208
+ "2012-02-15",
209
+ ]] })
210
210
  history = @maker.make_history_list
211
211
  expect = ["2011年8月3日 初版第1刷 発行",
212
212
  "2012年2月15日 初版第2刷 発行"]
@@ -219,13 +219,13 @@ class PDFMakerTest < Test::Unit::TestCase
219
219
  @config["pht"] = ["Mrs.Smith"]
220
220
  @config.merge!({"language" => "ja",
221
221
  "history" => [[
222
- "2011-08-03",
223
- "2012-02-15",
224
- ],[
225
- "2012-10-01",
226
- ],[
227
- "2013-03-01",
228
- ]] })
222
+ "2011-08-03",
223
+ "2012-02-15",
224
+ ],[
225
+ "2012-10-01",
226
+ ],[
227
+ "2013-03-01",
228
+ ]] })
229
229
  history = @maker.make_history_list
230
230
  expect = ["2011年8月3日 初版第1刷 発行",
231
231
  "2012年2月15日 初版第2刷 発行",
@@ -234,4 +234,22 @@ class PDFMakerTest < Test::Unit::TestCase
234
234
  assert_equal expect, history
235
235
  end
236
236
 
237
+ def test_colophon_history_freeformat
238
+ @config["aut"] = ["Mr.Smith"]
239
+ @config["pbl"] = ["BLUEPRINT"]
240
+ @config["pht"] = ["Mrs.Smith"]
241
+ @config.merge!({"language" => "ja",
242
+ "history" => [[
243
+ "2011年8月3日 ver 1.1.0発行",
244
+ ],[
245
+ "2011年10月12日 ver 1.2.0発行",
246
+ ],[
247
+ "2012年1月31日 ver 1.2.1発行",
248
+ ]] })
249
+ history = @maker.make_history_list
250
+ expect = ["2011年8月3日 ver 1.1.0発行",
251
+ "2011年10月12日 ver 1.2.0発行",
252
+ "2012年1月31日 ver 1.2.1発行"]
253
+ assert_equal expect, history
254
+ end
237
255
  end