review 3.2.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +31 -0
  3. data/.github/workflows/ruby-win.yml +45 -0
  4. data/.github/workflows/ruby.yml +27 -0
  5. data/.rubocop.yml +167 -42
  6. data/.travis.yml +1 -1
  7. data/Dockerfile +21 -5
  8. data/NEWS.ja.md +428 -1
  9. data/NEWS.md +429 -2
  10. data/README.md +11 -7
  11. data/Rakefile +7 -2
  12. data/appveyor.yml +0 -20
  13. data/bin/review +2 -4
  14. data/bin/review-catalog-converter +5 -5
  15. data/bin/review-check +13 -17
  16. data/bin/review-checkdep +3 -6
  17. data/bin/review-compile +13 -22
  18. data/bin/review-epub2html +1 -4
  19. data/bin/review-epubmaker +3 -4
  20. data/bin/review-idgxmlmaker +14 -0
  21. data/bin/review-index +5 -86
  22. data/bin/review-init +1 -4
  23. data/bin/review-pdfmaker +1 -3
  24. data/bin/review-preproc +11 -13
  25. data/bin/review-textmaker +1 -3
  26. data/bin/review-update +1 -4
  27. data/bin/review-validate +7 -7
  28. data/bin/review-vol +5 -82
  29. data/bin/review-webmaker +1 -3
  30. data/doc/config.yml.sample +67 -16
  31. data/doc/config.yml.sample-simple +4 -3
  32. data/doc/format.ja.md +133 -21
  33. data/doc/format.md +135 -34
  34. data/doc/makeindex.ja.md +2 -2
  35. data/doc/pdfmaker.ja.md +43 -1
  36. data/doc/pdfmaker.md +42 -1
  37. data/doc/quickstart.ja.md +55 -25
  38. data/doc/quickstart.md +47 -17
  39. data/lib/review.rb +1 -1
  40. data/lib/review/book.rb +2 -2
  41. data/lib/review/book/base.rb +89 -90
  42. data/lib/review/book/bib.rb +21 -0
  43. data/lib/review/book/book_unit.rb +158 -0
  44. data/lib/review/book/chapter.rb +51 -29
  45. data/lib/review/book/index.rb +42 -248
  46. data/lib/review/book/index/item.rb +46 -0
  47. data/lib/review/book/page_metric.rb +7 -7
  48. data/lib/review/book/part.rb +45 -10
  49. data/lib/review/book/volume.rb +5 -5
  50. data/lib/review/builder.rb +171 -54
  51. data/lib/review/call_hook.rb +20 -0
  52. data/lib/review/catalog.rb +15 -17
  53. data/lib/review/compiler.rb +240 -102
  54. data/lib/review/configure.rb +101 -12
  55. data/lib/review/converter.rb +1 -1
  56. data/lib/review/epub2html.rb +6 -1
  57. data/lib/review/epubmaker.rb +120 -118
  58. data/lib/review/epubmaker/content.rb +113 -0
  59. data/lib/review/epubmaker/epubcommon.rb +372 -0
  60. data/lib/review/epubmaker/epubv2.rb +178 -0
  61. data/lib/review/epubmaker/epubv3.rb +231 -0
  62. data/lib/review/epubmaker/producer.rb +168 -0
  63. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  64. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  65. data/lib/review/exception.rb +6 -0
  66. data/lib/review/extentions/string.rb +0 -4
  67. data/lib/review/htmlbuilder.rb +147 -149
  68. data/lib/review/htmlutils.rb +10 -14
  69. data/lib/review/i18n.rb +4 -3
  70. data/lib/review/idgxmlbuilder.rb +229 -103
  71. data/lib/review/idgxmlmaker.rb +188 -0
  72. data/lib/review/img_math.rb +245 -0
  73. data/lib/review/index_builder.rb +654 -0
  74. data/lib/review/init-web/finish.html +10 -0
  75. data/lib/review/init-web/index.html +190 -0
  76. data/lib/review/init-web/review-layout-design.js +691 -0
  77. data/lib/review/init.rb +124 -41
  78. data/lib/review/latexbox.rb +58 -0
  79. data/lib/review/latexbuilder.rb +249 -97
  80. data/lib/review/latexutils.rb +9 -1
  81. data/lib/review/lineinput.rb +113 -3
  82. data/lib/review/logger.rb +43 -8
  83. data/lib/review/makerhelper.rb +13 -186
  84. data/lib/review/markdownbuilder.rb +75 -39
  85. data/lib/review/md2inaobuilder.rb +3 -5
  86. data/lib/review/pdfmaker.rb +88 -83
  87. data/lib/review/plaintextbuilder.rb +158 -83
  88. data/lib/review/preprocessor.rb +30 -24
  89. data/lib/review/rstbuilder.rb +58 -39
  90. data/lib/review/sec_counter.rb +14 -0
  91. data/lib/review/template.rb +6 -0
  92. data/lib/review/textmaker.rb +29 -17
  93. data/lib/review/textutils.rb +68 -2
  94. data/lib/review/tocprinter.rb +242 -97
  95. data/lib/review/topbuilder.rb +147 -61
  96. data/lib/review/update.rb +27 -28
  97. data/lib/review/version.rb +1 -1
  98. data/lib/review/volumeprinter.rb +97 -0
  99. data/lib/review/webmaker.rb +36 -35
  100. data/lib/review/webtocprinter.rb +39 -35
  101. data/lib/review/yamlloader.rb +4 -0
  102. data/review.gemspec +8 -5
  103. data/samples/sample-book/README.md +7 -2
  104. data/samples/sample-book/src/.gitignore +154 -0
  105. data/samples/sample-book/src/config-ebook.yml +4 -0
  106. data/samples/sample-book/src/config-epub2.yml +1 -1
  107. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  108. data/samples/sample-book/src/config-jlreq.yml +6 -0
  109. data/samples/sample-book/src/config.yml +3 -3
  110. data/samples/sample-book/src/lib/tasks/review.rake +45 -14
  111. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  112. data/samples/syntax-book/Gemfile +1 -1
  113. data/samples/syntax-book/ch01.re +3 -1
  114. data/samples/syntax-book/ch02.re +28 -21
  115. data/samples/syntax-book/ch03.re +4 -7
  116. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  117. data/samples/syntax-book/config-jlreq.yml +5 -0
  118. data/samples/syntax-book/config-print.yml +3 -0
  119. data/samples/syntax-book/config.yml +1 -1
  120. data/samples/syntax-book/images/img3-2.png +0 -0
  121. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  122. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  123. data/templates/html/_colophon.html.erb +23 -0
  124. data/templates/html/_colophon_history.html.erb +9 -0
  125. data/templates/html/_cover.html.erb +10 -0
  126. data/templates/html/_part_body.html.erb +6 -0
  127. data/templates/html/_titlepage.html.erb +20 -0
  128. data/templates/html/layout-html5.html.erb +6 -0
  129. data/templates/html/layout-xhtml1.html.erb +6 -0
  130. data/templates/latex/config.erb +45 -27
  131. data/templates/latex/layout.tex.erb +1 -0
  132. data/templates/latex/review-jlreq/README.md +3 -1
  133. data/templates/latex/review-jlreq/review-base.sty +124 -37
  134. data/templates/latex/review-jlreq/review-jlreq.cls +29 -22
  135. data/templates/latex/review-jlreq/review-style.sty +9 -1
  136. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  137. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  138. data/templates/latex/review-jsbook/README.md +46 -5
  139. data/templates/latex/review-jsbook/review-base.sty +111 -30
  140. data/templates/latex/review-jsbook/review-jsbook.cls +16 -2
  141. data/templates/latex/review-jsbook/review-style.sty +10 -2
  142. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  143. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  144. data/templates/opf/epubv2.opf.erb +7 -7
  145. data/templates/opf/epubv3.opf.erb +7 -7
  146. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  147. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  148. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  149. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  150. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  151. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  152. data/templates/web/html/layout-html5.html.erb +9 -8
  153. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  154. data/test/assets/header_listener.html +35 -0
  155. data/test/assets/img_math/img1.png +0 -0
  156. data/test/assets/img_math/img2.png +0 -0
  157. data/test/assets/img_math/img3.png +0 -0
  158. data/test/assets/syntax_book_index_detail.txt +58 -0
  159. data/test/assets/test_template.tex +20 -9
  160. data/test/assets/test_template_backmatter.tex +20 -9
  161. data/test/book_test_helper.rb +11 -5
  162. data/test/run_test.rb +1 -1
  163. data/test/test_book.rb +123 -78
  164. data/test/test_book_chapter.rb +99 -56
  165. data/test/test_book_part.rb +3 -3
  166. data/test/test_builder.rb +24 -15
  167. data/test/test_catalog.rb +19 -42
  168. data/test/test_catalog_converter_cmd.rb +1 -1
  169. data/test/test_converter.rb +1 -0
  170. data/test/test_epub3maker.rb +170 -126
  171. data/test/test_epubmaker.rb +249 -129
  172. data/test/test_epubmaker_cmd.rb +16 -9
  173. data/test/test_helper.rb +23 -11
  174. data/test/test_htmlbuilder.rb +1083 -114
  175. data/test/test_htmlutils.rb +0 -12
  176. data/test/test_i18n.rb +37 -37
  177. data/test/test_idgxmlbuilder.rb +627 -27
  178. data/test/test_idgxmlmaker_cmd.rb +50 -0
  179. data/test/test_image_finder.rb +52 -70
  180. data/test/test_img_math.rb +111 -0
  181. data/test/test_index.rb +62 -52
  182. data/test/test_indexbuilder.rb +52 -0
  183. data/test/test_latexbuilder.rb +1189 -59
  184. data/test/test_latexbuilder_v2.rb +74 -34
  185. data/test/test_lineinput.rb +20 -93
  186. data/test/test_logger.rb +17 -4
  187. data/test/test_makerhelper.rb +2 -14
  188. data/test/test_markdownbuilder.rb +77 -4
  189. data/test/test_md2inaobuilder.rb +12 -2
  190. data/test/test_pdfmaker.rb +101 -12
  191. data/test/test_pdfmaker_cmd.rb +102 -8
  192. data/test/test_plaintextbuilder.rb +562 -31
  193. data/test/test_review_ext.rb +2 -1
  194. data/test/test_reviewheaderlistener.rb +49 -0
  195. data/test/test_rstbuilder.rb +58 -5
  196. data/test/test_sec_counter.rb +156 -0
  197. data/test/test_template.rb +12 -2
  198. data/test/test_textmaker_cmd.rb +58 -0
  199. data/test/test_textutils.rb +109 -2
  200. data/test/test_tocprinter.rb +46 -0
  201. data/test/test_topbuilder.rb +400 -17
  202. data/test/test_update.rb +53 -44
  203. data/test/test_webtocprinter.rb +75 -43
  204. data/test/test_yamlloader.rb +13 -0
  205. data/test/test_zip_exporter.rb +5 -6
  206. data/vendor/gentombow/LICENSE +1 -1
  207. data/vendor/gentombow/Makefile +0 -1
  208. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  209. data/vendor/gentombow/bounddvi-en.tex +1 -0
  210. data/vendor/gentombow/bounddvi.pdf +0 -0
  211. data/vendor/gentombow/bounddvi.sty +30 -7
  212. data/vendor/gentombow/bounddvi.tex +1 -0
  213. data/vendor/gentombow/create_archive.sh +1 -0
  214. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  215. data/vendor/gentombow/gentombow-ja.tex +9 -0
  216. data/vendor/gentombow/gentombow.pdf +0 -0
  217. data/vendor/gentombow/gentombow.sty +32 -10
  218. data/vendor/gentombow/gentombow.tex +8 -0
  219. data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
  220. data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
  221. data/vendor/jsclasses/LICENSE +1 -1
  222. data/vendor/jsclasses/Makefile +3 -2
  223. data/vendor/jsclasses/create_archive.sh +5 -5
  224. data/vendor/jsclasses/jis/Makefile +3 -2
  225. data/vendor/jsclasses/jis/jsarticle.cls +74 -31
  226. data/vendor/jsclasses/jis/jsbook.cls +74 -31
  227. data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
  228. data/vendor/jsclasses/jis/jsclasses.ins +15 -5
  229. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  230. data/vendor/jsclasses/jis/jslogo.ins +9 -0
  231. data/vendor/jsclasses/jis/jslogo.sty +4 -16
  232. data/vendor/jsclasses/jis/jspf.cls +73 -30
  233. data/vendor/jsclasses/jis/jsreport.cls +74 -31
  234. data/vendor/jsclasses/jis/jsverb.ins +9 -0
  235. data/vendor/jsclasses/jis/jsverb.sty +1 -13
  236. data/vendor/jsclasses/jis/kiyou.cls +74 -31
  237. data/vendor/jsclasses/jis/minijs.sty +65 -22
  238. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  239. data/vendor/jsclasses/jis/okumacro.ins +9 -0
  240. data/vendor/jsclasses/jis/okumacro.sty +4 -17
  241. data/vendor/jsclasses/jis/okuverb.ins +9 -0
  242. data/vendor/jsclasses/jis/okuverb.sty +1 -13
  243. data/vendor/jsclasses/jis/winjis.sty +23 -19
  244. data/vendor/jsclasses/jsarticle.cls +74 -31
  245. data/vendor/jsclasses/jsbook.cls +74 -31
  246. data/vendor/jsclasses/jsclasses.dtx +176 -36
  247. data/vendor/jsclasses/jsclasses.ins +15 -5
  248. data/vendor/jsclasses/jsclasses.pdf +0 -0
  249. data/vendor/jsclasses/jslogo.dtx +4 -4
  250. data/vendor/jsclasses/jslogo.ins +9 -0
  251. data/vendor/jsclasses/jslogo.pdf +0 -0
  252. data/vendor/jsclasses/jslogo.sty +4 -16
  253. data/vendor/jsclasses/jspf.cls +73 -30
  254. data/vendor/jsclasses/jsreport.cls +74 -31
  255. data/vendor/jsclasses/jsverb.ins +9 -0
  256. data/vendor/jsclasses/jsverb.pdf +0 -0
  257. data/vendor/jsclasses/jsverb.sty +1 -13
  258. data/vendor/jsclasses/kiyou.cls +74 -31
  259. data/vendor/jsclasses/minijs.sty +68 -22
  260. data/vendor/jsclasses/okumacro.dtx +4 -5
  261. data/vendor/jsclasses/okumacro.ins +9 -0
  262. data/vendor/jsclasses/okumacro.pdf +0 -0
  263. data/vendor/jsclasses/okumacro.sty +4 -17
  264. data/vendor/jsclasses/okuverb.ins +9 -0
  265. data/vendor/jsclasses/okuverb.pdf +0 -0
  266. data/vendor/jsclasses/okuverb.sty +1 -13
  267. data/vendor/jsclasses/tests/relfont.tex +10 -0
  268. data/vendor/jsclasses/winjis.sty +23 -19
  269. metadata +136 -23
  270. data/.rubocop_todo.yml +0 -7
  271. data/lib/epubmaker.rb +0 -23
  272. data/lib/epubmaker/content.rb +0 -110
  273. data/lib/epubmaker/epubcommon.rb +0 -441
  274. data/lib/epubmaker/epubv2.rb +0 -143
  275. data/lib/epubmaker/epubv3.rb +0 -233
  276. data/lib/epubmaker/producer.rb +0 -375
  277. data/lib/epubmaker/zip_exporter.rb +0 -81
  278. data/lib/lineinput.rb +0 -155
  279. data/lib/review/book/compilable.rb +0 -173
  280. data/lib/review/tocparser.rb +0 -271
  281. data/samples/syntax-book/review-ext.rb +0 -14
  282. data/test/test_tocparser.rb +0 -25
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2018-2019 Kenshi Muto
1
+ # Copyright (c) 2018-2020 Kenshi Muto
2
2
  #
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
@@ -74,7 +74,26 @@ module ReVIEW
74
74
  private :blank
