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
data/lib/review/catalog.rb
CHANGED
@@ -3,8 +3,8 @@ require 'yaml'
|
|
3
3
|
module ReVIEW
|
4
4
|
class Catalog
|
5
5
|
def initialize(file)
|
6
|
-
if file.respond_to?
|
7
|
-
@yaml = YAML.
|
6
|
+
if file.respond_to?(:read)
|
7
|
+
@yaml = YAML.safe_load(file.read, [Date])
|
8
8
|
else ## as Object
|
9
9
|
@yaml = file
|
10
10
|
end
|
@@ -12,12 +12,11 @@ module ReVIEW
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def predef
|
15
|
-
|
16
|
-
@yaml['PREDEF'].join("\n")
|
15
|
+
@yaml['PREDEF'] || []
|
17
16
|
end
|
18
17
|
|
19
18
|
def chaps
|
20
|
-
return
|
19
|
+
return [] unless @yaml['CHAPS']
|
21
20
|
|
22
21
|
@yaml['CHAPS'].map do |entry|
|
23
22
|
if entry.is_a?(String)
|
@@ -25,11 +24,11 @@ module ReVIEW
|
|
25
24
|
elsif entry.is_a?(Hash)
|
26
25
|
entry.values # chaps in a part
|
27
26
|
end
|
28
|
-
end.flatten
|
27
|
+
end.flatten
|
29
28
|
end
|
30
29
|
|
31
30
|
def parts
|
32
|
-
return
|
31
|
+
return [] unless @yaml['CHAPS']
|
33
32
|
|
34
33
|
part_list = @yaml['CHAPS'].map do |entry|
|
35
34
|
if entry.is_a?(Hash)
|
@@ -37,7 +36,7 @@ module ReVIEW
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
part_list.flatten.compact
|
39
|
+
part_list.flatten.compact
|
41
40
|
end
|
42
41
|
|
43
42
|
def replace_part(old_name, new_name)
|
@@ -50,18 +49,16 @@ module ReVIEW
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def parts_with_chaps
|
53
|
-
return
|
52
|
+
return [] unless @yaml['CHAPS']
|
54
53
|
@yaml['CHAPS'].flatten.compact
|
55
54
|
end
|
56
55
|
|
57
56
|
def appendix
|
58
|
-
|
59
|
-
@yaml['APPENDIX'].join("\n")
|
57
|
+
@yaml['APPENDIX'] || []
|
60
58
|
end
|
61
59
|
|
62
60
|
def postdef
|
63
|
-
|
64
|
-
@yaml['POSTDEF'].join("\n")
|
61
|
+
@yaml['POSTDEF'] || []
|
65
62
|
end
|
66
63
|
|
67
64
|
def to_s
|
@@ -71,7 +68,7 @@ module ReVIEW
|
|
71
68
|
def validate!(config, basedir)
|
72
69
|
filenames = []
|
73
70
|
if predef.present?
|
74
|
-
filenames.concat(predef
|
71
|
+
filenames.concat(predef)
|
75
72
|
end
|
76
73
|
parts_with_chaps.each do |chap|
|
77
74
|
if chap.is_a?(Hash)
|
@@ -86,10 +83,10 @@ module ReVIEW
|
|
86
83
|
end
|
87
84
|
end
|
88
85
|
if appendix.present?
|
89
|
-
filenames.concat(appendix
|
86
|
+
filenames.concat(appendix)
|
90
87
|
end
|
91
88
|
if postdef.present?
|
92
|
-
filenames.concat(postdef
|
89
|
+
filenames.concat(postdef)
|
93
90
|
end
|
94
91
|
filenames.each do |filename|
|
95
92
|
refile = File.join(basedir, config['contentdir'], filename)
|
data/lib/review/compiler.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2009-
|
1
|
+
# Copyright (c) 2009-2020 Minero Aoki, Kenshi Muto
|
2
2
|
# Copyright (c) 2002-2007 Minero Aoki
|
3
3
|
#
|
4
4
|
# This program is free software.
|
@@ -9,39 +9,31 @@
|
|
9
9
|
require 'review/extentions'
|
10
10
|
require 'review/preprocessor'
|
11
11
|
require 'review/exception'
|
12
|
+
require 'review/location'
|
12
13
|
require 'strscan'
|
13
14
|
|
14
15
|
module ReVIEW
|
15
|
-
class Location
|
16
|
-
def initialize(filename, f)
|
17
|
-
@filename = filename
|
18
|
-
@f = f
|
19
|
-
end
|
20
|
-
|
21
|
-
attr_reader :filename
|
22
|
-
|
23
|
-
def lineno
|
24
|
-
@f.lineno
|
25
|
-
end
|
26
|
-
|
27
|
-
def string
|
28
|
-
begin
|
29
|
-
"#{@filename}:#{@f.lineno}"
|
30
|
-
rescue
|
31
|
-
"#{@filename}:nil"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
alias_method :to_s, :string
|
36
|
-
end
|
37
|
-
|
38
16
|
class Compiler
|
39
17
|
def initialize(strategy)
|
40
18
|
@strategy = strategy
|
19
|
+
|
20
|
+
## commands which do not parse block lines in compiler
|
21
|
+
@non_parsed_commands = %i[embed texequation graph]
|
22
|
+
|
23
|
+
## to decide escaping/non-escaping for text
|
24
|
+
@command_name_stack = []
|
41
25
|
end
|
42
26
|
|
43
27
|
attr_reader :strategy
|
44
28
|
|
29
|
+
def non_escaped_commands
|
30
|
+
if @strategy.highlight?
|
31
|
+
%i[list emlist listnum emlistnum cmd]
|
32
|
+
else
|
33
|
+
[]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
45
37
|
def compile(chap)
|
46
38
|
@chapter = chap
|
47
39
|
do_compile
|
@@ -88,11 +80,11 @@ module ReVIEW
|
|
88
80
|
SYNTAX = {}
|
89
81
|
|
90
82
|
def self.defblock(name, argc, optional = false, &block)
|
91
|
-
defsyntax
|
83
|
+
defsyntax(name, (optional ? :optional : :block), argc, &block)
|
92
84
|
end
|
93
85
|
|
94
86
|
def self.defsingle(name, argc, &block)
|
95
|
-
defsyntax
|
87
|
+
defsyntax(name, :line, argc, &block)
|
96
88
|
end
|
97
89
|
|
98
90
|
def self.defsyntax(name, type, argc, &block)
|
@@ -131,7 +123,7 @@ module ReVIEW
|
|
131
123
|
defblock :emlist, 0..2
|
132
124
|
defblock :cmd, 0..1
|
133
125
|
defblock :table, 0..2
|
134
|
-
defblock :imgtable, 0..
|
126
|
+
defblock :imgtable, 0..3
|
135
127
|
defblock :emtable, 0..1
|
136
128
|
defblock :quote, 0
|
137
129
|
defblock :image, 2..3, true
|
@@ -239,32 +231,39 @@ module ReVIEW
|
|
239
231
|
|
240
232
|
def do_compile
|
241
233
|
f = LineInput.new(StringIO.new(@chapter.content))
|
242
|
-
@strategy.bind
|
234
|
+
@strategy.bind(self, @chapter, Location.new(@chapter.basename, f))
|
235
|
+
|
243
236
|
tagged_section_init
|
244
237
|
while f.next?
|
245
238
|
case f.peek
|
246
239
|
when /\A\#@/
|
247
240
|
f.gets # Nothing to do
|
248
241
|
when /\A=+[\[\s\{]/
|
249
|
-
compile_headline
|
242
|
+
compile_headline(f.gets)
|
250
243
|
when /\A\s+\*/
|
251
|
-
compile_ulist
|
244
|
+
compile_ulist(f)
|
252
245
|
when /\A\s+\d+\./
|
253
|
-
compile_olist
|
246
|
+
compile_olist(f)
|
247
|
+
when /\A\s+:\s/
|
248
|
+
compile_dlist(f)
|
254
249
|
when /\A\s*:\s/
|
255
|
-
|
250
|
+
warn 'Definition list starting with `:` is deprecated. It should start with ` : `.'
|
251
|
+
compile_dlist(f)
|
256
252
|
when %r{\A//\}}
|
257
253
|
f.gets
|
258
254
|
error 'block end seen but not opened'
|
259
255
|
when %r{\A//[a-z]+}
|
256
|
+
# @command_name_stack.push(name) ## <- move into read_command() to use name
|
260
257
|
name, args, lines = read_command(f)
|
261
258
|
syntax = syntax_descriptor(name)
|
262
259
|
unless syntax
|
263
260
|
error "unknown command: //#{name}"
|
264
|
-
compile_unknown_command
|
261
|
+
compile_unknown_command(args, lines)
|
262
|
+
@command_name_stack.pop
|
265
263
|
next
|
266
264
|
end
|
267
|
-
compile_command
|
265
|
+
compile_command(syntax, args, lines)
|
266
|
+
@command_name_stack.pop
|
268
267
|
when %r{\A//}
|
269
268
|
line = f.gets
|
270
269
|
warn "`//' seen but is not valid command: #{line.strip.inspect}"
|
@@ -277,7 +276,7 @@ module ReVIEW
|
|
277
276
|
f.gets
|
278
277
|
next
|
279
278
|
end
|
280
|
-
compile_paragraph
|
279
|
+
compile_paragraph(f)
|
281
280
|
end
|
282
281
|
end
|
283
282
|
close_all_tagged_section
|
@@ -318,7 +317,7 @@ module ReVIEW
|
|
318
317
|
end
|
319
318
|
@headline_indexs[index] += 1
|
320
319
|
close_current_tagged_section(level)
|
321
|
-
@strategy.headline
|
320
|
+
@strategy.headline(level, label, caption)
|
322
321
|
end
|
323
322
|
end
|
324
323
|
|
@@ -329,7 +328,7 @@ module ReVIEW
|
|
329
328
|
end
|
330
329
|
|
331
330
|
def headline(level, label, caption)
|
332
|
-
@strategy.headline
|
331
|
+
@strategy.headline(level, label, caption)
|
333
332
|
end
|
334
333
|
|
335
334
|
def tagged_section_init
|
@@ -340,17 +339,17 @@ module ReVIEW
|
|
340
339
|
mid = "#{tag}_begin"
|
341
340
|
unless @strategy.respond_to?(mid)
|
342
341
|
error "strategy does not support tagged section: #{tag}"
|
343
|
-
headline
|
342
|
+
headline(level, label, caption)
|
344
343
|
return
|
345
344
|
end
|
346
|
-
@tagged_section.push
|
347
|
-
@strategy.__send__
|
345
|
+
@tagged_section.push([tag, level])
|
346
|
+
@strategy.__send__(mid, level, label, caption)
|
348
347
|
end
|
349
348
|
|
350
349
|
def close_tagged_section(tag, level)
|
351
350
|
mid = "#{tag}_end"
|
352
351
|
if @strategy.respond_to?(mid)
|
353
|
-
@strategy.__send__
|
352
|
+
@strategy.__send__(mid, level)
|
354
353
|
else
|
355
354
|
error "strategy does not support block op: #{mid}"
|
356
355
|
end
|
@@ -369,7 +368,7 @@ module ReVIEW
|
|
369
368
|
|
370
369
|
buf = [text(line.sub(/\*+/, '').strip)]
|
371
370
|
f.while_match(/\A\s+(?!\*)\S/) do |cont|
|
372
|
-
buf.push
|
371
|
+
buf.push(text(cont.strip))
|
373
372
|
end
|
374
373
|
|
375
374
|
line =~ /\A\s+(\*+)/
|
@@ -377,16 +376,15 @@ module ReVIEW
|
|
377
376
|
if level == current_level
|
378
377
|
@strategy.ul_item_end
|
379
378
|
# body
|
380
|
-
@strategy.ul_item_begin
|
379
|
+
@strategy.ul_item_begin(buf)
|
381
380
|
elsif level < current_level # down
|
382
381
|
level_diff = current_level - level
|
383
|
-
|
384
|
-
|
385
|
-
@strategy.ul_begin { i }
|
386
|
-
@strategy.ul_item_begin []
|
382
|
+
if level_diff != 1
|
383
|
+
error 'too many *.'
|
387
384
|
end
|
385
|
+
level = current_level
|
388
386
|
@strategy.ul_begin { level }
|
389
|
-
@strategy.ul_item_begin
|
387
|
+
@strategy.ul_item_begin(buf)
|
390
388
|
elsif level > current_level # up
|
391
389
|
level_diff = level - current_level
|
392
390
|
level = current_level
|
@@ -396,7 +394,7 @@ module ReVIEW
|
|
396
394
|
end
|
397
395
|
@strategy.ul_item_end
|
398
396
|
# body
|
399
|
-
@strategy.ul_item_begin
|
397
|
+
@strategy.ul_item_begin(buf)
|
400
398
|
end
|
401
399
|
end
|
402
400
|
|
@@ -414,9 +412,9 @@ module ReVIEW
|
|
414
412
|
num = line.match(/(\d+)\./)[1]
|
415
413
|
buf = [text(line.sub(/\d+\./, '').strip)]
|
416
414
|
f.while_match(/\A\s+(?!\d+\.)\S/) do |cont|
|
417
|
-
buf.push
|
415
|
+
buf.push(text(cont.strip))
|
418
416
|
end
|
419
|
-
@strategy.ol_item
|
417
|
+
@strategy.ol_item(buf, num)
|
420
418
|
end
|
421
419
|
@strategy.ol_end
|
422
420
|
end
|
@@ -424,7 +422,10 @@ module ReVIEW
|
|
424
422
|
def compile_dlist(f)
|
425
423
|
@strategy.dl_begin
|
426
424
|
while /\A\s*:/ =~ f.peek
|
427
|
-
|
425
|
+
# defer compile_inline to handle footnotes
|
426
|
+
@strategy.doc_status[:dt] = true
|
427
|
+
@strategy.dt(text(f.gets.sub(/\A\s*:/, '').strip))
|
428
|
+
@strategy.doc_status[:dt] = nil
|
428
429
|
desc = f.break(/\A(\S|\s*:|\s+\d+\.\s|\s+\*\s)/).map { |line| text(line.strip) }
|
429
430
|
@strategy.dd(desc)
|
430
431
|
f.skip_blank_lines
|
@@ -437,15 +438,16 @@ module ReVIEW
|
|
437
438
|
buf = []
|
438
439
|
f.until_match(%r{\A//|\A\#@}) do |line|
|
439
440
|
break if line.strip.empty?
|
440
|
-
buf.push
|
441
|
+
buf.push(text(line.sub(/^(\t+)\s*/) { |m| '<!ESCAPETAB!>' * m.size }.strip.gsub('<!ESCAPETAB!>', "\t")))
|
441
442
|
end
|
442
|
-
@strategy.paragraph
|
443
|
+
@strategy.paragraph(buf)
|
443
444
|
end
|
444
445
|
|
445
446
|
def read_command(f)
|
446
447
|
line = f.gets
|
447
448
|
name = line.slice(/[a-z]+/).to_sym
|
448
|
-
ignore_inline = (name
|
449
|
+
ignore_inline = @non_parsed_commands.include?(name)
|
450
|
+
@command_name_stack.push(name)
|
449
451
|
args = parse_args(line.sub(%r{\A//[a-z]+}, '').rstrip.chomp('{'), name)
|
450
452
|
@strategy.doc_status[name] = true
|
451
453
|
lines = block_open?(line) ? read_block(f, ignore_inline) : nil
|
@@ -462,12 +464,12 @@ module ReVIEW
|
|
462
464
|
buf = []
|
463
465
|
f.until_match(%r{\A//\}}) do |line|
|
464
466
|
if ignore_inline
|
465
|
-
buf.push
|
467
|
+
buf.push(line.chomp)
|
466
468
|
elsif line !~ /\A\#@/
|
467
|
-
buf.push
|
469
|
+
buf.push(text(line.rstrip, true))
|
468
470
|
end
|
469
471
|
end
|
470
|
-
unless
|
472
|
+
unless f.peek.to_s.start_with?('//}')
|
471
473
|
error "unexpected EOF (block begins at: #{head})"
|
472
474
|
return buf
|
473
475
|
end
|
@@ -496,27 +498,27 @@ module ReVIEW
|
|
496
498
|
def compile_command(syntax, args, lines)
|
497
499
|
unless @strategy.respond_to?(syntax.name)
|
498
500
|
error "strategy does not support command: //#{syntax.name}"
|
499
|
-
compile_unknown_command
|
501
|
+
compile_unknown_command(args, lines)
|
500
502
|
return
|
501
503
|
end
|
502
504
|
begin
|
503
|
-
syntax.check_args
|
504
|
-
rescue CompileError =>
|
505
|
-
error
|
505
|
+
syntax.check_args(args)
|
506
|
+
rescue CompileError => e
|
507
|
+
error e.message
|
506
508
|
args = ['(NoArgument)'] * syntax.min_argc
|
507
509
|
end
|
508
510
|
if syntax.block_allowed?
|
509
|
-
compile_block
|
511
|
+
compile_block(syntax, args, lines)
|
510
512
|
else
|
511
513
|
if lines
|
512
514
|
error "block is not allowed for command //#{syntax.name}; ignore"
|
513
515
|
end
|
514
|
-
compile_single
|
516
|
+
compile_single(syntax, args)
|
515
517
|
end
|
516
518
|
end
|
517
519
|
|
518
520
|
def compile_unknown_command(args, lines)
|
519
|
-
@strategy.unknown_command
|
521
|
+
@strategy.unknown_command(args, lines)
|
520
522
|
end
|
521
523
|
|
522
524
|
def compile_block(syntax, args, lines)
|
@@ -550,7 +552,12 @@ module ReVIEW
|
|
550
552
|
str.gsub("\x01", '@').gsub("\x02", '\\').gsub("\x03", '{').gsub("\x04", '}')
|
551
553
|
end
|
552
554
|
|
553
|
-
def
|
555
|
+
def in_non_escaped_command?
|
556
|
+
current_command = @command_name_stack.last
|
557
|
+
current_command && non_escaped_commands.include?(current_command)
|
558
|
+
end
|
559
|
+
|
560
|
+
def text(str, block_mode = false)
|
554
561
|
return '' if str.empty?
|
555
562
|
words = replace_fence(str).split(/(@<\w+>\{(?:[^\}\\]|\\.)*?\})/, -1)
|
556
563
|
words.each do |w|
|
@@ -558,14 +565,19 @@ module ReVIEW
|
|
558
565
|
error "`@<xxx>' seen but is not valid inline op: #{w}"
|
559
566
|
end
|
560
567
|
end
|
561
|
-
result =
|
568
|
+
result = ''
|
562
569
|
until words.empty?
|
570
|
+
if in_non_escaped_command? && block_mode
|
571
|
+
result << revert_replace_fence(words.shift)
|
572
|
+
else
|
573
|
+
result << @strategy.nofunc_text(revert_replace_fence(words.shift))
|
574
|
+
end
|
575
|
+
break if words.empty?
|
563
576
|
result << compile_inline(revert_replace_fence(words.shift.gsub(/\\\}/, '}').gsub(/\\\\/, '\\')))
|
564
|
-
result << @strategy.nofunc_text(revert_replace_fence(words.shift))
|
565
577
|
end
|
566
578
|
result
|
567
|
-
rescue =>
|
568
|
-
error
|
579
|
+
rescue => e
|
580
|
+
error e.message
|
569
581
|
end
|
570
582
|
public :text # called from strategy
|
571
583
|
|
@@ -578,8 +590,8 @@ module ReVIEW
|
|
578
590
|
raise "strategy does not support inline op: @<#{op}>"
|
579
591
|
end
|
580
592
|
@strategy.__send__("inline_#{op}", arg)
|
581
|
-
rescue =>
|
582
|
-
error
|
593
|
+
rescue => e
|
594
|
+
error e.message
|
583
595
|
@strategy.nofunc_text(str)
|
584
596
|
end
|
585
597
|
|
data/lib/review/configure.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2012-
|
2
|
+
# Copyright (c) 2012-2020 Masanori Kado, Masayoshi Takahashi, Kenshi Muto
|
3
3
|
#
|
4
4
|
# This program is free software.
|
5
5
|
# You can distribute or modify this program under the terms of
|
@@ -15,10 +15,10 @@ module ReVIEW
|
|
15
15
|
def self.values
|
16
16
|
conf = Configure[
|
17
17
|
# These parameters can be overridden by YAML file.
|
18
|
-
'bookname' => '
|
18
|
+
'bookname' => 'book', # it defines epub file name also
|
19
19
|
'booktitle' => 'Re:VIEW Sample Book',
|
20
20
|
'title' => nil,
|
21
|
-
'aut' =>
|
21
|
+
'aut' => ['anonymous'], # author
|
22
22
|
'prt' => nil, # printer(publisher)
|
23
23
|
'asn' => nil, # associated name
|
24
24
|
'ant' => nil, # bibliographic antecedent
|
@@ -32,7 +32,7 @@ module ReVIEW
|
|
32
32
|
'rights' => nil, # Copyright messages
|
33
33
|
'description' => nil, # Description
|
34
34
|
'urnid' => "urn:uid:#{SecureRandom.uuid}", # Identifier
|
35
|
-
'stylesheet' =>
|
35
|
+
'stylesheet' => [], # stylesheet file
|
36
36
|
'coverfile' => nil, # content file of body of cover page
|
37
37
|
'mytoc' => nil, # whether make own table of contents or not
|
38
38
|
'params' => '', # specify review2html parameters
|
@@ -65,6 +65,8 @@ module ReVIEW
|
|
65
65
|
'words_file' => nil,
|
66
66
|
'colophon_order' => %w[aut csl trl dsr ill cov edt pbl contact prt],
|
67
67
|
'externallink' => true,
|
68
|
+
'join_lines_by_lang' => nil, # experimental. default should be nil
|
69
|
+
'table_row_separator' => 'tabs',
|
68
70
|
# for IDGXML
|
69
71
|
'tableopt' => nil,
|
70
72
|
'listinfo' => nil,
|
@@ -73,22 +75,25 @@ module ReVIEW
|
|
73
75
|
'structuredxml' => nil,
|
74
76
|
'pt_to_mm_unit' => 0.3528, # DTP: 1pt = 0.3528mm, JIS: 1pt = 0.3514mm
|
75
77
|
# for LaTeX
|
76
|
-
'image_scale2width' => true,
|
77
78
|
'footnotetext' => nil,
|
78
79
|
'texcommand' => 'uplatex',
|
79
|
-
'texoptions' => '-interaction=nonstopmode -file-line-error',
|
80
|
+
'texoptions' => '-interaction=nonstopmode -file-line-error -halt-on-error',
|
80
81
|
'_texdocumentclass' => ['review-jsbook', ''],
|
82
|
+
'texstyle' => ['reviewmacro'],
|
81
83
|
'dvicommand' => 'dvipdfmx',
|
82
84
|
'dvioptions' => '-d 5 -z 9',
|
83
85
|
# for PDFMaker
|
84
86
|
'pdfmaker' => {
|
87
|
+
'image_scale2width' => true,
|
85
88
|
'makeindex' => nil, # Make index page
|
86
89
|
'makeindex_command' => 'mendex', # works only when makeindex is true
|
87
90
|
'makeindex_options' => '-f -r -I utf8',
|
88
91
|
'makeindex_sty' => nil,
|
89
92
|
'makeindex_dic' => nil,
|
90
93
|
'makeindex_mecab' => true,
|
91
|
-
'makeindex_mecab_opts' => '-Oyomi'
|
94
|
+
'makeindex_mecab_opts' => '-Oyomi',
|
95
|
+
'use_cover_nombre' => true,
|
96
|
+
'use_original_image_size' => nil
|
92
97
|
},
|
93
98
|
'imgmath_options' => {
|
94
99
|
'format' => 'png',
|
@@ -99,8 +104,14 @@ module ReVIEW
|
|
99
104
|
'preamble_file' => nil,
|
100
105
|
'fontsize' => 10,
|
101
106
|
'lineheight' => 10 * 1.2,
|
102
|
-
'pdfcrop_pixelize_cmd' => 'pdftocairo
|
107
|
+
'pdfcrop_pixelize_cmd' => 'pdftocairo -%t -r 90 -f %p -l %p -singlefile %i %O',
|
103
108
|
'dvipng_cmd' => 'dvipng -T tight -z 9 -p %p -l %p -o %o %i'
|
109
|
+
},
|
110
|
+
'caption_position' => {
|
111
|
+
'list' => 'top',
|
112
|
+
'image' => 'bottom',
|
113
|
+
'table' => 'top',
|
114
|
+
'equation' => 'top'
|
104
115
|
}
|
105
116
|
]
|
106
117
|
conf.maker = nil
|