review 3.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-win.yml +39 -0
  3. data/.github/workflows/ruby.yml +27 -0
  4. data/.rubocop.yml +50 -12
  5. data/.travis.yml +17 -8
  6. data/Dockerfile +21 -5
  7. data/NEWS.ja.md +358 -0
  8. data/NEWS.md +358 -1
  9. data/README.md +11 -8
  10. data/appveyor.yml +1 -3
  11. data/bin/review-catalog-converter +4 -4
  12. data/bin/review-check +8 -8
  13. data/bin/review-checkdep +1 -1
  14. data/bin/review-compile +12 -12
  15. data/bin/review-epubmaker +3 -35
  16. data/bin/review-idgxmlmaker +16 -0
  17. data/bin/review-index +2 -89
  18. data/bin/review-preproc +14 -19
  19. data/bin/review-validate +3 -3
  20. data/bin/review-vol +4 -78
  21. data/doc/LICENSE +1 -1
  22. data/doc/config.yml.sample +46 -12
  23. data/doc/config.yml.sample-simple +4 -2
  24. data/doc/format.ja.md +37 -13
  25. data/doc/format.md +35 -20
  26. data/doc/pdfmaker.ja.md +43 -1
  27. data/doc/pdfmaker.md +42 -1
  28. data/doc/quickstart.ja.md +46 -26
  29. data/doc/quickstart.md +38 -17
  30. data/lib/epubmaker/epubcommon.rb +10 -5
  31. data/lib/epubmaker/epubv2.rb +1 -1
  32. data/lib/epubmaker/epubv3.rb +1 -0
  33. data/lib/epubmaker/producer.rb +4 -2
  34. data/lib/review/book.rb +1 -1
  35. data/lib/review/book/base.rb +38 -79
  36. data/lib/review/book/chapter.rb +18 -3
  37. data/lib/review/book/compilable.rb +6 -5
  38. data/lib/review/book/index.rb +69 -101
  39. data/lib/review/book/index/item.rb +40 -0
  40. data/lib/review/book/page_metric.rb +7 -7
  41. data/lib/review/book/part.rb +28 -5
  42. data/lib/review/book/volume.rb +3 -4
  43. data/lib/review/builder.rb +105 -44
  44. data/lib/review/catalog.rb +13 -16
  45. data/lib/review/compiler.rb +84 -72
  46. data/lib/review/configure.rb +19 -8
  47. data/lib/review/epub2html.rb +37 -4
  48. data/lib/review/epubmaker.rb +62 -7
  49. data/lib/review/extentions/string.rb +0 -4
  50. data/lib/review/htmlbuilder.rb +102 -115
  51. data/lib/review/htmlutils.rb +2 -3
  52. data/lib/review/i18n.rb +2 -2
  53. data/lib/review/i18n.yml +9 -0
  54. data/lib/review/idgxmlbuilder.rb +153 -74
  55. data/lib/review/idgxmlmaker.rb +191 -0
  56. data/lib/review/init-web/finish.html +10 -0
  57. data/lib/review/init-web/index.html +190 -0
  58. data/lib/review/init-web/review-layout-design.js +691 -0
  59. data/lib/review/init.rb +125 -34
  60. data/lib/review/latexbuilder.rb +199 -88
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/location.rb +32 -0
  63. data/lib/review/logger.rb +4 -8
  64. data/lib/review/makerhelper.rb +24 -5
  65. data/lib/review/markdownbuilder.rb +31 -37
  66. data/lib/review/md2inaobuilder.rb +3 -5
  67. data/lib/review/pdfmaker.rb +44 -22
  68. data/lib/review/plaintextbuilder.rb +106 -85
  69. data/lib/review/preprocessor.rb +32 -41
  70. data/lib/review/rstbuilder.rb +33 -33
  71. data/lib/review/textmaker.rb +19 -3
  72. data/lib/review/textutils.rb +76 -2
  73. data/lib/review/tocprinter.rb +231 -102
  74. data/lib/review/topbuilder.rb +114 -61
  75. data/lib/review/update.rb +19 -19
  76. data/lib/review/version.rb +1 -1
  77. data/lib/review/volumeprinter.rb +99 -0
  78. data/lib/review/webmaker.rb +11 -4
  79. data/lib/review/webtocprinter.rb +38 -35
  80. data/lib/review/yamlloader.rb +26 -16
  81. data/review.gemspec +6 -4
  82. data/samples/sample-book/README.md +7 -2
  83. data/samples/sample-book/src/.gitignore +154 -0
  84. data/samples/sample-book/src/config-ebook.yml +4 -0
  85. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  86. data/samples/sample-book/src/config-jlreq.yml +6 -0
  87. data/samples/sample-book/src/config.yml +2 -2
  88. data/samples/sample-book/src/lib/tasks/review.rake +29 -14
  89. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  90. data/samples/syntax-book/ch01.re +4 -2
  91. data/samples/syntax-book/ch02.re +8 -16
  92. data/samples/syntax-book/ch03.re +3 -6
  93. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  94. data/samples/syntax-book/config-jlreq.yml +5 -0
  95. data/samples/syntax-book/config-print.yml +3 -0
  96. data/samples/syntax-book/config.yml +1 -1
  97. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  98. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  99. data/templates/latex/config.erb +16 -0
  100. data/templates/latex/layout.tex.erb +4 -0
  101. data/templates/latex/review-jlreq/review-base.sty +150 -61
  102. data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
  103. data/templates/latex/review-jlreq/review-style.sty +4 -1
  104. data/templates/latex/review-jsbook/README.md +39 -0
  105. data/templates/latex/review-jsbook/review-base.sty +101 -23
  106. data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
  107. data/templates/latex/review-jsbook/review-style.sty +5 -2
  108. data/templates/opf/epubv3.opf.erb +1 -0
  109. data/templates/web/html/layout-html5.html.erb +2 -2
  110. data/test/assets/test_template.tex +24 -3
  111. data/test/assets/test_template_backmatter.tex +24 -3
  112. data/test/test_book.rb +75 -21
  113. data/test/test_book_chapter.rb +4 -2
  114. data/test/test_book_part.rb +3 -3
  115. data/test/test_builder.rb +16 -0
  116. data/test/test_catalog.rb +24 -42
  117. data/test/test_catalog_converter_cmd.rb +1 -1
  118. data/test/test_epubmaker_cmd.rb +14 -7
  119. data/test/test_helper.rb +15 -7
  120. data/test/test_htmlbuilder.rb +909 -159
  121. data/test/test_i18n.rb +25 -25
  122. data/test/test_idgxmlbuilder.rb +395 -38
  123. data/test/test_idgxmlmaker_cmd.rb +46 -0
  124. data/test/test_image_finder.rb +52 -70
  125. data/test/test_index.rb +50 -10
  126. data/test/test_latexbuilder.rb +1194 -106
  127. data/test/test_latexbuilder_v2.rb +628 -97
  128. data/test/test_logger.rb +14 -1
  129. data/test/test_makerhelper.rb +3 -3
  130. data/test/test_markdownbuilder.rb +134 -16
  131. data/test/test_md2inaobuilder.rb +32 -9
  132. data/test/test_pdfmaker.rb +18 -1
  133. data/test/test_pdfmaker_cmd.rb +100 -6
  134. data/test/test_plaintextbuilder.rb +371 -25
  135. data/test/test_preprocessor.rb +2 -16
  136. data/test/test_rstbuilder.rb +249 -26
  137. data/test/test_textmaker_cmd.rb +54 -0
  138. data/test/test_textutils.rb +109 -2
  139. data/test/test_topbuilder.rb +546 -31
  140. data/test/test_update.rb +17 -8
  141. data/test/test_webtocprinter.rb +66 -34
  142. data/test/test_yamlloader.rb +13 -0
  143. data/vendor/jsclasses/LICENSE +1 -1
  144. data/vendor/jsclasses/jis/jsarticle.cls +53 -14
  145. data/vendor/jsclasses/jis/jsbook.cls +53 -14
  146. data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
  147. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  148. data/vendor/jsclasses/jis/jslogo.sty +3 -3
  149. data/vendor/jsclasses/jis/jspf.cls +52 -13
  150. data/vendor/jsclasses/jis/jsreport.cls +53 -14
  151. data/vendor/jsclasses/jis/kiyou.cls +53 -14
  152. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  153. data/vendor/jsclasses/jis/okumacro.sty +3 -4
  154. data/vendor/jsclasses/jsarticle.cls +53 -14
  155. data/vendor/jsclasses/jsbook.cls +53 -14
  156. data/vendor/jsclasses/jsclasses.dtx +84 -25
  157. data/vendor/jsclasses/jsclasses.pdf +0 -0
  158. data/vendor/jsclasses/jslogo.dtx +4 -4
  159. data/vendor/jsclasses/jslogo.pdf +0 -0
  160. data/vendor/jsclasses/jslogo.sty +3 -3
  161. data/vendor/jsclasses/jspf.cls +52 -13
  162. data/vendor/jsclasses/jsreport.cls +53 -14
  163. data/vendor/jsclasses/kiyou.cls +53 -14
  164. data/vendor/jsclasses/okumacro.dtx +4 -5
  165. data/vendor/jsclasses/okumacro.pdf +0 -0
  166. data/vendor/jsclasses/okumacro.sty +3 -4
  167. metadata +55 -10
  168. data/lib/review/tocparser.rb +0 -271
  169. data/samples/syntax-book/review-ext.rb +0 -14
  170. data/test/test_tocparser.rb +0 -25
