review 1.0.0 → 1.1.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 (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
@@ -21,4 +21,8 @@ class HTMLUtilsTest < Test::Unit::TestCase
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ def test_strip_html
26
+ assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
27
+ end
24
28
  end
@@ -2,6 +2,10 @@
2
2
  require 'test_helper'
3
3
  require 'review/i18n'
4
4
 
5
+ require 'review/compiler'
6
+ require 'review/book'
7
+ require 'review/htmlbuilder'
8
+
5
9
  class I18nTest < Test::Unit::TestCase
6
10
  include ReVIEW
7
11
 
@@ -39,7 +43,7 @@ class I18nTest < Test::Unit::TestCase
39
43
  def test_htmlbuilder
40
44
  _setup_htmlbuilder
41
45
  @builder.headline(1,"test","this is test.")
42
- assert_equal %Q|<h1 id="test"><a id="h1" />Chapter 1. this is test.</h1>\n|, @builder.raw_result
46
+ assert_equal %Q|<h1 id="test"><a id="h1"></a>Chapter 1. this is test.</h1>\n|, @builder.raw_result
43
47
  end
44
48
 
45
49
  def _setup_htmlbuilder
@@ -53,7 +57,7 @@ class I18nTest < Test::Unit::TestCase
53
57
  }
54
58
  ReVIEW.book.param = @param
55
59
  @compiler = ReVIEW::Compiler.new(@builder)
56
- @chapter = Chapter.new(nil, 1, '-', nil, StringIO.new)
60
+ @chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
57
61
  location = Location.new(nil, nil)
58
62
  @builder.bind(@compiler, @chapter, location)
59
63
  end
@@ -4,6 +4,7 @@ require 'test_helper'
4
4
  require 'review/compiler'
5
5
  require 'review/book'
6
6
  require 'review/idgxmlbuilder'
7
+ require 'review/i18n'
7
8
 
8
9
  class IDGXMLBuidlerTest < Test::Unit::TestCase
9
10
  include ReVIEW
@@ -20,7 +21,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
20
21
  }
21
22
  ReVIEW.book.param = @param
22
23
  @compiler = ReVIEW::Compiler.new(@builder)
23
- @chapter = Chapter.new(nil, 1, '-', nil, StringIO.new)
24
+ @chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
24
25
  location = Location.new(nil, nil)
25
26
  @builder.bind(@compiler, @chapter, location)
26
27
  end
@@ -58,6 +59,11 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
58
59
  assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><label id='label_test' />|, @builder.raw_result
59
60
  end
60
61
 
62
+ def test_inline_ref
63
+ ret = @builder.compile_inline("@<ref>{外部参照<>&}")
64
+ assert_equal %Q|<ref idref='外部参照&lt;&gt;&amp;'>「●● 外部参照&lt;&gt;&amp;」</ref>|, ret
65
+ end
66
+
61
67
  def test_href
62
68
  ret = @builder.compile_href("http://github.com", "GitHub")
63
69
  assert_equal %Q|<a linkurl='http://github.com'>GitHub</a>|, ret
@@ -226,9 +232,20 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
226
232
  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
227
233
  end
228
234
 
235
+ def test_emlist_with_tab
236
+ @builder.emlist(["\ttest1", "\t\ttest1.5", "", "\ttest<i>2</i>"], "this is @<b>{test}<&>_")
237
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre> test1\n test1.5\n\n test<i>2</i>\n</pre></list>|, @builder.raw_result
238
+ end
239
+
240
+ def test_emlist_with_4tab
241
+ @builder.instance_eval{@tabwidth=4}
242
+ @builder.emlist(["\ttest1", "\t\ttest1.5", "", "\ttest<i>2</i>"], "this is @<b>{test}<&>_")
243
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre> test1\n test1.5\n\n test<i>2</i>\n</pre></list>|, @builder.raw_result
244
+ end
245
+
229
246
  def test_list
230
247
  def @chapter.list(id)
231
- ListIndex::Item.new("samplelist",1)
248
+ Book::ListIndex::Item.new("samplelist",1)
232
249
  end
233
250
  @builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_")