75
75
 
76
76
  def result
77
- @output.string
77
+ solve_nest(@output.string)
78
+ end
79
+
80
+ def solve_nest(s)
81
+ check_nest
82
+ lines = []
83
+ clevel = []
84
+ s.split("\n", -1).each do |l| # -1 means don't omit last "\n"
85
+ if l =~ /\A\x01→(dl|ul|ol)←\x01/
86
+ clevel.push($1)
87
+ lines.push("\x01→END←\x01")
88
+ elsif l =~ %r{\A\x01→/(dl|ul|ol)←\x01}
89
+ clevel.pop
90
+ lines.push("\x01→END←\x01")
91
+ else
92
+ lines.push("\t" * clevel.size + l)
93
+ end
94
+ end
95
+
96
+ lines.join("\n").gsub(/\n*\x01→END←\x01\n*/, "\n")
78
97
  end
79
98
 
80
99
  def headline(level, _label, caption)
@@ -87,7 +106,7 @@ module ReVIEW
87
106
  end
88
107
 
89
108
  def ul_item(lines)
90
- puts lines.join
109
+ puts join_lines_to_paragraph(lines)
91
110
  end
92
111
 
93
112
  def ul_end
@@ -100,7 +119,7 @@ module ReVIEW
100
119
  end
101
120
 