@@ -6,7 +6,12 @@ class TextUtilsTest < Test::Unit::TestCase
6
6
 
7
7
  def setup
8
8
  @tu_nil = Object.new
9
- @tu_nil.extend ReVIEW::TextUtils
9
+ @tu_nil.extend(ReVIEW::TextUtils)
10
+ @tu_nil.instance_eval { @book = Book::Base.new('.') }
11
+ def @tu_nil.config
12
+ @book.config
13
+ end
14
+
10
15
  def @tu_nil.pre_paragraph
11
16
  nil
12
17
  end
@@ -16,7 +21,12 @@ class TextUtilsTest < Test::Unit::TestCase
16
21
  end
17
22
 
18
23
  @tu_p = Object.new
19
- @tu_p.extend ReVIEW::TextUtils
24
+ @tu_p.extend(ReVIEW::TextUtils)
25
+ @tu_p.instance_eval { @book = Book::Base.new('.') }
26
+ def @tu_p.config
27
+ @book.config
28
+ end
29
+
20
30
  def @tu_p.pre_paragraph
21
31
  '<p>'
22
32
  end
@@ -63,6 +73,20 @@ class TextUtilsTest < Test::Unit::TestCase
63
73
  assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
64
74
  ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
65
75
  assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
76
+
77
+ @tu_p.config['join_lines_by_lang'] = true
78
+ ret = @tu_p.split_paragraph(['abc'])
79
+ assert_equal ['<p>abc</p>'], ret
80
+ ret = @tu_p.split_paragraph(['abc', 'def'])
81
+ assert_equal ['<p>abc def</p>'], ret
82
+ ret = @tu_p.split_paragraph(['abc', '', 'def'])
83
+ assert_equal ['<p>abc</p>', '<p>def</p>'], ret
84
+ ret = @tu_p.split_paragraph(['abc', '', '', 'def'])
85
+ assert_equal ['<p>abc</p>', '<p>def</p>'], ret
86
+ ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi'])
87
+ assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
88
+ ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
89
+ assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
66
90
  end