234
251
  assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></codelist>|, @builder.raw_result
@@ -236,7 +253,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
236
253
 
237
254
  def test_list_listinfo
238
255
  def @chapter.list(id)
239
- ListIndex::Item.new("samplelist",1)
256
+ Book::ListIndex::Item.new("samplelist",1)
240
257
  end
241
258
  @param["listinfo"] = true
242
259
  @builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_")
@@ -262,6 +279,11 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
262
279
  assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p align='right'>foobar</p><p align='right'>buz</p>|, @builder.raw_result
263
280
  end
264
281
 
282
+ def test_centering
283
+ @builder.centering(["foo", "bar", "","buz"])
284
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p align='center'>foobar</p><p align='center'>buz</p>|, @builder.raw_result
285
+ end
286
+
265
287
  def test_noindent
266
288
  @builder.noindent
267
289
  @builder.paragraph(["foo", "bar"])
@@ -271,7 +293,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
271
293
 
272
294
  def test_image
273
295
  def @chapter.image(id)
274
- item = ImageIndex::Item.new("sampleimg",1)
296
+ item = Book::ImageIndex::Item.new("sampleimg",1)
275
297
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
276
298
  item
277
299
  end
@@ -282,7 +304,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
282
304
 
283
305
  def test_image_with_metric
284
306
  def @chapter.image(id)
285
- item = ImageIndex::Item.new("sampleimg",1)
307
+ item = Book::ImageIndex::Item.new("sampleimg",1)
286
308
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
287
309
  item
288
310
  end
@@ -293,7 +315,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
293
315
 
294
316
  def test_image_with_metric2
295
317
  def @chapter.image(id)
296
- item = ImageIndex::Item.new("sampleimg",1)
318
+ item = Book::ImageIndex::Item.new("sampleimg",1)
297
319
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
298
320
  item
299
321
  end
@@ -304,7 +326,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
304
326
 
305
327
  def test_indepimage
306
328
  def @chapter.image(id)
307
- item = ImageIndex::Item.new("sampleimg",1)
329
+ item = Book::ImageIndex::Item.new("sampleimg",1)
308
330
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
309
331
  item
310
332
  end
@@ -315,7 +337,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
315
337
 
316
338
  def test_indepimage_without_caption
317
339
  def @chapter.image(id)
318
- item = ImageIndex::Item.new("sampleimg",1)
340
+ item = Book::ImageIndex::Item.new("sampleimg",1)
319
341
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
320
342
  item
321
343
  end
@@ -326,7 +348,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
326
348
 
327
349
  def test_indepimage_with_metric
328
350
  def @chapter.image(id)
329
- item = ImageIndex::Item.new("sampleimg",1)
351
+ item = Book::ImageIndex::Item.new("sampleimg",1)
330
352
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
331
353
  item
332
354
  end
@@ -337,7 +359,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
337
359
 
338
360
  def test_indepimage_with_metric2
339
361
  def @chapter.image(id)
340
- item = ImageIndex::Item.new("sampleimg",1)
362
+ item = Book::ImageIndex::Item.new("sampleimg",1)
341
363
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
342
364
  item
343
365
  end
@@ -348,7 +370,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
348
370
 
349
371
  def test_indepimage_without_caption_but_with_metric
350
372
  def @chapter.image(id)
351
- item = ImageIndex::Item.new("sampleimg",1)
373
+ item = Book::ImageIndex::Item.new("sampleimg",1)
352
374
  item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
353
375
  item
354
376
  end