102
121
  def ol_item(lines, num)
103
- puts "#{num} #{lines.join}"
122
+ puts "#{num} #{join_lines_to_paragraph(lines)}"
104
123
  end
105
124
 
106
125
  def ol_end
@@ -118,7 +137,7 @@ module ReVIEW
118
137
 
119
138
  def dd(lines)
120
139
  split_paragraph(lines).each do |paragraph|
121
- puts paragraph.gsub(/\n/, '')
140
+ puts paragraph.delete("\n")
122
141
  end
123
142
  end
124
143
 
@@ -127,7 +146,7 @@ module ReVIEW
127
146
  end
128
147
 
129
148
  def paragraph(lines)
130
- puts lines.join
149
+ puts join_lines_to_paragraph(lines)
131
150
  end
132
151
 
133
152
  def read(lines)
@@ -137,27 +156,47 @@ module ReVIEW
137
156
 
138
157
  alias_method :lead, :read
139
158
 
140
- def list_header(id, caption, _lang)
159
+ def list(lines, id, caption, lang = nil)
141
160
  blank
161
+ begin
162
+ if caption_top?('list')
163
+ list_header(id, caption, lang)
164
+ blank
165
+ end
166
+ list_body(id, lines, lang)
167
+ unless caption_top?('list')
168
+ blank
169
+ list_header(id, caption, lang)
170
+ end
171
+ rescue KeyError
172
+ error "no such list: #{id}"
173
+ end
174
+ blank
175
+ end
176
+
177
+ def list_header(id, caption, _lang)
142
178
  if get_chap