67
91
 
68
92
  def test_split_paragraph_nil
@@ -76,5 +100,88 @@ class TextUtilsTest < Test::Unit::TestCase
76
100
  assert_equal ['abc', 'def'], ret
77
101
  ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
78
102
  assert_equal ['abc', 'defghi'], ret
103
+
104
+ @tu_nil.config['join_lines_by_lang'] = true
105
+ ret = @tu_nil.split_paragraph(['abc'])
106
+ assert_equal ['abc'], ret
107
+ ret = @tu_nil.split_paragraph(['abc', 'def'])
108
+ assert_equal ['abc def'], ret
109
+ ret = @tu_nil.split_paragraph(['abc', '', 'def'])
110
+ assert_equal ['abc', 'def'], ret
111
+ ret = @tu_nil.split_paragraph(['abc', '', '', 'def'])
112
+ assert_equal ['abc', 'def'], ret
113
+ ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
114
+ assert_equal ['abc', 'def ghi'], ret
115
+ end
116
+
117
+ def test_split_paragraph_p_lang
118
+ ret = @tu_p.split_paragraph(['I', 'have.'])
119
+ assert_equal ['<p>Ihave.</p>'], ret
120
+ ret = @tu_p.split_paragraph(['I', 'have', '.'])
121
+ assert_equal ['<p>Ihave.</p>'], ret
122
+ ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
123
+ assert_equal ['<p>0123a4</p>'], ret
124
+ ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
125
+ assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
126
+ ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
127
+ assert_equal ['<p>こんにちは0814日</p>'], ret
128
+ ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
129
+ assert_equal ['<p>あaい?a</p>'], ret
130
+ ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
131
+ assert_equal ['<p>안녕하세요こんにちは</p>'], ret
132
+ ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
133
+ assert_equal ['<p>Hello안녕하세요처음뵙겠습니다</p>'], ret
134
+ ret = @tu_p.split_paragraph([''])
135
+ assert_equal ['<p></p>'], ret
136
+ # LaTeX
137
+ ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
138
+ assert_equal ['<p>\tag{a}A\tag{b}B</p>'], ret
139
+ ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
140
+ assert_equal ['<p>\tag{あ}い\tag{う}A\tag{え}\tag{b}\tag{お}\tag{か}</p>'], ret
141
+ # HTML/IDGXML
142
+ ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
143
+ assert_equal ['<p><b>a</b>A<b>b</b>B</p>'], ret
144
+ ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
145
+ assert_equal ['<p><b>あ</b>い<b>う</b>A<b>え</b><b>b</b><b>お</b><b>か</b></p>'], ret
146
+ # Text
147
+ ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
148
+ assert_equal ['<p>★a☆A★b☆B</p>'], ret
149
+ ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
150
+ assert_equal ['<p>★あ☆い★う☆A★え☆★b☆★お☆★か☆</p>'], ret
151
+
152
+ @tu_p.config['join_lines_by_lang'] = true
153
+ ret = @tu_p.split_paragraph(['I', 'have.'])
154
+ assert_equal ['<p>I have.</p>'], ret
155
+ ret = @tu_p.split_paragraph(['I', 'have', '.'])
156
+ assert_equal ['<p>I have .</p>'], ret # ...OK? (I have. ?)
157
+ ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
158
+ assert_equal ['<p>01 23 a 4</p>'], ret
159
+ ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
160
+ assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
161
+ ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
162
+ assert_equal ['<p>こんにちは0814日</p>'], ret
163
+ ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
164
+ assert_equal ['<p>あaい? a</p>'], ret
165
+ ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
166
+ assert_equal ['<p>안녕하세요こんにちは</p>'], ret
167
+ ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
168
+ assert_equal ['<p>Hello 안녕하세요 처음뵙겠습니다</p>'], ret
169
+ ret = @tu_p.split_paragraph([''])
170
+ assert_equal ['<p></p>'], ret
171
+ # LaTeX
172
+ ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
173
+ assert_equal ['<p>\tag{a} A \tag{b} B</p>'], ret
174
+ ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
175
+ assert_equal ['<p>\tag{あ}い\tag{う} A \tag{え} \tag{b} \tag{お} \tag{か}</p>'], ret # ...OK? (\tag{お}\tag{か}?)
176
+ # HTML/IDGXML
177
+ ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
178
+ assert_equal ['<p><b>a</b> A <b>b</b> B</p>'], ret
179
+ ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
180
+ assert_equal ['<p><b>あ</b>い<b>う</b> A <b>え</b> <b>b</b> <b>お</b> <b>か</b></p>'], ret # ...OK? (<b>お</b><b>か</b>?)
181
+ # Text
182
+ ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
183
+ assert_equal ['<p>★a☆ A ★b☆ B</p>'], ret
184
+ ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
185
+ assert_equal ['<p>★あ☆い★う☆ A ★え☆ ★b☆ ★お☆ ★か☆</p>'], ret # ...OK? (★お☆★か☆?)
79
186
  end
