review 3.0.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-win.yml +39 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +50 -12
- data/.travis.yml +17 -8
- data/Dockerfile +21 -5
- data/NEWS.ja.md +358 -0
- data/NEWS.md +358 -1
- data/README.md +11 -8
- data/appveyor.yml +1 -3
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -8
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +12 -12
- data/bin/review-epubmaker +3 -35
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +2 -89
- data/bin/review-preproc +14 -19
- data/bin/review-validate +3 -3
- data/bin/review-vol +4 -78
- data/doc/LICENSE +1 -1
- data/doc/config.yml.sample +46 -12
- data/doc/config.yml.sample-simple +4 -2
- data/doc/format.ja.md +37 -13
- data/doc/format.md +35 -20
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- data/doc/quickstart.ja.md +46 -26
- data/doc/quickstart.md +38 -17
- data/lib/epubmaker/epubcommon.rb +10 -5
- data/lib/epubmaker/epubv2.rb +1 -1
- data/lib/epubmaker/epubv3.rb +1 -0
- data/lib/epubmaker/producer.rb +4 -2
- data/lib/review/book.rb +1 -1
- data/lib/review/book/base.rb +38 -79
- data/lib/review/book/chapter.rb +18 -3
- data/lib/review/book/compilable.rb +6 -5
- data/lib/review/book/index.rb +69 -101
- data/lib/review/book/index/item.rb +40 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +28 -5
- data/lib/review/book/volume.rb +3 -4
- data/lib/review/builder.rb +105 -44
- data/lib/review/catalog.rb +13 -16
- data/lib/review/compiler.rb +84 -72
- data/lib/review/configure.rb +19 -8
- data/lib/review/epub2html.rb +37 -4
- data/lib/review/epubmaker.rb +62 -7
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +102 -115
- data/lib/review/htmlutils.rb +2 -3
- data/lib/review/i18n.rb +2 -2
- data/lib/review/i18n.yml +9 -0
- data/lib/review/idgxmlbuilder.rb +153 -74
- data/lib/review/idgxmlmaker.rb +191 -0
- data/lib/review/init-web/finish.html +10 -0
- data/lib/review/init-web/index.html +190 -0
- data/lib/review/init-web/review-layout-design.js +691 -0
- data/lib/review/init.rb +125 -34
- data/lib/review/latexbuilder.rb +199 -88
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/location.rb +32 -0
- data/lib/review/logger.rb +4 -8
- data/lib/review/makerhelper.rb +24 -5
- data/lib/review/markdownbuilder.rb +31 -37
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +44 -22
- data/lib/review/plaintextbuilder.rb +106 -85
- data/lib/review/preprocessor.rb +32 -41
- data/lib/review/rstbuilder.rb +33 -33
- data/lib/review/textmaker.rb +19 -3
- data/lib/review/textutils.rb +76 -2
- data/lib/review/tocprinter.rb +231 -102
- data/lib/review/topbuilder.rb +114 -61
- data/lib/review/update.rb +19 -19
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +99 -0
- data/lib/review/webmaker.rb +11 -4
- data/lib/review/webtocprinter.rb +38 -35
- data/lib/review/yamlloader.rb +26 -16
- data/review.gemspec +6 -4
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +154 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/config.yml +2 -2
- data/samples/sample-book/src/lib/tasks/review.rake +29 -14
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/ch01.re +4 -2
- data/samples/syntax-book/ch02.re +8 -16
- data/samples/syntax-book/ch03.re +3 -6
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/lib/tasks/review.rake +30 -15
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/latex/config.erb +16 -0
- data/templates/latex/layout.tex.erb +4 -0
- data/templates/latex/review-jlreq/review-base.sty +150 -61
- data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
- data/templates/latex/review-jlreq/review-style.sty +4 -1
- data/templates/latex/review-jsbook/README.md +39 -0
- data/templates/latex/review-jsbook/review-base.sty +101 -23
- data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
- data/templates/latex/review-jsbook/review-style.sty +5 -2
- data/templates/opf/epubv3.opf.erb +1 -0
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/test_template.tex +24 -3
- data/test/assets/test_template_backmatter.tex +24 -3
- data/test/test_book.rb +75 -21
- data/test/test_book_chapter.rb +4 -2
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +16 -0
- data/test/test_catalog.rb +24 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +15 -7
- data/test/test_htmlbuilder.rb +909 -159
- data/test/test_i18n.rb +25 -25
- data/test/test_idgxmlbuilder.rb +395 -38
- data/test/test_idgxmlmaker_cmd.rb +46 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_index.rb +50 -10
- data/test/test_latexbuilder.rb +1194 -106
- data/test/test_latexbuilder_v2.rb +628 -97
- data/test/test_logger.rb +14 -1
- data/test/test_makerhelper.rb +3 -3
- data/test/test_markdownbuilder.rb +134 -16
- data/test/test_md2inaobuilder.rb +32 -9
- data/test/test_pdfmaker.rb +18 -1
- data/test/test_pdfmaker_cmd.rb +100 -6
- data/test/test_plaintextbuilder.rb +371 -25
- data/test/test_preprocessor.rb +2 -16
- data/test/test_rstbuilder.rb +249 -26
- data/test/test_textmaker_cmd.rb +54 -0
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +546 -31
- data/test/test_update.rb +17 -8
- data/test/test_webtocprinter.rb +66 -34
- data/test/test_yamlloader.rb +13 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/jis/jsarticle.cls +53 -14
- data/vendor/jsclasses/jis/jsbook.cls +53 -14
- data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.sty +3 -3
- data/vendor/jsclasses/jis/jspf.cls +52 -13
- data/vendor/jsclasses/jis/jsreport.cls +53 -14
- data/vendor/jsclasses/jis/kiyou.cls +53 -14
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.sty +3 -4
- data/vendor/jsclasses/jsarticle.cls +53 -14
- data/vendor/jsclasses/jsbook.cls +53 -14
- data/vendor/jsclasses/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +3 -3
- data/vendor/jsclasses/jspf.cls +52 -13
- data/vendor/jsclasses/jsreport.cls +53 -14
- data/vendor/jsclasses/kiyou.cls +53 -14
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +3 -4
- metadata +55 -10
- data/lib/review/tocparser.rb +0 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2018 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
|
@@ -87,7 +87,7 @@ module ReVIEW
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def ul_item(lines)
|
90
|
-
puts lines
|
90
|
+
puts join_lines_to_paragraph(lines)
|
91
91
|
end
|
92
92
|
|
93
93
|
def ul_end
|
@@ -100,7 +100,7 @@ module ReVIEW
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def ol_item(lines, num)
|
103
|
-
puts "#{num} #{lines
|
103
|
+
puts "#{num} #{join_lines_to_paragraph(lines)}"
|
104
104
|
end
|
105
105
|
|
106
106
|
def ol_end
|
@@ -127,7 +127,7 @@ module ReVIEW
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def paragraph(lines)
|
130
|
-
puts lines
|
130
|
+
puts join_lines_to_paragraph(lines)
|
131
131
|
end
|
132
132
|
|
133
133
|
def read(lines)
|
@@ -137,27 +137,47 @@ module ReVIEW
|
|
137
137
|
|
138
138
|
alias_method :lead, :read
|
139
139
|
|
140
|
-
def
|
140
|
+
def list(lines, id, caption, lang = nil)
|
141
|
+
blank
|
142
|
+
begin
|
143
|
+
if caption_top?('list')
|
144
|
+
list_header(id, caption, lang)
|
145
|
+
blank
|
146
|
+
end
|
147
|
+
list_body(id, lines, lang)
|
148
|
+
unless caption_top?('list')
|
149
|
+
blank
|
150
|
+
list_header(id, caption, lang)
|
151
|
+
end
|
152
|
+
rescue KeyError
|
153
|
+
error "no such list: #{id}"
|
154
|
+
end
|
141
155
|
blank
|
156
|
+
end
|
157
|
+
|
158
|
+
def list_header(id, caption, _lang)
|
142
159
|
if get_chap
|
143
160
|
puts %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
144
161
|
else
|
145
162
|
puts %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
146
163
|
end
|
147
|
-
blank
|
148
164
|
end
|
149
165
|
|
150
166
|
def list_body(_id, lines, _lang)
|
151
167
|
lines.each do |line|
|
152
168
|
puts detab(line)
|
153
169
|
end
|
154
|
-
blank
|
155
170
|
end
|
156
171
|
|
157
172
|
def base_block(_type, lines, caption = nil)
|
158
173
|
blank
|
159
|
-
|
174
|
+
if caption_top?('list') && caption.present?
|
175
|
+
puts compile_inline(caption)
|
176
|
+
end
|
160
177
|
puts lines.join("\n")
|
178
|
+
if !caption_top?('list') && caption.present?
|
179
|
+
puts compile_inline(caption)
|
180
|
+
end
|
161
181
|
blank
|
162
182
|
end
|
163
183
|
|
@@ -169,15 +189,38 @@ module ReVIEW
|
|
169
189
|
end
|
170
190
|
|
171
191
|
def emlist(lines, caption = nil, _lang = nil)
|
172
|
-
base_block
|
192
|
+
base_block('emlist', lines, caption)
|
173
193
|
end
|
174
194
|
|
175
195
|
def emlistnum(lines, caption = nil, _lang = nil)
|
176
196
|
blank
|
177
|
-
|
197
|
+
if caption_top?('list')
|
198
|
+
puts compile_inline(caption) if caption.present?
|
199
|
+
end
|
178
200
|
lines.each_with_index do |line, i|
|
179
201
|
puts((i + 1).to_s.rjust(2) + ": #{line}")
|
180
202
|
end
|
203
|
+
unless caption_top?('list')
|
204
|
+
puts compile_inline(caption) if caption.present?
|
205
|
+
end
|
206
|
+
blank
|
207
|
+
end
|
208
|
+
|
209
|
+
def listnum(lines, id, caption, lang = nil)
|
210
|
+
blank
|
211
|
+
begin
|
212
|
+
if caption_top?('list')
|
213
|
+
list_header(id, caption, lang)
|
214
|
+
blank
|
215
|
+
end
|
216
|
+
listnum_body(lines, lang)
|
217
|
+
unless caption_top?('list')
|
218
|
+
blank
|
219
|
+
list_header(id, caption, lang)
|
220
|
+
end
|
221
|
+
rescue KeyError
|
222
|
+
error "no such list: #{id}"
|
223
|
+
end
|
181
224
|
blank
|
182
225
|
end
|
183
226
|
|
@@ -185,15 +228,14 @@ module ReVIEW
|
|
185
228
|
lines.each_with_index do |line, i|
|
186
229
|
puts((i + 1).to_s.rjust(2) + ": #{line}")
|
187
230
|
end
|
188
|
-
blank
|
189
231
|
end
|
190
232
|
|
191
233
|
def cmd(lines, caption = nil)
|
192
|
-
base_block
|
234
|
+
base_block('cmd', lines, caption)
|
193
235
|
end
|
194
236
|
|
195
237
|
def quote(lines)
|
196
|
-
base_parablock
|
238
|
+
base_parablock('quote', lines, nil)
|
197
239
|
end
|
198
240
|
|
199
241
|
def image(_lines, id, caption, _metric = nil)
|
@@ -207,58 +249,35 @@ module ReVIEW
|
|
207
249
|
end
|
208
250
|
|
209
251
|
def texequation(lines, id = nil, caption = '')
|
252
|
+
blank
|
253
|
+
texequation_header(id, caption) if caption_top?('equation')
|
254
|
+
puts lines.join("\n")
|
255
|
+
texequation_header(id, caption) unless caption_top?('equation')
|
256
|
+
blank
|
257
|
+
end
|
258
|
+
|
259
|
+
def texequation_header(id, caption)
|
210
260
|
if id
|
211
|
-
blank
|
212
261
|
if get_chap
|
213
262
|
puts "#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
214
263
|
else
|
215
264
|
puts "#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
216
265
|
end
|
217
266
|
end
|
218
|
-
|
219
|
-
puts lines.join("\n")
|
220
|
-
blank
|
221
267
|
end
|
222
268
|
|
223
|
-
def table(lines, id = nil, caption = nil)
|
224
|
-
|
225
|
-
|
226
|
-
sepidx = nil
|
227
|
-
lines.each_with_index do |line, idx|
|
228
|
-
if /\A[\=\-]{12}/ =~ line
|
229
|
-
# just ignore
|
230
|
-
# error "too many table separator" if sepidx
|
231
|
-
sepidx ||= idx
|
232
|
-
next
|
233
|
-
end
|
234
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
235
|
-
end
|
236
|
-
rows = adjust_n_cols(rows)
|
237
|
-
|
238
|
-
begin
|
239
|
-
table_header(id, caption) if caption.present?
|
240
|
-
rescue KeyError
|
241
|
-
error "no such table: #{id}"
|
242
|
-
end
|
243
|
-
return if rows.empty?
|
244
|
-
table_begin rows.first.size
|
245
|
-
if sepidx
|
246
|
-
sepidx.times do
|
247
|
-
tr(rows.shift.map { |s| th(s) })
|
248
|
-
end
|
249
|
-
rows.each do |cols|
|
250
|
-
tr(cols.map { |s| td(s) })
|
251
|
-
end
|
252
|
-
else
|
253
|
-
rows.each do |cols|
|
254
|
-
h, *cs = *cols
|
255
|
-
tr([th(h)] + cs.map { |s| td(s) })
|
256
|
-
end
|
269
|
+
def table(lines, id = nil, caption = nil, noblank = nil)
|
270
|
+
unless noblank
|
271
|
+
blank
|
257
272
|
end
|
258
|
-
|
273
|
+
super(lines, id, caption)
|
259
274
|
end
|
260
275
|
|
261
276
|
def table_header(id, caption)
|
277
|
+
unless caption_top?('table')
|
278
|
+
blank
|
279
|
+
end
|
280
|
+
|
262
281
|
if id.nil?
|
263
282
|
puts compile_inline(caption)
|
264
283
|
elsif get_chap
|
@@ -266,7 +285,10 @@ module ReVIEW
|
|
266
285
|
else
|
267
286
|
puts "#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [@chapter.table(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
268
287
|
end
|
269
|
-
|
288
|
+
|
289
|
+
if caption_top?('table')
|
290
|
+
blank
|
291
|
+
end
|
270
292
|
end
|
271
293
|
|
272
294
|
def table_begin(_ncols)
|
@@ -344,8 +366,8 @@ module ReVIEW
|
|
344
366
|
end
|
345
367
|
|
346
368
|
def bibpaper(lines, id, caption)
|
347
|
-
bibpaper_header
|
348
|
-
bibpaper_bibpaper
|
369
|
+
bibpaper_header(id, caption)
|
370
|
+
bibpaper_bibpaper(id, caption, lines) unless lines.empty?
|
349
371
|
end
|
350
372
|
|
351
373
|
def bibpaper_header(id, caption)
|
@@ -354,7 +376,7 @@ module ReVIEW
|
|
354
376
|
end
|
355
377
|
|
356
378
|
def bibpaper_bibpaper(_id, _caption, lines)
|
357
|
-
|
379
|
+
puts split_paragraph(lines).join("\n")
|
358
380
|
end
|
359
381
|
|
360
382
|
def inline_bib(id)
|
@@ -364,13 +386,12 @@ module ReVIEW
|
|
364
386
|
end
|
365
387
|
|
366
388
|
def inline_hd_chap(chap, id)
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
389
|
+
n = chap.headline_index.number(id)
|
390
|
+
if n.present? && chap.number && over_secnolevel?(n)
|
391
|
+
I18n.t('hd_quote', [n, compile_inline(chap.headline(id).caption)])
|
392
|
+
else
|
393
|
+
I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
|
372
394
|
end
|
373
|
-
I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
|
374
395
|
rescue KeyError
|
375
396
|
error "unknown headline: #{id}"
|
376
397
|
end
|
@@ -472,87 +493,87 @@ module ReVIEW
|
|
472
493
|
end
|
473
494
|
|
474
495
|
def flushright(lines)
|
475
|
-
base_parablock
|
496
|
+
base_parablock('flushright', lines, nil)
|
476
497
|
end
|
477
498
|
|
478
499
|
def centering(lines)
|
479
|
-
base_parablock
|
500
|
+
base_parablock('centering', lines, nil)
|
480
501
|
end
|
481
502
|
|
482
503
|
def note(lines, caption = nil)
|
483
|
-
base_parablock
|
504
|
+
base_parablock('note', lines, caption)
|
484
505
|
end
|
485
506
|
|
486
507
|
def memo(lines, caption = nil)
|
487
|
-
base_parablock
|
508
|
+
base_parablock('memo', lines, caption)
|
488
509
|
end
|
489
510
|
|
490
511
|
def tip(lines, caption = nil)
|
491
|
-
base_parablock
|
512
|
+
base_parablock('tip', lines, caption)
|
492
513
|
end
|
493
514
|
|
494
515
|
def info(lines, caption = nil)
|
495
|
-
base_parablock
|
516
|
+
base_parablock('info', lines, caption)
|
496
517
|
end
|
497
518
|
|
498
519
|
def planning(lines, caption = nil)
|
499
|
-
base_parablock
|
520
|
+
base_parablock('planning', lines, caption)
|
500
521
|
end
|
501
522
|
|
502
523
|
def best(lines, caption = nil)
|
503
|
-
base_parablock
|
524
|
+
base_parablock('best', lines, caption)
|
504
525
|
end
|
505
526
|
|
506
527
|
def important(lines, caption = nil)
|
507
|
-
base_parablock
|
528
|
+
base_parablock('important', lines, caption)
|
508
529
|
end
|
509
530
|
|
510
531
|
def security(lines, caption = nil)
|
511
|
-
base_parablock
|
532
|
+
base_parablock('security', lines, caption)
|
512
533
|
end
|
513
534
|
|
514
535
|
def caution(lines, caption = nil)
|
515
|
-
base_parablock
|
536
|
+
base_parablock('caution', lines, caption)
|
516
537
|
end
|
517
538
|
|
518
539
|
def term(lines)
|
519
|
-
base_parablock
|
540
|
+
base_parablock('term', lines, nil)
|
520
541
|
end
|
521
542
|
|
522
543
|
def link(lines, caption = nil)
|
523
|
-
base_parablock
|
544
|
+
base_parablock('link', lines, caption)
|
524
545
|
end
|
525
546
|
|
526
547
|
def notice(lines, caption = nil)
|
527
|
-
base_parablock
|
548
|
+
base_parablock('notice', lines, caption)
|
528
549
|
end
|
529
550
|
|
530
551
|
def point(lines, caption = nil)
|
531
|
-
base_parablock
|
552
|
+
base_parablock('point', lines, caption)
|
532
553
|
end
|
533
554
|
|
534
555
|
def shoot(lines, caption = nil)
|
535
|
-
base_parablock
|
556
|
+
base_parablock('shoot', lines, caption)
|
536
557
|
end
|
537
558
|
|
538
559
|
def reference(lines)
|
539
|
-
base_parablock
|
560
|
+
base_parablock('reference', lines, nil)
|
540
561
|
end
|
541
562
|
|
542
563
|
def practice(lines)
|
543
|
-
base_parablock
|
564
|
+
base_parablock('practice', lines, nil)
|
544
565
|
end
|
545
566
|
|
546
567
|
def expert(lines)
|
547
|
-
base_parablock
|
568
|
+
base_parablock('expert', lines, nil)
|
548
569
|
end
|
549
570
|
|
550
571
|
def insn(lines, caption = nil)
|
551
|
-
base_block
|
572
|
+
base_block('insn', lines, caption)
|
552
573
|
end
|
553
574
|
|
554
575
|
def warning(lines, caption = nil)
|
555
|
-
base_parablock
|
576
|
+
base_parablock('warning', lines, caption)
|
556
577
|
end
|
557
578
|
|
558
579
|
alias_method :box, :insn
|
@@ -573,7 +594,7 @@ module ReVIEW
|
|
573
594
|
end
|
574
595
|
|
575
596
|
def bpo(lines)
|
576
|
-
base_block
|
597
|
+
base_block('bpo', lines, nil)
|
577
598
|
end
|
578
599
|
|
579
600
|
def inline_dtp(_str)
|
@@ -623,7 +644,7 @@ module ReVIEW
|
|
623
644
|
end
|
624
645
|
|
625
646
|
def source(lines, caption = nil, _lang = nil)
|
626
|
-
base_block
|
647
|
+
base_block('source', lines, caption)
|
627
648
|
end
|
628
649
|
|
629
650
|
def inline_labelref(_idref)
|
data/lib/review/preprocessor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2010-
|
1
|
+
# Copyright (c) 2010-2019 Minero Aoki, Kenshi Muto
|
2
2
|
# 2002-2009 Minero Aoki
|
3
3
|
#
|
4
4
|
# This program is free software.
|
@@ -43,41 +43,20 @@ module ReVIEW
|
|
43
43
|
class Preprocessor
|
44
44
|
include ErrorUtils
|
45
45
|
|
46
|
-
class Strip
|
47
|
-
def initialize(f)
|
48
|
-
@f = f
|
49
|
-
end
|
50
|
-
|
51
|
-
def path
|
52
|
-
@f.path
|
53
|
-
end
|
54
|
-
|
55
|
-
def lineno
|
56
|
-
@f.lineno
|
57
|
-
end
|
58
|
-
|
59
|
-
def gets
|
60
|
-
@f.each_line do |line|
|
61
|
-
return "\#@\#\n" if /\A\#@/ =~ line
|
62
|
-
return line
|
63
|
-
end
|
64
|
-
nil
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
46
|
def initialize(repo, param)
|
69
47
|
@repository = repo
|
70
48
|
@config = param
|
71
49
|
@logger = ReVIEW.logger
|
50
|
+
@leave_content = nil
|
72
51
|
end
|
73
52
|
|
74
53
|
def process(inf, outf)
|
75
|
-
init_errorutils
|
54
|
+
init_errorutils(inf)
|
76
55
|
@f = outf
|
77
56
|
begin
|
78
|
-
preproc
|
79
|
-
rescue Errno::ENOENT =>
|
80
|
-
error
|
57
|
+
preproc(inf)
|
58
|
+
rescue Errno::ENOENT => e
|
59
|
+
error e.message
|
81
60
|
end
|
82
61
|
end
|
83
62
|
|
@@ -101,11 +80,12 @@ module ReVIEW
|
|
101
80
|
direc = parse_directive(line, 1, 'stderr')
|
102
81
|
@f.print line
|
103
82
|
get_output(expand(direc.arg), direc['stderr']).each { |out| @f.print out.string }
|
104
|
-
skip_list
|
83
|
+
skip_list(f)
|
105
84
|
|
106
85
|
when /\A\#@mapfile/
|
107
86
|
direc = parse_directive(line, 1, 'eval')
|
108
87
|
path = expand(direc.arg)
|
88
|
+
@leave_content = File.extname(path) == '.re'
|
109
89
|
if direc['eval']
|
110
90
|
ent = evaluate(path, ent)
|
111
91
|
else
|
@@ -116,6 +96,7 @@ module ReVIEW
|
|
116
96
|
when /\A\#@map(?:range)?/
|
117
97
|
direc = parse_directive(line, 2, 'unindent')
|
118
98
|
path = expand(direc.args[0])
|
99
|
+
@leave_content = File.extname(path) == '.re'
|
119
100
|
ent = @repository.fetch_range(path, direc.args[1]) or
|
120
101
|
error "unknown range: #{path}: #{direc.args[1]}"
|
121
102
|
ent = (direc['unindent'] ? unindent(ent, direc['unindent']) : ent)
|
@@ -127,6 +108,9 @@ module ReVIEW
|
|
127
108
|
when /\A\#@/
|
128
109
|
op = line.slice(/@(\w+)/, 1)
|
129
110
|
warn "unknown directive: #{line.strip}" unless known_directive?(op)
|
111
|
+
if op == 'warn'
|
112
|
+
warn line.strip.sub(/\#@warn\((.+)\)/, '\1')
|
113
|
+
end
|
130
114
|
@f.print line
|
131
115
|
|
132
116
|
when /\A\s*\z/ # empty line
|
@@ -147,15 +131,15 @@ module ReVIEW
|
|
147
131
|
@f.print directive_line
|
148
132
|
newlines.each do |line|
|
149
133
|
if with_lineno
|
150
|
-
print_number
|
134
|
+
print_number(line.number)
|
151
135
|
end
|
152
136
|
@f.print line.string
|
153
137
|
end
|
154
|
-
skip_list
|
138
|
+
skip_list(f)
|
155
139
|
end
|
156
140
|
|
157
141
|
def print_number(num)
|
158
|
-
@f.printf
|
142
|
+
@f.printf('%4s ', (num ? num.to_s : ''))
|
159
143
|
end
|
160
144
|
|
161
145
|
def skip_list(f)
|
@@ -166,9 +150,11 @@ module ReVIEW
|
|
166
150
|
@f.print line
|
167
151
|
return nil
|
168
152
|
when %r{\A//\}}
|
169
|
-
|
170
|
-
|
171
|
-
|
153
|
+
unless @leave_content
|
154
|
+
warn '//} seen in list'
|
155
|
+
@f.print line
|
156
|
+
return nil
|
157
|
+
end
|
172
158
|
when /\A\#@\w/
|
173
159
|
warn "#{line.slice(/\A\#@\w+/)} seen in list"
|
174
160
|
@f.print line
|
@@ -293,7 +279,7 @@ module ReVIEW
|
|
293
279
|
Open3.popen3(cmd) do |_stdin, stdout, stderr|
|
294
280
|
out = stdout.readlines
|
295
281
|
if use_stderr
|
296
|
-
out.concat
|
282
|
+
out.concat(stderr.readlines)
|
297
283
|
else
|
298
284
|
err = stderr.readlines
|
299
285
|
end
|
@@ -357,6 +343,7 @@ module ReVIEW
|
|
357
343
|
private
|
358
344
|
|
359
345
|
def file_descripter(fname)
|
346
|
+
@leave_content = File.extname(fname) == '.re'
|
360
347
|
return @repository[fname] if @repository[fname]
|
361
348
|
|
362
349
|
@repository[fname] = git?(fname) ? parse_git_blob(fname) : parse_file(fname)
|
@@ -374,7 +361,7 @@ module ReVIEW
|
|
374
361
|
end
|
375
362
|
|
376
363
|
def parse_file(fname)
|
377
|
-
File.open(fname, '
|
364
|
+
File.open(fname, 'rt:BOM|utf-8') do |f|
|
378
365
|
init_errorutils f
|
379
366
|
return _parse_file(f)
|
380
367
|
end
|
@@ -416,14 +403,14 @@ module ReVIEW
|
|
416
403
|
error "begin x2: #{key}"
|
417
404
|
end
|
418
405
|
(repo[type] ||= {})[spec] = curr[key] = []
|
419
|
-
opened.push
|
406
|
+
opened.push([type, spec])
|
420
407
|
|
421
408
|
when %r{(?:\A\#@|\#@@)([a-z]+)/(\w+)\}}
|
422
409
|
type = check_type($1)
|
423
410
|
spec = check_spec($2)
|
424
411
|
curr.delete("#{type}/#{spec}") or
|
425
412
|
error "end before begin: #{type}/#{spec}"
|
426
|
-
opened.delete
|
413
|
+
opened.delete("#{type}/#{spec}")
|
427
414
|
|
428
415
|
when /(?:\A\#@|\#@@)\}/
|
429
416
|
type, spec = opened.last
|
@@ -436,17 +423,17 @@ module ReVIEW
|
|
436
423
|
|
437
424
|
when /\A\#@-/ # does not increment line number.
|
438
425
|
line = canonical($')
|
439
|
-
curr.each_value { |list| list.push
|
426
|
+
curr.each_value { |list| list.push(Line.new(nil, line)) }
|
440
427
|
|
441
428
|
else
|
442
429
|
next if yacchack and line.strip == ';'
|
443
430
|
line = canonical(line)
|
444
|
-
curr.each_value { |list| list.push
|
431
|
+
curr.each_value { |list| list.push(Line.new(lineno, line)) }
|
445
432
|
lineno += 1
|
446
433
|
end
|
447
434
|
end
|
448
435
|
if curr.size > 1
|
449
|
-
curr.delete
|
436
|
+
curr.delete('WHOLE')
|
450
437
|
curr.each { |range, lines| @logger.warn "#{filename}: unclosed range: #{range} (begin @#{lines.first.number})" }
|
451
438
|
raise ApplicationError, 'ERROR'
|
452
439
|
end
|
@@ -455,6 +442,10 @@ module ReVIEW
|
|
455
442
|
end
|
456
443
|
|
457
444
|
def canonical(line)
|
445
|
+
if @leave_content
|
446
|
+
return line
|
447
|
+
end
|
448
|
+
|
458
449
|
tabwidth = @config['tabwidth'] || 8
|
459
450
|
if tabwidth > 0
|
460
451
|
detab(line, tabwidth).rstrip + "\n"
|