143
179
  puts %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
144
180
  else
145
181
  puts %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
146
182
  end
147
- blank
148
183
  end
149
184
 
150
185
  def list_body(_id, lines, _lang)
151
186
  lines.each do |line|
152
187
  puts detab(line)
153
188
  end
154
- blank
155
189
  end
156
190
 
157
191
  def base_block(_type, lines, caption = nil)
158
192
  blank
159
- puts compile_inline(caption) if caption.present?
193
+ if caption_top?('list') && caption.present?
194
+ puts compile_inline(caption)
195
+ end
160
196
  puts lines.join("\n")
197
+ if !caption_top?('list') && caption.present?
198
+ puts compile_inline(caption)
199
+ end
161
200
  blank
162
201
  end
163
202
 
@@ -169,15 +208,38 @@ module ReVIEW
169
208
  end
170
209
 
171
210
  def emlist(lines, caption = nil, _lang = nil)
172
- base_block 'emlist', lines, caption
211
+ base_block('emlist', lines, caption)
173
212
  end
174
213
 
175
214
  def emlistnum(lines, caption = nil, _lang = nil)
176
215
  blank
177
- puts compile_inline(caption) if caption.present?
216
+ if caption_top?('list')
217
+ puts compile_inline(caption) if caption.present?
218
+ end
178
219
  lines.each_with_index do |line, i|