80
187
  end
@@ -142,27 +142,90 @@ class TOPBuidlerTest < Test::Unit::TestCase
142
142
 
143
143
  def test_inline_in_table
144
144
  actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
145
- assert_equal %Q(◆→開始:表←◆\n★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n), actual
145
+ expected = <<-EOS
146
+ ◆→開始:表←◆
147
+ ★★1☆☆\t★▲2☆☆
148
+ ★3☆\t▲4☆<>&
149
+ ◆→終了:表←◆
150
+
151
+ EOS
152
+ assert_equal expected, actual
146
153
  end
147
154
 
148
155
  def test_dlist_beforeulol
149
156
  actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
150
- assert_equal %Q(★foo☆\n\tfoo.\n\npara\n\n★foo☆\n\tfoo.\n\n1\tbar\n\n★foo☆\n\tfoo.\n\n●\tbar\n\n), actual
157
+ expected = <<-EOS
158
+ ★foo☆
159
+ \tfoo.
160
+
161
+ para
162
+
163
+ ★foo☆
164
+ \tfoo.
165
+
166
+ 1\tbar
167
+
168
+ ★foo☆
169
+ \tfoo.
170
+
171
+ ●\tbar
172
+
173
+ EOS
174
+ assert_equal expected, actual
175
+ end
176
+
177
+ def test_dt_inline
178
+ fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
179
+ @chapter.instance_eval { @footnote_index = fn }
180
+ actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
181
+
182
+ expected = <<-EOS
183
+ ★foo【注1】[]<>&◆→TeX式ここから←◆\\alpha[]◆→TeX式ここまで←◆☆
184
+
185
+
186
+ EOS
187
+ assert_equal expected, actual
151
188
  end
152
189
 
153
190
  def test_paragraph
154
191
  actual = compile_block("foo\nbar\n")
155
192
  assert_equal %Q(foobar\n), actual
193
+
194
+ @book.config['join_lines_by_lang'] = true
195
+ actual = compile_block("foo\nbar\n")
196
+ assert_equal %Q(foo bar\n), actual
156
197
  end
157
198
 
158
199
  def test_tabbed_paragraph
159
200
  actual = compile_block("\tfoo\nbar\n")
160
201
  assert_equal %Q(\tfoobar\n), actual
202
+
203
+ @book.config['join_lines_by_lang'] = true
204
+ actual = compile_block("\tfoo\nbar\n")
205
+ assert_equal %Q(\tfoo bar\n), actual
161
206
  end
162
207
 
163
208
  def test_flushright
164
209
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
165
- assert_equal %Q(◆→開始:右寄せ←◆\nfoobar\nbuz\n◆→終了:右寄せ←◆\n\n), actual
210
+ expected = <<-EOS
211
+ ◆→開始:右寄せ←◆
212
+ foobar
213
+ buz
214
+ ◆→終了:右寄せ←◆
215
+
216
+ EOS
217
+ assert_equal expected, actual
218
+
219
+ @book.config['join_lines_by_lang'] = true
220
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
221
+ expected = <<-EOS
222
+ ◆→開始:右寄せ←◆
223
+ foo bar
224
+ buz
225
+ ◆→終了:右寄せ←◆
226
+
227
+ EOS
228
+ assert_equal expected, actual
166
229
  end
167
230
 
168
231
  def test_blankline
@@ -172,7 +235,21 @@ class TOPBuidlerTest < Test::Unit::TestCase
172
235
 
173
236
  def test_noindent
174
237
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
175
- assert_equal %Q(◆→DTP連絡:次の1行インデントなし←◆\nfoobar\nfoo2bar2\n), actual
238
+ expected = <<-EOS
239
+ ◆→DTP連絡:次の1行インデントなし←◆
240
+ foobar
241
+ foo2bar2
242
+ EOS
243
+ assert_equal expected, actual
244
+
245
+ @book.config['join_lines_by_lang'] = true
246
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
247
+ expected = <<-EOS
248
+ ◆→DTP連絡:次の1行インデントなし←◆
249
+ foo bar
250
+ foo2 bar2
251
+ EOS
252
+ assert_equal expected, actual
176
253
  end
