review 1.2.0 → 1.3.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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +36 -0
  3. data/.rubocop.yml +1 -0
  4. data/ChangeLog +102 -0
  5. data/README.rdoc +2 -2
  6. data/bin/review-check +18 -16
  7. data/bin/review-compile +49 -42
  8. data/bin/review-epubmaker +23 -993
  9. data/bin/review-epubmaker-legacy +1024 -0
  10. data/bin/review-index +17 -15
  11. data/bin/review-init +39 -9
  12. data/bin/review-pdfmaker +124 -89
  13. data/bin/review-preproc +16 -14
  14. data/bin/review-vol +17 -15
  15. data/debian/docs +1 -1
  16. data/doc/catalog.rdoc +34 -0
  17. data/doc/format.rdoc +16 -2
  18. data/doc/libepubmaker/{config.yaml → config.yml} +63 -19
  19. data/doc/quickstart.rdoc +1 -1
  20. data/doc/{sample.yaml → sample.yml} +0 -0
  21. data/lib/epubmaker.rb +1 -1
  22. data/lib/epubmaker/content.rb +9 -1
  23. data/lib/epubmaker/epubv2.rb +59 -7
  24. data/lib/epubmaker/epubv3.rb +14 -9
  25. data/lib/epubmaker/producer.rb +68 -27
  26. data/lib/epubmaker/resource.rb +3 -1
  27. data/lib/lineinput.rb +2 -2
  28. data/lib/review/book/base.rb +125 -24
  29. data/lib/review/book/chapter.rb +42 -0
  30. data/lib/review/book/compilable.rb +23 -4
  31. data/lib/review/book/image_finder.rb +64 -0
  32. data/lib/review/book/index.rb +64 -50
  33. data/lib/review/book/page_metric.rb +1 -1
  34. data/lib/review/builder.rb +19 -12
  35. data/lib/review/catalog.rb +47 -0
  36. data/lib/review/compiler.rb +3 -2
  37. data/lib/review/configure.rb +5 -3
  38. data/lib/review/epubmaker.rb +130 -46
  39. data/lib/review/ewbbuilder.rb +27 -31
  40. data/lib/review/extentions/string.rb +4 -4
  41. data/lib/review/htmlbuilder.rb +140 -79
  42. data/lib/review/htmllayout.rb +26 -4
  43. data/lib/review/htmlutils.rb +20 -1
  44. data/lib/review/i18n.rb +5 -2
  45. data/lib/review/{i18n.yaml → i18n.yml} +4 -2
  46. data/lib/review/idgxmlbuilder.rb +65 -39
  47. data/lib/review/latexbuilder.rb +72 -24
  48. data/lib/review/latexutils.rb +3 -1
  49. data/lib/review/makerhelper.rb +8 -2
  50. data/lib/review/preprocessor.rb +20 -20
  51. data/lib/review/review.tex.erb +4 -0
  52. data/lib/review/sec_counter.rb +9 -11
  53. data/lib/review/tocparser.rb +2 -2
  54. data/lib/review/tocprinter.rb +12 -12
  55. data/lib/review/topbuilder.rb +15 -15
  56. data/lib/review/version.rb +1 -1
  57. data/lib/uuid.rb +7 -7
  58. data/review.gemspec +2 -2
  59. data/rubocop-todo.yml +443 -0
  60. data/test/sample-book/src/config.yml +2 -2
  61. data/test/sample-book/src/{main.css → style.css} +0 -0
  62. data/test/test_book.rb +46 -48
  63. data/test/test_book_chapter.rb +25 -13
  64. data/test/test_builder.rb +3 -3
  65. data/test/test_catalog.rb +107 -0
  66. data/test/test_epubmaker.rb +6 -6
  67. data/test/test_htmlbuilder.rb +160 -39
  68. data/test/test_htmlutils.rb +22 -0
  69. data/test/test_i18n.rb +2 -2
  70. data/test/test_idgxmlbuilder.rb +33 -47
  71. data/test/test_image_finder.rb +82 -0
  72. data/test/test_inaobuilder.rb +1 -1
  73. data/test/test_latexbuilder.rb +35 -39
  74. data/test/test_lineinput.rb +2 -2
  75. data/test/test_markdownbuilder.rb +2 -2
  76. data/test/test_topbuilder.rb +39 -23
  77. metadata +23 -14
  78. data/bin/review-epubmaker-ng +0 -23