179
220
  puts((i + 1).to_s.rjust(2) + ": #{line}")
180
221
  end
222
+ unless caption_top?('list')
223
+ puts compile_inline(caption) if caption.present?
224
+ end
225
+ blank
226
+ end
227
+
228
+ def listnum(lines, id, caption, lang = nil)
229
+ blank
230
+ begin
231
+ if caption_top?('list')
232
+ list_header(id, caption, lang)
233
+ blank
234
+ end
235
+ listnum_body(lines, lang)
236
+ unless caption_top?('list')
237
+ blank
238
+ list_header(id, caption, lang)
239
+ end
240
+ rescue KeyError
241
+ error "no such list: #{id}"
242
+ end
181
243
  blank
182
244
  end
183
245
 
@@ -185,15 +247,14 @@ module ReVIEW
185
247
  lines.each_with_index do |line, i|
186
248
  puts((i + 1).to_s.rjust(2) + ": #{line}")
187
249
  end
188
- blank
189
250
  end
190
251
 
191
252
  def cmd(lines, caption = nil)
192
- base_block 'cmd', lines, caption
253
+ base_block('cmd', lines, caption)
193
254
  end
194
255
 
195
256
  def quote(lines)
196
- base_parablock 'quote', lines, nil
257
+ base_parablock('quote', lines, nil)
197
258
  end