177
254
 
178
255
  def test_comment
@@ -182,34 +259,237 @@ class TOPBuidlerTest < Test::Unit::TestCase
182
259
 
183
260
  def test_comment_for_draft
184
261
  @config['draft'] = true
185
- actual = compile_block('//comment[コメント]')
186
- assert_equal %Q(◆→コメント←◆\n), actual
262
+ actual = compile_block('//comment[コメント<]')
263
+ assert_equal %Q(◆→コメント<←◆\n), actual
264
+ actual = compile_block("//comment{\nA<>\nB&\n//}")
265
+ assert_equal %Q(◆→A<>\nB&←◆\n), actual
187
266
  end
188
267
 
189
268
  def test_list
190
269
  def @chapter.list(_id)
191
- Book::ListIndex::Item.new('test', 1)
270
+ Book::Index::Item.new('test', 1)
192
271
  end
193
272
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
194
- assert_equal %Q(◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\nfoo\nbar\n◆→終了:リスト←◆\n\n), actual
273
+ expected = <<-EOS
274
+ ◆→開始:リスト←◆
275
+ リスト1.1 this is ★test☆<&>_
276
+
277
+ foo
278
+ bar
279
+ ◆→終了:リスト←◆
280
+
281
+ EOS
282
+ assert_equal expected, actual
195
283
  end
196
284
 
197
285
  def test_listnum
198
286
  def @chapter.list(_id)
199
- Book::ListIndex::Item.new('test', 1)
287
+ Book::Index::Item.new('test', 1)
200
288
  end
201
289
  actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
202
- assert_equal %Q(◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\n 1: foo\n 2: bar\n◆→終了:リスト←◆\n\n), actual
290
+ expected = <<-EOS
291
+ ◆→開始:リスト←◆
292
+ リスト1.1 this is ★test☆<&>_
293
+
294
+ 1: foo
295
+ 2: bar
296
+ ◆→終了:リスト←◆
297
+
298
+ EOS
299
+ assert_equal expected, actual
300
+
301
+ @config['caption_position']['list'] = 'bottom'
302
+ actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
303
+ expected = <<-EOS
304
+ ◆→開始:リスト←◆
305
+ 1: foo
306
+ 2: bar
307
+
308
+ リスト1.1 this is ★test☆<&>_
309
+ ◆→終了:リスト←◆
310
+
311
+ EOS
312
+ assert_equal expected, actual
313
+ end
314
+
315
+ def test_source
316
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
317
+ expected = <<-EOS
318
+ ◆→開始:ソースコードリスト←◆
319
+ ■foo/bar/test.rb
320
+ foo
321
+ bar
322
+
323
+ buz
324
+ ◆→終了:ソースコードリスト←◆
325
+
326
+ EOS
327
+ assert_equal expected, actual
328
+
329
+ @config['caption_position']['list'] = 'bottom'
330
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
331
+ expected = <<-EOS
332
+ ◆→開始:ソースコードリスト←◆
333
+ foo
334
+ bar
335
+
336
+ buz
337
+ ■foo/bar/test.rb
338
+ ◆→終了:ソースコードリスト←◆
339
+
340
+ EOS
341
+ assert_equal expected, actual
342
+ end
343
+
344
+ def test_source_empty_caption
345
+ actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
346
+ expected = <<-EOS
347
+ ◆→開始:ソースコードリスト←◆
348
+ foo
349
+ bar
350
+
351
+ buz
352
+ ◆→終了:ソースコードリスト←◆
353
+
354
+ EOS
355
+ assert_equal expected, actual
356
+ end
357
+
358
+ def test_box
359
+ actual = compile_block("//box{\nfoo\nbar\n//}\n")
360
+ expected = <<-EOS
361
+ ◆→開始:書式←◆
362
+ foo
363
+ bar
364
+ ◆→終了:書式←◆
365
+
366
+ EOS
367
+ assert_equal expected, actual
368
+
369
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
370
+ expected = <<-EOS
371
+ ◆→開始:書式←◆
372
+ ■FOO
373
+ foo
374
+ bar
375
+ ◆→終了:書式←◆
376
+
377
+ EOS
378
+ assert_equal expected, actual
379
+
380
+ @config['caption_position']['list'] = 'bottom'
381
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
382
+ expected = <<-EOS
383
+ ◆→開始:書式←◆
384
+ foo
385
+ bar
386
+ ■FOO
387
+ ◆→終了:書式←◆
388
+
389
+ EOS
390
+ assert_equal expected, actual
391
+ end
392
+
393
+ def test_cmd
394
+ actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
395
+ expected = <<-EOS
396
+ ◆→開始:コマンド←◆
397
+ lineA
398
+ lineB
399
+ ◆→終了:コマンド←◆
400
+
401
+ EOS
402
+ assert_equal expected, actual
403
+
404
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
405
+ expected = <<-EOS
406
+ ◆→開始:コマンド←◆
407
+ ■cap1
408
+ lineA
409
+ lineB
410
+ ◆→終了:コマンド←◆
411
+
412
+ EOS
413
+ assert_equal expected, actual
414
+
415
+ @config['caption_position']['list'] = 'bottom'
416
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
417
+ expected = <<-EOS
418
+ ◆→開始:コマンド←◆
419
+ lineA
420
+ lineB
421
+ ■cap1
422
+ ◆→終了:コマンド←◆
423
+
424
+ EOS
425
+ assert_equal expected, actual
426
+ end
427
+
428
+ def test_emlist
429
+ actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
430
+ expected = <<-EOS
431
+ ◆→開始:インラインリスト←◆
432
+ lineA
433
+ lineB
434
+ ◆→終了:インラインリスト←◆
435
+
436
+ EOS
437
+ assert_equal expected, actual
438
+ end
439
+
440
+ def test_emlist_caption
441
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
442
+ expected = <<-EOS
443
+ ◆→開始:インラインリスト←◆
444
+ ■cap1
445
+ lineA
446
+ lineB
447
+ ◆→終了:インラインリスト←◆
448
+
449
+ EOS
450
+ assert_equal expected, actual
451
+
452
+ @config['caption_position']['list'] = 'bottom'
453
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
454
+ expected = <<-EOS
455
+ ◆→開始:インラインリスト←◆
456
+ lineA
457
+ lineB
458
+ ■cap1
459
+ ◆→終了:インラインリスト←◆
460
+
461
+ EOS
462
+ assert_equal expected, actual
203
463
  end