@@ -11,14 +11,14 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
11
11
 
12
12
  def setup
13
13
  @builder = IDGXMLBuilder.new()
14
- @param = {
14
+ @config = {
15
15
  "secnolevel" => 2,
16
16
  "inencoding" => "UTF-8",
17
17
  "outencoding" => "UTF-8",
18
18
  "nolf" => true,
19
19
  "tableopt" => "10"
20
20
  }
21
- ReVIEW.book.param = @param
21
+ ReVIEW.book.config = @config
22
22
  @compiler = ReVIEW::Compiler.new(@builder)
23
23
  @chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
24
24
  location = Location.new(nil, nil)
@@ -31,7 +31,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
31
31
  end
32
32
 
33
33
  def test_headline_level1_without_secno
34
- @param["secnolevel"] = 0
34
+ @config["secnolevel"] = 0
35
35
  @builder.headline(1,"test","this is test.")
36
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
37
  end
@@ -48,7 +48,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
48
48
 
49
49
 
50
50
  def test_headline_level3_with_secno
51
- @param["secnolevel"] = 3
51
+ @config["secnolevel"] = 3
52
52
  @builder.headline(3,"test","this is test.")
53
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
54
  end
@@ -94,17 +94,17 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
94
94
  end
95
95
 
96
96
  def test_inline_in_table_without_cellwidth
97
- @param["tableopt"] = nil
97
+ @config["tableopt"] = nil
98
98
  ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
99
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
100
+ @config["tableopt"] = 10
101
101
  end
102
102
 
103
103
  def test_inline_in_table_without_header_and_cellwidth
104
- @param["tableopt"] = nil
104
+ @config["tableopt"] = nil
105
105
  ret = @builder.table(["<b>1</b>\t<i>2</i>", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
106
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
107
+ @config["tableopt"] = 10
108
108
  end
109
109
 
110
110
  def test_inline_br
@@ -172,9 +172,9 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
172
172
 
173
173
  def test_quote_deprecated
174
174
  lines = ["foo","","buz"]
175
- ReVIEW.book.param["deprecated-blocklines"] = true
175
+ ReVIEW.book.config["deprecated-blocklines"] = true
176
176
  @builder.quote(lines)
177
- ReVIEW.book.param["deprecated-blocklines"] = nil
177
+ ReVIEW.book.config["deprecated-blocklines"] = nil
178
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
179
  end
180
180
 
@@ -194,9 +194,9 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
194
194
  end
195
195
 
196
196
  def test_term_deprecated
197
- ReVIEW.book.param["deprecated-blocklines"] = true
197
+ ReVIEW.book.config["deprecated-blocklines"] = true
198
198
  @builder.term(["test1", "test1.5", "", "test<i>2</i>"])
199
- ReVIEW.book.param["deprecated-blocklines"] = nil
199
+ ReVIEW.book.config["deprecated-blocklines"] = nil
200
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
201
  end
202
202
 
@@ -226,7 +226,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
226
226
  end
227
227
 
228
228
  def test_emlist_listinfo
229
- @param["listinfo"] = true
229
+ @config["listinfo"] = true
230
230
  @builder.emlist(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
231
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
232
  end
@@ -254,22 +254,22 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
254
254
  def @chapter.list(id)
255
255
  Book::ListIndex::Item.new("samplelist",1)
256
256
  end
257
- @param["listinfo"] = true
257
+ @config["listinfo"] = true
258
258
  @builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_")
259
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
260
  end
261
261
 
262
262
  def test_insn
263
- @param["listinfo"] = true
263
+ @config["listinfo"] = true
264
264
  @builder.insn(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
265
- @param["listinfo"] = nil
265
+ @config["listinfo"] = nil
266
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
267
  end
268
268
 
269
269
  def test_box
270
- @param["listinfo"] = true
270
+ @config["listinfo"] = true
271
271
  @builder.box(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
272
- @param["listinfo"] = nil
272
+ @config["listinfo"] = nil
273
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
274
  end
275
275
 
@@ -293,7 +293,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
293
293
  def test_image
294
294
  def @chapter.image(id)
295
295
  item = Book::ImageIndex::Item.new("sampleimg",1)
296
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
296
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
297
297
  item
298
298
  end
299
299
 
@@ -304,7 +304,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
304
304
  def test_image_with_metric
305
305
  def @chapter.image(id)
306
306
  item = Book::ImageIndex::Item.new("sampleimg",1)
307
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
307
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
308
308
  item
309
309
  end
310
310
 
@@ -315,7 +315,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
315
315
  def test_image_with_metric2
316
316
  def @chapter.image(id)
317
317
  item = Book::ImageIndex::Item.new("sampleimg",1)
318
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
318
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
319
319
  item
320
320
  end
321
321
 
@@ -326,7 +326,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
326
326
  def test_indepimage
327
327
  def @chapter.image(id)
328
328
  item = Book::ImageIndex::Item.new("sampleimg",1)
329
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
329
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
330
330
  item
331
331
  end
332
332
 
@@ -337,7 +337,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
337
337
  def test_indepimage_without_caption
338
338
  def @chapter.image(id)
339
339
  item = Book::ImageIndex::Item.new("sampleimg",1)
340
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
340
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
341
341
  item
342
342
  end
343
343
 
@@ -348,7 +348,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
348
348
  def test_indepimage_with_metric
349
349
  def @chapter.image(id)
350
350
  item = Book::ImageIndex::Item.new("sampleimg",1)
351
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
351
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
352
352
  item
353
353
  end
354
354
 
@@ -359,7 +359,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
359
359
  def test_indepimage_with_metric2
360
360
  def @chapter.image(id)
361
361
  item = Book::ImageIndex::Item.new("sampleimg",1)
362
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
362
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
363
363
  item
364
364
  end
365
365
 
@@ -370,7 +370,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
370
370
  def test_indepimage_without_caption_but_with_metric
371
371
  def @chapter.image(id)
372
372
  item = Book::ImageIndex::Item.new("sampleimg",1)
373
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
373
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
374
374
  item
375
375
  end
376
376
 
@@ -398,7 +398,7 @@ inside column
398
398
  EOS
399
399
  expect =<<-EOS
400
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>
401
+ <doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column id="column-1"><title aid:pstyle="column-title">prev column</title><p>inside prev column</p></column><column id="column-2"><title aid:pstyle="column-title">test</title><p>inside column</p></column></doc>
402
402
  EOS
403
403
  assert_equal expect, column_helper(review)
404
404
  end
@@ -413,7 +413,7 @@ inside column
413
413
  EOS
414
414
  expect =<<-EOS
415
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>
416
+ <doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><column id="column-1"><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
417
  EOS
418
418
 
419
419
  assert_equal expect, column_helper(review)
@@ -557,45 +557,31 @@ EOS
557
557
 
558
558
  def test_block_raw0
559
559
  @builder.raw("<>!\"\\n& ")
560
- expect =<<-EOS
561
- <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!"
562
- &
563
- EOS
560
+ expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"\n& )
564
561
  assert_equal expect.chomp, @builder.raw_result
565
562
  end
566
563
 
567
564
  def test_block_raw1
568
565
  @builder.raw("|idgxml|<>!\"\\n& ")
569
- expect =<<-EOS
570
- <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!"
571
- &
572
- EOS
566
+ expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"\n& )
573
567
  assert_equal expect.chomp, @builder.raw_result
574
568
  end
575
569
 
576
570
  def test_block_raw2
577
571
  @builder.raw("|idgxml, latex|<>!\"\\n& ")
578
- expect =<<-EOS
579
- <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"
580
- &
581
- EOS
572
+ expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><>!\"\n& )
582
573
  assert_equal expect.chomp, @builder.raw_result
583
574
  end
584
575
 
585
576
  def test_block_raw3
586
577
  @builder.raw("|latex, html|<>!\"\\n& ")
587
- expect =<<-EOS
588
- <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">
589
- EOS
578
+ expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">)
590
579
  assert_equal expect.chomp, @builder.raw_result
591
580
  end
592
581
 
593
582
  def test_block_raw4
594
583
  @builder.raw("|idgxml <>!\"\\n& ")
595
- expect =<<-EOS
596
- <?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">|idgxml <>!\"
597
- &
598
- EOS
584
+ expect = %Q(<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">|idgxml <>!\"\n& )
599
585
  assert_equal expect.chomp, @builder.raw_result
600
586
  end
601
587
 
@@ -0,0 +1,82 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test_helper'
3
+ require 'review'
4
+ require 'review/book/image_finder'
5
+ require 'fileutils'
6
+
7
+ class ImageFinderTest < Test::Unit::TestCase
8
+ include ReVIEW
9
+
10
+ def setup
11
+ end
12
+
13
+ def test_find_path_pattern1
14
+ dir = Dir.mktmpdir
15
+ begin
16
+ path = dir+"/builder/ch01/foo.jpg"
17
+ FileUtils.mkdir_p(File.dirname(path))
18
+ FileUtils.touch(path)
19
+
20
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
21
+ assert_equal(path, finder.find_path("foo"))
22
+ ensure
23
+ FileUtils.remove_entry_secure dir
24
+ end
25
+ end
26
+
27
+ def test_find_path_pattern2
28
+ dir = Dir.mktmpdir
29
+ begin
30
+ path = dir+"/builder/ch01-foo.jpg"
31
+ FileUtils.mkdir_p(File.dirname(path))
32
+ FileUtils.touch(path)
33
+
34
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
35
+ assert_equal(path, finder.find_path("foo"))
36
+ ensure
37
+ FileUtils.remove_entry_secure dir
38
+ end
39
+ end
40
+
41
+ def test_find_path_pattern3
42
+ dir = Dir.mktmpdir
43
+ begin
44
+ path = dir+"/builder/foo.jpg"
45
+ FileUtils.mkdir_p(File.dirname(path))
46
+ FileUtils.touch(path)
47
+
48
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
49
+ assert_equal(path, finder.find_path("foo"))
50
+ ensure
51
+ FileUtils.remove_entry_secure dir
52
+ end
53
+ end
54
+
55
+ def test_find_path_pattern4
56
+ dir = Dir.mktmpdir
57
+ begin
58
+ path = dir+"/ch01/foo.jpg"
59
+ FileUtils.mkdir_p(File.dirname(path))
60
+ FileUtils.touch(path)
61
+
62
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
63
+ assert_equal(path, finder.find_path("foo"))
64
+ ensure
65
+ FileUtils.remove_entry_secure dir
66
+ end
67
+ end
68
+
69
+ def test_find_path_pattern5
70
+ dir = Dir.mktmpdir
71
+ begin
72
+ path = dir+"/ch01-foo.jpg"
73
+ FileUtils.mkdir_p(File.dirname(path))
74
+ FileUtils.touch(path)
75
+
76
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
77
+ assert_equal(path, finder.find_path("foo"))
78
+ ensure
79
+ FileUtils.remove_entry_secure dir
80
+ end
81
+ end
82
+ end
@@ -14,7 +14,7 @@ class INAOBuidlerTest < Test::Unit::TestCase
14
14
  "outencoding" => "UTF-8",
15
15
  "stylesheet" => nil, # for HTMLBuilder
16
16
  }
17
- ReVIEW.book.param = param
17
+ ReVIEW.book.config = param
18
18
  end
19
19
 
20
20
  def test_all
@@ -10,16 +10,16 @@ class LATEXBuidlerTest < Test::Unit::TestCase
10
10
 
11
11
  def setup
12
12
  @builder = LATEXBuilder.new()
13
- @param = {
13
+ @config = {
14
14
  "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
15
15
  "toclevel" => 2,
16
16
  "inencoding" => "UTF-8",
17
17
  "outencoding" => "UTF-8",
18
18
  "stylesheet" => nil, # for EPUBBuilder
19
19
  }
20
- ReVIEW.book.param = @param
20
+ ReVIEW.book.config = @config
21
21
  @compiler = ReVIEW::Compiler.new(@builder)
22
- @chapter = Book::Chapter.new(nil, 1, 'chap1', nil, StringIO.new)
22
+ @chapter = Book::Chapter.new(Book::Base.new(nil), 1, 'chap1', nil, StringIO.new)
23
23
  location = Location.new(nil, nil)
24
24
  @builder.bind(@compiler, @chapter, location)
25
25
  end
@@ -30,7 +30,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  def test_headline_level1_without_secno
33
- @param["secnolevel"] = 0
33
+ @config["secnolevel"] = 0
34
34
  @builder.headline(1,"test","this is test.")
35
35
  assert_equal %Q|\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n|, @builder.result
36
36
  end
@@ -42,19 +42,19 @@ class LATEXBuidlerTest < Test::Unit::TestCase
42
42
 
43
43
  def test_headline_level2
44
44
  @builder.headline(2,"test","this is test.")
45
- assert_equal %Q|\\section{this is test.}\n|, @builder.result
45
+ assert_equal %Q|\\section{this is test.}\n\\label{sec:1-1}\n|, @builder.result
46
46
  end
47
47
 
48
48
  def test_headline_level3
49
49
  @builder.headline(3,"test","this is test.")
50
- assert_equal %Q|\\subsection*{this is test.}\n|, @builder.result
50
+ assert_equal %Q|\\subsection*{this is test.}\n\\label{sec:1-0-1}\n|, @builder.result
51
51
  end
52
52
 
53
53
 
54
54
  def test_headline_level3_with_secno
55
- @param["secnolevel"] = 3
55
+ @config["secnolevel"] = 3
56
56
  @builder.headline(3,"test","this is test.")
57
- assert_equal %Q|\\subsection{this is test.}\n|, @builder.result
57
+ assert_equal %Q|\\subsection{this is test.}\n\\label{sec:1-0-1}\n|, @builder.result
58
58
  end
59
59
 
60
60
  def test_label
@@ -97,11 +97,6 @@ class LATEXBuidlerTest < Test::Unit::TestCase
97
97
  assert_equal %Q|abc\\\\\ndef|, ret
98
98
  end
99
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
100
  def test_inline_i
106
101
  ret = @builder.compile_inline("abc@<i>{def}ghi")
107
102
  assert_equal %Q|abc\\textit{def}ghi|, ret
@@ -192,6 +187,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
192
187
  Book::HeadlineIndex.new(items, self)
193
188
  end
194
189
 
190
+ @config["secnolevel"] = 3
195
191
  ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
196
192
  assert_equal %Q|test 「1.1.1 te\\textunderscore{}st」 test2|, ret
197
193
  end
@@ -206,6 +202,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
206
202
  assert_equal %Q|test \\UTF{2460} test2|, ret
207
203
  end
208
204
 
205
+ def test_inline_idx
206
+ ret = @builder.compile_inline("@<idx>{__TEST%$}, @<hidx>{__TEST%$}")
207
+ assert_equal %Q|\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$}, \\index{__TEST%$}|, ret
208
+ end
209
+
209
210
  def test_jis_x_0201_kana
210
211
  ret = @builder.compile_inline("foo・カンジ、テスト")
211
212
  assert_equal %Q|foo\\aj半角{・}\\aj半角{カ}\\aj半角{ン}\\aj半角{シ}\\aj半角{゛}\\aj半角{、}テスト|, ret
@@ -295,7 +296,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
295
296
  def test_image
296
297
  def @chapter.image(id)
297
298
  item = Book::ImageIndex::Item.new("sampleimg",1)
298
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
299
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
299
300
  item
300
301
  end
301
302
 
@@ -306,7 +307,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
306
307
  def test_image_with_metric
307
308
  def @chapter.image(id)
308
309
  item = Book::ImageIndex::Item.new("sampleimg",1)
309
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
310
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
310
311
  item
311
312
  end
312
313
 
@@ -317,7 +318,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
317
318
  def test_image_with_metric2
318
319
  def @chapter.image(id)
319
320
  item = Book::ImageIndex::Item.new("sampleimg",1)
320
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
321
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
321
322
  item
322
323
  end
323
324
 
@@ -328,7 +329,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
328
329
  def test_indepimage
329
330
  def @chapter.image(id)
330
331
  item = Book::ImageIndex::Item.new("sampleimg",1)
331
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
332
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
332
333
  item
333
334
  end
334
335
 
@@ -339,7 +340,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
339
340
  def test_indepimage_without_caption
340
341
  def @chapter.image(id)
341
342
  item = Book::ImageIndex::Item.new("sampleimg",1)
342
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
343
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
343
344
  item
344
345
  end
345
346
 
@@ -351,7 +352,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
351
352
  def test_indepimage_with_metric
352
353
  def @chapter.image(id)
353
354
  item = Book::ImageIndex::Item.new("sampleimg",1)
354
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
355
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
355
356
  item
356
357
  end
357
358
 
@@ -362,7 +363,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
362
363
  def test_indepimage_with_metric2
363
364
  def @chapter.image(id)
364
365
  item = Book::ImageIndex::Item.new("sampleimg",1)
365
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
366
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
366
367
  item
367
368
  end
368
369
 
@@ -373,7 +374,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
373
374
  def test_indepimage_without_caption_but_with_metric
374
375
  def @chapter.image(id)
375
376
  item = Book::ImageIndex::Item.new("sampleimg",1)
376
- item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
377
+ item.instance_eval{@path="./images/chap1-sampleimg.png"}
377
378
  item
378
379
  end
379
380
 
@@ -429,19 +430,24 @@ EOS
429
430
  expect =<<-EOS
430
431
 
431
432
  \\begin{reviewcolumn}
433
+ \\hypertarget{column:chap1:1}{}
432
434
  \\reviewcolumnhead{}{prev column}
435
+ \\addcontentsline{toc}{subsection}{prev column}
433
436
 
434
437
  inside prev column
435
438
 
436
439
  \\end{reviewcolumn}
437
440
 
438
441
  \\begin{reviewcolumn}
442
+ \\hypertarget{column:chap1:2}{}
439
443
  \\reviewcolumnhead{}{test}
444
+ \\addcontentsline{toc}{subsection}{test}
440
445
 
441
446
  inside column
442
447
 
443
448
  \\end{reviewcolumn}
444
449
  EOS
450
+ @config["toclevel"] = 3
445
451
  assert_equal expect, column_helper(review)
446
452
  end
447
453
 
@@ -456,6 +462,7 @@ EOS
456
462
  expect =<<-EOS
457
463
 
458
464
  \\begin{reviewcolumn}
465
+ \\hypertarget{column:chap1:1}{}
459
466
  \\reviewcolumnhead{}{test}
460
467
 
461
468
  inside column
@@ -463,8 +470,10 @@ inside column
463
470
  \\end{reviewcolumn}
464
471
 
465
472
  \\subsection*{next level}
473
+ \\label{sec:1-0-1}
466
474
  EOS
467
475
 
476
+ @config["toclevel"] = 1
468
477
  assert_equal expect, column_helper(review)
469
478
  end
470
479
 
@@ -638,44 +647,31 @@ EOS
638
647
 
639
648
  def test_block_raw0
640
649
  @builder.raw("<>!\"\\n& ")
641
- expect =<<-EOS
642
- <>!"
643
- &
644
- EOS
650
+ expect = %Q(<>!\"\n& )
645
651
  assert_equal expect.chomp, @builder.raw_result
646
652
  end
647
653
 
648
654
  def test_block_raw1
649
655
  @builder.raw("|latex|<>!\"\\n& ")
650
- expect =<<-EOS
651
- <>!"
652
- &
653
- EOS
656
+ expect = %Q(<>!\"\n& )
654
657
  assert_equal expect.chomp, @builder.raw_result
655
658
  end
656
659
 
657
660
  def test_block_raw2
658
661
  @builder.raw("|html, latex|<>!\"\\n& ")
659
- expect =<<-EOS
660
- <>!\"
661
- &
662
- EOS
662
+ expect = %Q(<>!\"\n& )
663
663
  assert_equal expect.chomp, @builder.raw_result
664
664
  end
665
665
 
666
666
  def test_block_raw3
667
667
  @builder.raw("|html, idgxml|<>!\"\\n& ")
668
- expect =<<-EOS
669
- EOS
668
+ expect = ''
670
669
  assert_equal expect.chomp, @builder.raw_result
671
670
  end
672
671
 
673
672
  def test_block_raw4
674
673
  @builder.raw("|latex <>!\"\\n& ")
675
- expect =<<-EOS
676
- |latex <>!\"
677
- &
678
- EOS
674
+ expect = %Q(|latex <>!\"\n& )
679
675
  assert_equal expect.chomp, @builder.raw_result
680
676
  end
681
677