198
259
 
199
260
  def image(_lines, id, caption, _metric = nil)
@@ -207,59 +268,35 @@ module ReVIEW
207
268
  end
208
269
 
209
270
  def texequation(lines, id = nil, caption = '')
271
+ blank
272
+ texequation_header(id, caption) if caption_top?('equation')
273
+ puts lines.join("\n")
274
+ texequation_header(id, caption) unless caption_top?('equation')
275
+ blank
276
+ end
277
+
278
+ def texequation_header(id, caption)
210
279
  if id
211
- blank
212
280
  if get_chap
213
281
  puts "#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
214
282
  else
215
283
  puts "#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
216
284
  end
217
285
  end
218
-
219
- puts lines.join("\n")
220
- blank
221
286
  end
222
287
 
223
- def table(lines, id = nil, caption = nil)
224
- rows = []
225
- sepidx = nil
226
- lines.each_with_index do |line, idx|
227
- if /\A[\=\-]{12}/ =~ line
228
- # just ignore
229
- # error "too many table separator" if sepidx
230
- sepidx ||= idx
231
- next
232
- end
233
- rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
234
- end
235
- rows = adjust_n_cols(rows)
236
- error 'no rows in the table' if rows.empty?
237
-
238
- blank
239
-
240
- begin
241
- table_header(id, caption) if caption.present?
242
- rescue KeyError
243
- error "no such table: #{id}"
244
- end
245
- table_begin rows.first.size
246
- if sepidx
247
- sepidx.times do
248
- tr(rows.shift.map { |s| th(s) })
249
- end
250
- rows.each do |cols|
251
- tr(cols.map { |s| td(s) })
252
- end
253
- else
254
- rows.each do |cols|
255
- h, *cs = *cols
256
- tr([th(h)] + cs.map { |s| td(s) })
257
- end
288
+ def table(lines, id = nil, caption = nil, noblank = nil)
289
+ unless noblank
290
+ blank
258
291
  end