204
464
 
205
465
  def test_emlistnum
206
466
  actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
207
- assert_equal %Q(◆→開始:インラインリスト←◆\n■this is ★test☆<&>_\n 1: foo\n 2: bar\n◆→終了:インラインリスト←◆\n\n), actual
467
+ expected = <<-EOS
468
+ ◆→開始:インラインリスト←◆
469
+ ■this is ★test☆<&>_
470
+ 1: foo
471
+ 2: bar
472
+ ◆→終了:インラインリスト←◆
473
+
474
+ EOS
475
+ assert_equal expected, actual
476
+
477
+ @config['caption_position']['list'] = 'bottom'
478
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
479
+ expected = <<-EOS
480
+ ◆→開始:インラインリスト←◆
481
+ 1: foo
482
+ 2: bar
483
+ ■this is ★test☆<&>_
484
+ ◆→終了:インラインリスト←◆
485
+
486
+ EOS
487
+ assert_equal expected, actual
208
488
  end
209
489
 
210
490
  def test_bib
211
491
  def @chapter.bibpaper(_id)
212
- Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
492
+ Book::Index::Item.new('samplebib', 1, 'sample bib')
213
493
  end
214
494
 
215
495
  assert_equal '[1]', compile_inline('@<bib>{samplebib}')
@@ -217,13 +497,52 @@ class TOPBuidlerTest < Test::Unit::TestCase
217
497
 
218
498
  def test_table
219
499
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
220
- assert_equal %Q(◆→開始:表←◆\n★aaa☆\t★bbb☆\nccc\tddd<>&\n◆→終了:表←◆\n\n),
221
- actual
500
+ expected = <<-EOS
501
+ ◆→開始:表←◆
502
+ ★aaa☆\t★bbb☆
503
+ ccc\tddd<>&
504
+ ◆→終了:表←◆
505
+
506
+ EOS
507
+ assert_equal expected, actual
508
+
509
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
510
+ expected = <<-EOS
511
+ ◆→開始:表←◆
512
+ 表1.1 FOO
513
+
514
+ ★aaa☆\t★bbb☆
515
+ ccc\tddd<>&
516
+ ◆→終了:表←◆
517
+
518
+ EOS
519
+ assert_equal expected, actual
520
+
521
+ @config['caption_position']['table'] = 'bottom'
522
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
523
+ expected = <<-EOS
524
+ ◆→開始:表←◆
525
+ ★aaa☆\t★bbb☆
526
+ ccc\tddd<>&
527
+
528
+ 表1.1 FOO
529
+ ◆→終了:表←◆
530
+
531
+ EOS
532
+ assert_equal expected, actual
533
+ end
534
+
535
+ def test_empty_table
536
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
537
+ assert_equal ':2: error: no rows in the table', e.message
538
+
539
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
540
+ assert_equal ':3: error: no rows in the table', e.message
222
541
  end
223
542
 
224
543
  def test_inline_table
225
544
  def @chapter.table(_id)
226
- Book::TableIndex::Item.new('sampletable', 1)
545
+ Book::Index::Item.new('sampletable', 1)
227
546
  end
228
547
  actual = compile_block("@<table>{sampletest}\n")
229
548
  assert_equal "表1.1\n", actual
@@ -231,69 +550,251 @@ class TOPBuidlerTest < Test::Unit::TestCase
231
550
 
232
551
  def test_emtable
233
552
  actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