@@ -0,0 +1,247 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test_helper'
3
+ require 'book_test_helper'
4
+ require 'review'
5
+
6
+ class INAOBuidlerTest < Test::Unit::TestCase
7
+ include ReVIEW
8
+ include BookTestHelper
9
+
10
+ def setup
11
+ param = {
12
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
13
+ "inencoding" => "UTF-8",
14
+ "outencoding" => "UTF-8",
15
+ "subdirmode" => nil,
16
+ "stylesheet" => nil, # for HTMLBuilder
17
+ }
18
+ ReVIEW.book.param = param
19
+ end
20
+
21
+ def test_all
22
+ compiler = Compiler.new(INAOBuilder.new)
23
+ mktmpbookdir do |dir, book, files|
24
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
25
+ chapter.content = <<-EOS
26
+ = 見出し1(大見出し、節)
27
+ == 見出し2(中見出し、項)
28
+ === 見出し3(小見出し、目)
29
+ 段落冒頭の字下げは、自動で行われます。
30
+ 改行は、(改行)
31
+ このように自動で取り除かれます。
32
+
33
+ 通常の本文@<b>{強調(ボールド)}通常の本文@<i>{斜体(イタリック)}通常の本文@<tt>{インラインのコード}通常の本文@<fn>{1}通常の本文@<kbd>{Enter}(←キーボードフォント)通常の本文@<ruby>{外村,ほかむら}(←ルビ)。
34
+
35
+ //footnote[1][脚注]
36
+
37
+ //quote{
38
+ 引用です
39
+ //}
40
+
41
+ ====[column]コラム見出し
42
+ 本文コラム
43
+ ===== コラム小見出し
44
+ 本文コラム
45
+ ====[/column]
46
+
47
+ == 箇条書き
48
+ === 通常の箇条書き
49
+ * 連番箇条書き
50
+ * 連番箇条書き
51
+ === 連番箇条書き
52
+ 1. 連番箇条書き
53
+ 2. 連番箇条書き
54
+
55
+ == コマンド
56
+ //cmd[コマンドのタイトル]{
57
+ $ command foo
58
+ //}
59
+
60
+ === 本文埋め込みコマンド(本文埋め込み版はWEB+DB PRESSでは未使用)
61
+ //cmd{
62
+ $ command foo
63
+ //}
64
+
65
+ == 表
66
+ //table[id][表のタイトル]{
67
+ 項目1 項目2
68
+ -------------
69
+ 内容1 内容2
70
+ 内容1 内容2
71
+ //}
72
+
73
+ EOS
74
+
75
+ expected = <<-EOS
76
+ ■見出し1(大見出し、節)
77
+ ■■見出し2(中見出し、項)
78
+ ■■■見出し3(小見出し、目)
79
+  段落冒頭の字下げは、自動で行われます。改行は、(改行)このように自動で取り除かれます。
80
+  通常の本文◆b/◆強調(ボールド)◆/b◆通常の本文◆i/◆斜体(イタリック)◆/i◆通常の本文◆cmd/◆インラインのコード◆/cmd◆通常の本文◆注/◆脚注◆/注◆通常の本文Enter▲(←キーボードフォント)通常の本文◆ルビ/◆外村◆ほかむら◆/ルビ◆(←ルビ)。
81
+ ◆quote/◆
82
+ 引用です
83
+ ◆/quote◆
84
+
85
+ ◆column/◆
86
+ ■■■■コラム見出し
87
+  本文コラム
88
+ ■■■■■コラム小見出し
89
+  本文コラム
90
+ ◆/column◆
91
+ ■■箇条書き
92
+ ■■■通常の箇条書き
93
+ ・連番箇条書き
94
+ ・連番箇条書き
95
+ ■■■連番箇条書き
96
+ (1)連番箇条書き
97
+ (2)連番箇条書き
98
+ ■■コマンド
99
+ ◆list-white/◆
100
+ ●コマンドのタイトル
101
+ $ command foo
102
+ ◆/list-white◆
103
+ ■■■本文埋め込みコマンド(本文埋め込み版はWEB+DB PRESSでは未使用)
104
+ ◆list-white/◆
105
+ $ command foo
106
+ ◆/list-white◆
107
+ ■■表
108
+ ◆table/◆
109
+ ●表1.1 表のタイトル
110
+ ◆table-title◆項目1 項目2
111
+ 内容1 内容2
112
+ 内容1 内容2
113
+ ◆/table◆
114
+ EOS
115
+ assert_equal expected, compiler.compile(chapter)
116
+ end
117
+ end
118
+
119
+ def test_list
120
+ compiler = Compiler.new(INAOBuilder.new)
121
+ mktmpbookdir do |dir, book, files|
122
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
123
+ chapter.content = <<-EOS
124
+ == リスト
125
+ @<list>{id}
126
+ //list[id][キャプション(コードのタイトル)]{
127
+ function hoge() {
128
+ alert(foo);
129
+ alert(bar);
130
+ }
131
+ //}
132
+
133
+ === 本文埋め込みリスト
134
+ 本文中で流れでコードを掲載するときに使用します。
135
+
136
+ //emlist{
137
+ function hoge() {
138
+ alert(foo);@<comment>{こんな風にコメントがつけられます}
139
+ }
140
+ //}
141
+
142
+ このように、上下に本文が入ります。
143
+
144
+ 本文から一連の流れで読んでもらうことができますが、コードがページをまたぐ可能性がございます。
145
+ EOS
146
+ expected = <<-EOS
147
+ ■■リスト
148
+  リスト1.1
149
+ ◆list/◆
150
+ ●リスト1.1 キャプション(コードのタイトル)
151
+ function hoge() {
152
+ alert(foo);
153
+ alert(bar);
154
+ }
155
+ ◆/list◆
156
+ ■■■本文埋め込みリスト
157
+  本文中で流れでコードを掲載するときに使用します。
158
+ ◆list/◆
159
+ function hoge() {
160
+ alert(foo);◆comment/◆こんな風にコメントがつけられます◆/comment◆
161
+ }
162
+ ◆/list◆
163
+  このように、上下に本文が入ります。
164
+  本文から一連の流れで読んでもらうことができますが、コードがページをまたぐ可能性がございます。
165
+ EOS
166
+ assert_equal expected, compiler.compile(chapter)
167
+ end
168
+ end
169
+
170
+ def test_image
171
+ compiler = Compiler.new(INAOBuilder.new)
172
+ mktmpbookdir do |dir, book, files|
173
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
174
+ chapter.content = <<-EOS
175
+ = 図
176
+ @<img>{id}
177
+ //image[id][図のタイトル]{
178
+ ダミー
179
+ //}
180
+ EOS
181
+ expected = <<-EOS
182
+ ■図
183
+  図1.1
184
+ ●図1.1 図のタイトル
185
+ ダミー
186
+ EOS
187
+ assert_equal expected, compiler.compile(chapter)
188
+ end
189
+ end
190
+
191
+ def test_table
192
+ compiler = Compiler.new(INAOBuilder.new)
193
+ mktmpbookdir do |dir, book, files|
194
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
195
+ chapter.content = <<-EOS
196
+ == 表
197
+ @<table>{id}
198
+ //table[id][表のタイトル]{
199
+ 項目1 項目2
200
+ -------------
201
+ 内容1 内容2
202
+ 内容1 内容2
203
+ //}
204
+ EOS
205
+ expected = <<-EOS
206
+ ■■表
207
+  表1.1
208
+ ◆table/◆
209
+ ●表1.1 表のタイトル
210
+ ◆table-title◆項目1 項目2
211
+ 内容1 内容2
212
+ 内容1 内容2
213
+ ◆/table◆
214
+ EOS
215
+ assert_equal expected, compiler.compile(chapter)
216
+ end
217
+ end
218
+
219
+ def test_listnum
220
+ compiler = Compiler.new(INAOBuilder.new)
221
+ mktmpbookdir do |dir, book, files|
222
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
223
+ chapter.content = <<-EOS
224
+ == リスト
225
+ @<list>{id}
226
+ //listnum[id][キャプション(コードのタイトル)]{
227
+ function hoge() {
228
+ alert(foo);
229
+ alert(bar);
230
+ }
231
+ //}
232
+ EOS
233
+ expected = <<-EOS
234
+ ■■リスト
235
+  リスト1.1
236
+ ◆list/◆
237
+ ●リスト1.1 キャプション(コードのタイトル)
238
+ 1 function hoge() {
239
+ 2 alert(foo);
240
+ 3 alert(bar);
241
+ 4 }
242
+ ◆/list◆
243
+ EOS
244
+ assert_equal expected, compiler.compile(chapter)
245
+ end
246
+ end
247
+ end
@@ -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
+