259
- table_end
292
+ super(lines, id, caption)
260
293
  end
261
294
 
262
295
  def table_header(id, caption)
296
+ unless caption_top?('table')
297
+ blank
298
+ end
299
+
263
300
  if id.nil?
264
301
  puts compile_inline(caption)
265
302
  elsif get_chap
@@ -267,7 +304,10 @@ module ReVIEW
267
304
  else
268
305
  puts "#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [@chapter.table(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
269
306
  end
270
- blank
307
+
308
+ if caption_top?('table')
309
+ blank
310
+ end
271
311
  end
272
312
 
273
313
  def table_begin(_ncols)
@@ -345,8 +385,8 @@ module ReVIEW
345
385
  end
346
386
 
347
387
  def bibpaper(lines, id, caption)
348
- bibpaper_header id, caption
349
- bibpaper_bibpaper id, caption, lines unless lines.empty?
388
+ bibpaper_header(id, caption)
389
+ bibpaper_bibpaper(id, caption, lines) unless lines.empty?
350
390
  end
351
391
 
352
392
  def bibpaper_header(id, caption)
@@ -355,7 +395,7 @@ module ReVIEW
355
395
  end
356
396
 
357
397
  def bibpaper_bibpaper(_id, _caption, lines)
358
- print split_paragraph(lines).join
398
+ puts split_paragraph(lines).join("\n")
359
399
  end
360
400
 
361
401
  def inline_bib(id)
@@ -472,91 +512,118 @@ module ReVIEW
472
512
  end
473
513
 
474
514
  def flushright(lines)
475
- base_parablock 'flushright', lines, nil
515
+ base_parablock('flushright', lines, nil)
476
516
  end
477
517
 
478
518
  def centering(lines)
479
- base_parablock 'centering', lines, nil
519
+ base_parablock('centering', lines, nil)
480
520
  end
481
521
 
482
522
  def note(lines, caption = nil)
483
- base_parablock 'note', lines, caption
523
+ check_nested_minicolumn
524
+ base_parablock('note', lines, caption)
484
525
  end
485
526
 
486
527
  def memo(lines, caption = nil)
487
- base_parablock 'memo', lines, caption
528
+ check_nested_minicolumn
529
+ base_parablock('memo', lines, caption)
488
530
  end
489
531
 
490
532
  def tip(lines, caption = nil)
491
- base_parablock 'tip', lines, caption
533
+ check_nested_minicolumn
534
+ base_parablock('tip', lines, caption)
492
535
  end
493
536
 
494
537
  def info(lines, caption = nil)
495
- base_parablock 'info', lines, caption
538
+ check_nested_minicolumn
539
+ base_parablock('info', lines, caption)
496
540
  end
497
541
 
498
542
  def planning(lines, caption = nil)
499
- base_parablock 'planning', lines, caption
543
+ base_parablock('planning', lines, caption)
500
544
  end
501
545
 
502
546
  def best(lines, caption = nil)
503
- base_parablock 'best', lines, caption
547
+ check_nested_minicolumn
548
+ base_parablock('best', lines, caption)
504
549
  end
505
550
 
506
551
  def important(lines, caption = nil)
507
- base_parablock 'important', lines, caption
552
+ check_nested_minicolumn
553
+ base_parablock('important', lines, caption)
508
554
  end
509
555
 
510
556
  def security(lines, caption = nil)
511
- base_parablock 'security', lines, caption
557
+ base_parablock('security', lines, caption)
512
558
  end
513
559
 
514
560
  def caution(lines, caption = nil)
515
- base_parablock 'caution', lines, caption
561
+ check_nested_minicolumn
562
+ base_parablock('caution', lines, caption)
516
563
  end