234
- assert_equal %Q(◆→開始:表←◆\nfoo\n\n★aaa☆\t★bbb☆\nccc\tddd<>&\n◆→終了:表←◆\n\n◆→開始:表←◆\n★aaa☆\t★bbb☆\nccc\tddd<>&\n◆→終了:表←◆\n\n),
235
- actual
553
+ expected = <<-EOS
554
+ ◆→開始:表←◆
555
+ foo
556
+
557
+ ★aaa☆\t★bbb☆
558
+ ccc\tddd<>&
559
+ ◆→終了:表←◆
560
+
561
+ ◆→開始:表←◆
562
+ ★aaa☆\t★bbb☆
563
+ ccc\tddd<>&
564
+ ◆→終了:表←◆
565
+
566
+ EOS
567
+ assert_equal expected, actual
568
+ end
569
+
570
+ def test_table_row_separator
571
+ src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
572
+ expected = <<-EOS
573
+ ◆→開始:表←◆
574
+ ★1☆ ★2☆ ★3 4| 5☆
575
+ a b c d |e
576
+ ◆→終了:表←◆
577
+
578
+ EOS
579
+ actual = compile_block(src)
580
+ assert_equal expected, actual
581
+
582
+ @config['table_row_separator'] = 'singletab'
583
+ actual = compile_block(src)
584
+ expected = <<-EOS
585
+ ◆→開始:表←◆
586
+ ★1☆ ★2☆ ★☆ ★3 4| 5☆
587
+ a b c d |e
588
+ ◆→終了:表←◆
589
+
590
+ EOS
591
+ assert_equal expected, actual
592
+
593
+ @config['table_row_separator'] = 'spaces'
594
+ actual = compile_block(src)
595
+ expected = <<-EOS
596
+ ◆→開始:表←◆
597
+ ★1☆ ★2☆ ★3☆ ★4|☆ ★5☆
598
+ a b c d |e
599
+ ◆→終了:表←◆
600
+
601
+ EOS
602
+ assert_equal expected, actual
603
+
604
+ @config['table_row_separator'] = 'verticalbar'
605
+ actual = compile_block(src)
606
+ expected = <<-EOS
607
+ ◆→開始:表←◆
608
+ ★1 2 3 4☆ ★5☆
609
+ a b c d e
610
+ ◆→終了:表←◆
611
+
612
+ EOS
613
+ assert_equal expected, actual
236
614
  end
237
615
 
238
616
  def test_major_blocks
239
617
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
240
- expected = %Q(◆→開始:ノート←◆\nA\nB\n◆→終了:ノート←◆\n\n◆→開始:ノート←◆\n■caption\nA\n◆→終了:ノート←◆\n\n)
618
+ expected = <<-EOS
619
+ ◆→開始:ノート←◆
620
+ A
621
+ B
622
+ ◆→終了:ノート←◆
623
+
624
+ ◆→開始:ノート←◆
625
+ ■caption
626
+ A
627
+ ◆→終了:ノート←◆
628
+
629
+ EOS
241
630
  assert_equal expected, actual
242
631
 
243
632
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
244
- expected = %Q(◆→開始:メモ←◆\nA\nB\n◆→終了:メモ←◆\n\n◆→開始:メモ←◆\n■caption\nA\n◆→終了:メモ←◆\n\n)
633
+ expected = <<-EOS
634
+ ◆→開始:メモ←◆
635
+ A
636
+ B
637
+ ◆→終了:メモ←◆
638
+
639
+ ◆→開始:メモ←◆
640
+ ■caption
641
+ A
642
+ ◆→終了:メモ←◆
643
+
644
+ EOS
245
645
  assert_equal expected, actual
246
646
 
247
647
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
248
- expected = %Q(◆→開始:情報←◆\nA\nB\n◆→終了:情報←◆\n\n◆→開始:情報←◆\n■caption\nA\n◆→終了:情報←◆\n\n)
648
+ expected = <<-EOS
649
+ ◆→開始:情報←◆
650
+ A
651
+ B
652
+ ◆→終了:情報←◆
653
+
654
+ ◆→開始:情報←◆
655
+ ■caption
656
+ A
657
+ ◆→終了:情報←◆
658
+
659
+ EOS
249
660
  assert_equal expected, actual
250
661
 
251
662
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
252
- expected = %Q(◆→開始:重要←◆\nA\nB\n◆→終了:重要←◆\n\n◆→開始:重要←◆\n■caption\nA\n◆→終了:重要←◆\n\n)
663
+ expected = <<-EOS
664
+ ◆→開始:重要←◆
665
+ A
666
+ B
667
+ ◆→終了:重要←◆
668
+
669
+ ◆→開始:重要←◆
670
+ ■caption
671
+ A
672
+ ◆→終了:重要←◆
673
+
674
+ EOS
253
675
  assert_equal expected, actual
254
676
 
255
677
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
256
- expected = %Q(◆→開始:警告←◆\nA\nB\n◆→終了:警告←◆\n\n◆→開始:警告←◆\n■caption\nA\n◆→終了:警告←◆\n\n)
678
+ expected = <<-EOS
679
+ ◆→開始:警告←◆
680
+ A
681
+ B
682
+ ◆→終了:警告←◆
683
+
684
+ ◆→開始:警告←◆
685
+ ■caption
686
+ A
687
+ ◆→終了:警告←◆
688
+
689
+ EOS
257
690
  assert_equal expected, actual
258
691
 