517
564
 
518
565
  def term(lines)
519
- base_parablock 'term', lines, nil
566
+ base_parablock('term', lines, nil)
520
567
  end
521
568
 
522
569
  def link(lines, caption = nil)
523
- base_parablock 'link', lines, caption
570
+ base_parablock('link', lines, caption)
524
571
  end
525
572
 
526
573
  def notice(lines, caption = nil)
527
- base_parablock 'notice', lines, caption
574
+ check_nested_minicolumn
575
+ base_parablock('notice', lines, caption)
528
576
  end
529
577
 
530
578
  def point(lines, caption = nil)
531
- base_parablock 'point', lines, caption
579
+ base_parablock('point', lines, caption)
532
580
  end
533
581
 
534
582
  def shoot(lines, caption = nil)
535
- base_parablock 'shoot', lines, caption
583
+ base_parablock('shoot', lines, caption)
536
584
  end
537
585
 
538
586
  def reference(lines)
539
- base_parablock 'reference', lines, nil
587
+ base_parablock('reference', lines, nil)
540
588
  end
541
589
 
542
590
  def practice(lines)
543
- base_parablock 'practice', lines, nil
591
+ base_parablock('practice', lines, nil)
544
592
  end
545
593
 
546
594
  def expert(lines)
547
- base_parablock 'expert', lines, nil
595
+ base_parablock('expert', lines, nil)
548
596
  end
549
597
 
550
598
  def insn(lines, caption = nil)
551
- base_block 'insn', lines, caption
599
+ base_block('insn', lines, caption)
552
600
  end
553
601
 
554
602
  def warning(lines, caption = nil)
555
- base_parablock 'warning', lines, caption
603
+ check_nested_minicolumn
604
+ base_parablock('warning', lines, caption)
556
605
  end
557
606
 
558
607
  alias_method :box, :insn
559
608
 
609
+ CAPTION_TITLES.each do |name|
610
+ class_eval %Q(
611
+ def #{name}_begin(caption = nil)
612
+ check_nested_minicolumn
613
+ @doc_status[:minicolumn] = '#{name}'
614
+ blank
615
+ if caption.present?
616
+ puts compile_inline(caption)
617
+ end
618
+ end
619
+
620
+ def #{name}_end
621
+ blank
622
+ @doc_status[:minicolumn] = nil
623
+ end
624
+ ), __FILE__, __LINE__ - 14
625
+ end
626
+
560
627
  def indepimage(_lines, _id, caption = nil, _metric = nil)
561
628
  blank
562
629
  puts "図 #{compile_inline(caption)}" if caption.present?
@@ -573,17 +640,25 @@ module ReVIEW
573
640
  end
574
641
 
575
642
  def bpo(lines)
576
- base_block 'bpo', lines, nil
643
+ base_block('bpo', lines, nil)
577
644
  end
578
645
 
579
646
  def inline_dtp(_str)
580
647
  ''
581
648
  end
582
649
 
650
+ def inline_ins(str)
651
+ str
652
+ end
653
+
583
654
  def inline_del(_str)
584
655
  ''
585
656
  end
586
657
 
658
+ def inline_tcy(str)
659
+ str
660
+ end
661
+
587
662
  def inline_br(_str)
588
663
  "\n"
589
664
  end
@@ -592,7 +667,7 @@ module ReVIEW
592
667
  str
593
668
  end
594
669
 
595
- def inline_chap(id)
670
+ def inline_chap(id) # rubocop:disable Lint/UselessMethodDefinition
596
671
  # "「第#{super}章 #{inline_title(id)}」"
597
672
  # "第#{super}章"
598
673
  super
@@ -623,7 +698,7 @@ module ReVIEW
623
698
  end
624
699
 
625
700
  def source(lines, caption = nil, _lang = nil)
626
- base_block 'source', lines, caption
701
+ base_block('source', lines, caption)
627
702
  end
628
703
 
629
704
  def inline_labelref(_idref)