259
692
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
260
- expected = %Q(◆→開始:注意←◆\nA\nB\n◆→終了:注意←◆\n\n◆→開始:注意←◆\n■caption\nA\n◆→終了:注意←◆\n\n)
693
+ expected = <<-EOS
694
+ ◆→開始:注意←◆
695
+ A
696
+ B
697
+ ◆→終了:注意←◆
698
+
699
+ ◆→開始:注意←◆
700
+ ■caption
701
+ A
702
+ ◆→終了:注意←◆
703
+
704
+ EOS
261
705
  assert_equal expected, actual
262
706
 
263
707
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
264
- expected = %Q(◆→開始:危険←◆\nA\nB\n◆→終了:危険←◆\n\n◆→開始:危険←◆\n■caption\nA\n◆→終了:危険←◆\n\n)
708
+ expected = <<-EOS
709
+ ◆→開始:危険←◆
710
+ A
711
+ B
712
+ ◆→終了:危険←◆
713
+
714
+ ◆→開始:危険←◆
715
+ ■caption
716
+ A
717
+ ◆→終了:危険←◆
718
+
719
+ EOS
265
720
  assert_equal expected, actual
266
721
 
267
722
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
268
- expected = %Q(◆→開始:TIP←◆\nA\nB\n◆→終了:TIP←◆\n\n◆→開始:TIP←◆\n■caption\nA\n◆→終了:TIP←◆\n\n)
723
+ expected = <<-EOS
724
+ ◆→開始:TIP←◆
725
+ A
726
+ B
727
+ ◆→終了:TIP←◆
728
+
729
+ ◆→開始:TIP←◆
730
+ ■caption
731
+ A
732
+ ◆→終了:TIP←◆
733
+
734
+ EOS
269
735
  assert_equal expected, actual
270
736
  end
271
737
 
272
738
  def test_image
273
739
  def @chapter.image(_id)
274
- item = Book::ImageIndex::Item.new('sampleimg', 1)
740
+ item = Book::Index::Item.new('sampleimg', 1)
275
741
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
276
742
  item
277
743
  end
278
744
 
279
745
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
280
- assert_equal %Q(◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n), actual
746
+ expected = <<-EOS
747
+ ◆→開始:図←◆
748
+ ◆→./images/chap1-sampleimg.png←◆
749
+
750
+ 図1.1 sample photo
751
+ ◆→終了:図←◆
752
+
753
+ EOS
754
+ assert_equal expected, actual
755
+
756
+ @config['caption_position']['image'] = 'top'
757
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
758
+ expected = <<-EOS
759
+ ◆→開始:図←◆
760
+ 図1.1 sample photo
761
+
762
+ ◆→./images/chap1-sampleimg.png←◆
763
+ ◆→終了:図←◆
764
+
765
+ EOS
766
+ assert_equal expected, actual
281
767
  end
282
768
 
283
769
  def test_image_with_metric
284
770
  def @chapter.image(_id)
285
- item = Book::ImageIndex::Item.new('sampleimg', 1)
771
+ item = Book::Index::Item.new('sampleimg', 1)
286
772
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
287
773
  item
288
774
  end
289
775
 
290
776
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
291
- assert_equal %Q(◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png scale=1.2←◆\n◆→終了:図←◆\n\n), actual
777
+ expected = <<-EOS
778
+ ◆→開始:図←◆
779
+ ◆→./images/chap1-sampleimg.png scale=1.2←◆
780
+
781
+ 図1.1 sample photo
782
+ ◆→終了:図←◆
783
+
784
+ EOS
785
+ assert_equal expected, actual
292
786
  end
293
787
 
294
788
  def test_texequation
295
789
  actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
296
- assert_equal %Q(◆→開始:TeX式←◆\n\\sin\n1^{2}\n◆→終了:TeX式←◆\n\n), actual
790
+ expected = <<-EOS
791
+ ◆→開始:TeX式←◆
792
+ \\sin
793
+ 1^{2}
794
+ ◆→終了:TeX式←◆
795
+
796
+ EOS
797
+ assert_equal expected, actual
297
798
  end
298
799
 
299
800
  def test_inline_w
@@ -310,7 +811,7 @@ EOB
310
811
  @builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
311
812
  actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
312
813
  assert_equal %Q(foo bar"\\<>_@<b>{BAZ} ★bar"\\<>_@<b>{BAZ}☆ [missing word: N]\n), actual
313
- assert_match(/WARN -- : :1: word not bound: N/, io.string)
814
+ assert_match(/WARN --: :1: word not bound: N/, io.string)
314
815
  end
315
816
  end
316
817
 
@@ -428,6 +929,20 @@ EOS
428
929
  e=mc^2
429
930
  ◆→終了:TeX式←◆
430
931
 
932
+ EOS
933
+ actual = compile_block(src)
934
+ assert_equal expected, actual
935
+
936
+ @config['caption_position']['equation'] = 'bottom'
937
+
938
+ expected = <<-EOS
939
+ 式1.1
940
+
941
+ ◆→開始:TeX式←◆
942
+ e=mc^2
943
+ 式1.1 The Equivalence of Mass ▲and☆ Energy
944
+ ◆→終了:TeX式←◆
945
+
431
946
  EOS
432
947
  actual = compile_block(src)
433
948
  assert_equal expected, actual