review 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -4
- data/.travis.yml +1 -1
- data/NEWS.ja.md +97 -1
- data/NEWS.md +97 -1
- data/bin/review-catalog-converter +1 -1
- data/bin/review-check +5 -5
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +5 -5
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +7 -7
- data/bin/review-preproc +9 -9
- data/bin/review-validate +2 -2
- data/bin/review-vol +5 -5
- data/doc/config.yml.sample +14 -6
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +15 -5
- data/doc/format.md +30 -18
- data/doc/pdfmaker.ja.md +1 -1
- data/doc/pdfmaker.md +1 -1
- data/lib/review/book.rb +1 -1
- data/lib/review/book/base.rb +23 -63
- data/lib/review/book/chapter.rb +18 -3
- data/lib/review/book/compilable.rb +5 -0
- data/lib/review/book/index.rb +26 -65
- data/lib/review/book/index/item.rb +40 -0
- data/lib/review/book/part.rb +22 -2
- data/lib/review/builder.rb +60 -40
- data/lib/review/catalog.rb +12 -15
- data/lib/review/compiler.rb +68 -36
- data/lib/review/configure.rb +10 -7
- data/lib/review/epubmaker.rb +5 -2
- data/lib/review/htmlbuilder.rb +24 -71
- data/lib/review/htmlutils.rb +2 -3
- data/lib/review/i18n.rb +2 -2
- data/lib/review/idgxmlbuilder.rb +101 -55
- data/lib/review/idgxmlmaker.rb +184 -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 +110 -26
- data/lib/review/latexbuilder.rb +76 -54
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +4 -8
- data/lib/review/makerhelper.rb +6 -4
- data/lib/review/markdownbuilder.rb +25 -38
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +15 -15
- data/lib/review/plaintextbuilder.rb +67 -76
- data/lib/review/preprocessor.rb +13 -13
- data/lib/review/rstbuilder.rb +31 -31
- data/lib/review/textmaker.rb +13 -3
- data/lib/review/textutils.rb +77 -2
- data/lib/review/tocparser.rb +17 -17
- data/lib/review/tocprinter.rb +8 -8
- data/lib/review/topbuilder.rb +76 -57
- data/lib/review/update.rb +16 -16
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +2 -2
- data/lib/review/yamlloader.rb +3 -0
- data/review.gemspec +4 -3
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +153 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/lib/tasks/review.rake +20 -9
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/ch03.re +3 -6
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/lib/tasks/review.rake +7 -7
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/latex/config.erb +6 -0
- data/templates/latex/layout.tex.erb +1 -0
- data/templates/latex/review-jlreq/review-base.sty +93 -31
- data/templates/latex/review-jlreq/review-jlreq.cls +6 -0
- data/templates/latex/review-jlreq/review-style.sty +3 -0
- data/templates/latex/review-jsbook/README.md +39 -0
- data/templates/latex/review-jsbook/review-base.sty +65 -10
- data/templates/latex/review-jsbook/review-jsbook.cls +4 -0
- data/templates/latex/review-jsbook/review-style.sty +4 -1
- data/test/assets/test_template.tex +11 -3
- data/test/assets/test_template_backmatter.tex +11 -3
- data/test/test_book.rb +65 -19
- data/test/test_catalog.rb +18 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epubmaker_cmd.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/test_htmlbuilder.rb +144 -55
- data/test/test_i18n.rb +25 -25
- data/test/test_idgxmlbuilder.rb +60 -18
- data/test/test_image_finder.rb +6 -6
- data/test/test_latexbuilder.rb +128 -24
- data/test/test_latexbuilder_v2.rb +23 -23
- data/test/test_logger.rb +14 -1
- data/test/test_makerhelper.rb +3 -3
- data/test/test_markdownbuilder.rb +45 -4
- data/test/test_md2inaobuilder.rb +12 -2
- data/test/test_pdfmaker.rb +1 -1
- data/test/test_pdfmaker_cmd.rb +1 -1
- data/test/test_plaintextbuilder.rb +31 -6
- data/test/test_rstbuilder.rb +33 -4
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +35 -7
- data/test/test_update.rb +17 -8
- data/test/test_yamlloader.rb +13 -0
- metadata +26 -2
data/lib/review/lineinput.rb
CHANGED
data/lib/review/logger.rb
CHANGED
|
@@ -2,18 +2,14 @@ require 'logger'
|
|
|
2
2
|
|
|
3
3
|
module ReVIEW
|
|
4
4
|
class Logger < ::Logger
|
|
5
|
-
def initialize(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
self.formatter = ->(severity, _datetime, _progname, msg) { "#{severity}: #{msg}\n" }
|
|
9
|
-
else
|
|
10
|
-
super
|
|
11
|
-
end
|
|
5
|
+
def initialize(io = STDERR, progname: '--')
|
|
6
|
+
super(io, progname: progname)
|
|
7
|
+
self.formatter = ->(severity, _datetime, name, msg) { "#{severity} #{name}: #{msg}\n" }
|
|
12
8
|
end
|
|
13
9
|
end
|
|
14
10
|
|
|
15
11
|
def self.logger
|
|
16
|
-
@logger ||= ReVIEW::Logger.new
|
|
12
|
+
@logger ||= ReVIEW::Logger.new(STDERR, progname: File.basename($PROGRAM_NAME, '.*'))
|
|
17
13
|
end
|
|
18
14
|
|
|
19
15
|
def self.logger=(logger)
|
data/lib/review/makerhelper.rb
CHANGED
|
@@ -55,7 +55,7 @@ module ReVIEW
|
|
|
55
55
|
exts = options[:exts] || %w[png gif jpg jpeg svg pdf eps ai tif psd]
|
|
56
56
|
exts_str = exts.join('|')
|
|
57
57
|
if !is_converted && fname =~ /\.(#{exts_str})$/i
|
|
58
|
-
FileUtils.cp
|
|
58
|
+
FileUtils.cp("#{from_dir}/#{fname}", to_dir)
|
|
59
59
|
image_files << "#{from_dir}/#{fname}"
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -66,8 +66,8 @@ module ReVIEW
|
|
|
66
66
|
end
|
|
67
67
|
module_function :copy_images_to_dir
|
|
68
68
|
|
|
69
|
-
def cleanup_mathimg
|
|
70
|
-
math_dir = "./#{@config['imagedir']}
|
|
69
|
+
def cleanup_mathimg(path = '_review_math')
|
|
70
|
+
math_dir = "./#{@config['imagedir']}/#{path}"
|
|
71
71
|
if @config['imgmath'] && Dir.exist?(math_dir)
|
|
72
72
|
FileUtils.rm_rf(math_dir)
|
|
73
73
|
end
|
|
@@ -141,6 +141,7 @@ EOB
|
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
def make_math_images_pdfcrop(dir, tex_path, math_dir)
|
|
144
|
+
# rubocop:disable Metrics/BlockLength
|
|
144
145
|
Dir.chdir(dir) do
|
|
145
146
|
dvi_path = '__IMGMATH__.dvi'
|
|
146
147
|
pdf_path = '__IMGMATH__.pdf'
|
|
@@ -155,7 +156,6 @@ EOB
|
|
|
155
156
|
raise CompileError
|
|
156
157
|
end
|
|
157
158
|
end
|
|
158
|
-
|
|
159
159
|
args = @config['imgmath_options']['pdfcrop_cmd'].shellsplit
|
|
160
160
|
args.map! do |m|
|
|
161
161
|
m.sub('%i', pdf_path).
|
|
@@ -201,6 +201,7 @@ EOB
|
|
|
201
201
|
args = @config['imgmath_options']['pdfcrop_pixelize_cmd'].shellsplit
|
|
202
202
|
args.map! do |m|
|
|
203
203
|
m.sub('%i', pdf_path2).
|
|
204
|
+
sub('%t', @config['imgmath_options']['format']).
|
|
204
205
|
sub('%o', File.join(math_dir, "_gen_#{key}.#{@config['imgmath_options']['format']}")).
|
|
205
206
|
sub('%O', File.join(math_dir, "_gen_#{key}")).
|
|
206
207
|
sub('%p', page.to_s)
|
|
@@ -213,6 +214,7 @@ EOB
|
|
|
213
214
|
end
|
|
214
215
|
end
|
|
215
216
|
end
|
|
217
|
+
# rubocop:enable Metrics/BlockLength
|
|
216
218
|
end
|
|
217
219
|
|
|
218
220
|
def make_math_images_dvipng(dir, tex_path, math_dir)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Copyright (c) 2013-2019 KADO Masanori, Masayoshi Takahashi, Kenshi Muto
|
|
2
|
+
#
|
|
1
3
|
# This program is free software.
|
|
2
4
|
# You can distribute or modify this program under the terms of
|
|
3
5
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
|
@@ -50,11 +52,11 @@ module ReVIEW
|
|
|
50
52
|
|
|
51
53
|
def paragraph(lines)
|
|
52
54
|
if @noindent
|
|
53
|
-
puts %Q(<p class="noindent">#{lines
|
|
55
|
+
puts %Q(<p class="noindent">#{join_lines_to_paragraph(lines)}</p>)
|
|
54
56
|
puts "\n"
|
|
55
57
|
@noindent = nil
|
|
56
58
|
else
|
|
57
|
-
puts lines
|
|
59
|
+
puts join_lines_to_paragraph(lines)
|
|
58
60
|
puts "\n"
|
|
59
61
|
end
|
|
60
62
|
end
|
|
@@ -63,24 +65,26 @@ module ReVIEW
|
|
|
63
65
|
@noindent = true
|
|
64
66
|
end
|
|
65
67
|
|
|
66
|
-
def list_header(id, caption,
|
|
68
|
+
def list_header(id, caption, _lang)
|
|
67
69
|
if get_chap.nil?
|
|
68
70
|
print %Q(リスト#{@chapter.list(id).number} #{compile_inline(caption)}\n\n)
|
|
69
71
|
else
|
|
70
72
|
print %Q(リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}\n\n)
|
|
71
73
|
end
|
|
72
|
-
lang ||= ''
|
|
73
|
-
puts "```#{lang}"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
def list_body(_id, lines,
|
|
76
|
+
def list_body(_id, lines, lang)
|
|
77
|
+
lang ||= ''
|
|
78
|
+
puts "```#{lang}"
|
|
77
79
|
lines.each do |line|
|
|
78
80
|
puts detab(line)
|
|
79
81
|
end
|
|
80
82
|
puts '```'
|
|
81
83
|
end
|
|
82
84
|
|
|
83
|
-
def listnum_body(lines,
|
|
85
|
+
def listnum_body(lines, lang)
|
|
86
|
+
lang ||= ''
|
|
87
|
+
puts "```#{lang}"
|
|
84
88
|
lines.each_with_index do |line, i|
|
|
85
89
|
puts((i + 1).to_s.rjust(2) + ": #{detab(line)}")
|
|
86
90
|
end
|
|
@@ -93,7 +97,7 @@ module ReVIEW
|
|
|
93
97
|
end
|
|
94
98
|
|
|
95
99
|
def ul_item_begin(lines)
|
|
96
|
-
puts ' ' * (@ul_indent - 1) + '* ' + lines
|
|
100
|
+
puts ' ' * (@ul_indent - 1) + '* ' + join_lines_to_paragraph(lines)
|
|
97
101
|
end
|
|
98
102
|
|
|
99
103
|
def ul_item_end
|
|
@@ -109,7 +113,7 @@ module ReVIEW
|
|
|
109
113
|
end
|
|
110
114
|
|
|
111
115
|
def ol_item(lines, num)
|
|
112
|
-
puts "#{num}. #{lines
|
|
116
|
+
puts "#{num}. #{join_lines_to_paragraph(lines)}"
|
|
113
117
|
end
|
|
114
118
|
|
|
115
119
|
def ol_end
|
|
@@ -125,7 +129,7 @@ module ReVIEW
|
|
|
125
129
|
end
|
|
126
130
|
|
|
127
131
|
def dd(lines)
|
|
128
|
-
puts "<dd>#{lines
|
|
132
|
+
puts "<dd>#{join_lines_to_paragraph(lines)}</dd>"
|
|
129
133
|
end
|
|
130
134
|
|
|
131
135
|
def dl_end
|
|
@@ -134,9 +138,9 @@ module ReVIEW
|
|
|
134
138
|
|
|
135
139
|
def emlist(lines, caption = nil, lang = nil)
|
|
136
140
|
blank
|
|
137
|
-
if caption
|
|
141
|
+
if caption.present?
|
|
138
142
|
puts caption
|
|
139
|
-
|
|
143
|
+
blank
|
|
140
144
|
end
|
|
141
145
|
lang ||= ''
|
|
142
146
|
puts "```#{lang}"
|
|
@@ -236,7 +240,11 @@ module ReVIEW
|
|
|
236
240
|
'jpg'
|
|
237
241
|
end
|
|
238
242
|
|
|
239
|
-
def cmd(lines)
|
|
243
|
+
def cmd(lines, caption = nil)
|
|
244
|
+
if caption.present?
|
|
245
|
+
puts caption
|
|
246
|
+
blank
|
|
247
|
+
end
|
|
240
248
|
puts '```shell-session'
|
|
241
249
|
lines.each do |line|
|
|
242
250
|
puts detab(line)
|
|
@@ -244,32 +252,12 @@ module ReVIEW
|
|
|
244
252
|
puts '```'
|
|
245
253
|
end
|
|
246
254
|
|
|
247
|
-
def
|
|
248
|
-
rows = []
|
|
249
|
-
sepidx = nil
|
|
250
|
-
lines.each_with_index do |line, idx|
|
|
251
|
-
if /\A[\=\-]{12}/ =~ line
|
|
252
|
-
# just ignore
|
|
253
|
-
# error "too many table separator" if sepidx
|
|
254
|
-
sepidx ||= idx
|
|
255
|
-
next
|
|
256
|
-
end
|
|
257
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
|
258
|
-
end
|
|
259
|
-
rows = adjust_n_cols(rows)
|
|
260
|
-
error 'no rows in the table' if rows.empty?
|
|
261
|
-
|
|
262
|
-
begin
|
|
263
|
-
table_header id, caption unless caption.nil?
|
|
264
|
-
rescue KeyError
|
|
265
|
-
error "no such table: #{id}"
|
|
266
|
-
end
|
|
267
|
-
table_begin rows.first.size
|
|
255
|
+
def table_rows(sepidx, rows)
|
|
268
256
|
if sepidx
|
|
269
257
|
sepidx.times do
|
|
270
258
|
tr(rows.shift.map { |s| th(s) })
|
|
271
259
|
end
|
|
272
|
-
table_border
|
|
260
|
+
table_border(rows.first.size)
|
|
273
261
|
rows.each do |cols|
|
|
274
262
|
tr(cols.map { |s| td(s) })
|
|
275
263
|
end
|
|
@@ -279,7 +267,6 @@ module ReVIEW
|
|
|
279
267
|
tr([th(h)] + cs.map { |s| td(s) })
|
|
280
268
|
end
|
|
281
269
|
end
|
|
282
|
-
table_end
|
|
283
270
|
end
|
|
284
271
|
|
|
285
272
|
def table_header(id, caption)
|
|
@@ -355,7 +342,7 @@ module ReVIEW
|
|
|
355
342
|
return unless @book.config['draft']
|
|
356
343
|
lines ||= []
|
|
357
344
|
unless comment.blank?
|
|
358
|
-
lines.unshift
|
|
345
|
+
lines.unshift(comment)
|
|
359
346
|
end
|
|
360
347
|
str = lines.join('<br />')
|
|
361
348
|
puts %Q(<div class="red">#{escape(str)}</div>)
|
|
@@ -380,7 +367,7 @@ module ReVIEW
|
|
|
380
367
|
|
|
381
368
|
def flushright(lines)
|
|
382
369
|
puts %Q(<div class="flushright">)
|
|
383
|
-
puts lines.join
|
|
370
|
+
puts split_paragraph(lines).join("\n")
|
|
384
371
|
puts %Q(</div>)
|
|
385
372
|
end
|
|
386
373
|
end
|
|
@@ -7,13 +7,11 @@ require 'review/markdownbuilder'
|
|
|
7
7
|
module ReVIEW
|
|
8
8
|
class MD2INAOBuilder < MARKDOWNBuilder
|
|
9
9
|
def paragraph(lines)
|
|
10
|
-
puts ' ' + lines
|
|
10
|
+
puts ' ' + join_lines_to_paragraph(lines)
|
|
11
11
|
puts "\n"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def list_header(id, caption,
|
|
15
|
-
lang ||= ''
|
|
16
|
-
puts "```#{lang}"
|
|
14
|
+
def list_header(id, caption, _lang)
|
|
17
15
|
print %Q(●リスト#{@chapter.list(id).number}::#{compile_inline(caption)}\n\n)
|
|
18
16
|
end
|
|
19
17
|
|
|
@@ -35,7 +33,7 @@ module ReVIEW
|
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
def dd(lines)
|
|
38
|
-
puts "<dd>#{lines
|
|
36
|
+
puts "<dd>#{join_lines_to_paragraph(lines)}</dd>"
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
def dl_end
|
data/lib/review/pdfmaker.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2010-
|
|
1
|
+
# Copyright (c) 2010-2019 Kenshi Muto and Masayoshi Takahashi
|
|
2
2
|
#
|
|
3
3
|
# This program is free software.
|
|
4
4
|
# You can distribute or modify this program under the terms of
|
|
@@ -54,12 +54,12 @@ module ReVIEW
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def error(msg)
|
|
57
|
-
@logger.error
|
|
57
|
+
@logger.error msg
|
|
58
58
|
exit 1
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def warn(msg)
|
|
62
|
-
@logger.warn
|
|
62
|
+
@logger.warn msg
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def pdf_filepath
|
|
@@ -153,20 +153,20 @@ module ReVIEW
|
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
begin
|
|
156
|
-
generate_pdf
|
|
156
|
+
generate_pdf
|
|
157
157
|
rescue ApplicationError => e
|
|
158
158
|
raise if @config['debug']
|
|
159
159
|
error(e.message)
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
def make_input_files(book
|
|
163
|
+
def make_input_files(book)
|
|
164
164
|
input_files = Hash.new { |h, key| h[key] = '' }
|
|
165
165
|
book.parts.each do |part|
|
|
166
166
|
if part.name.present?
|
|
167
167
|
@config['use_part'] = true
|
|
168
168
|
if part.file?
|
|
169
|
-
output_chaps(part.name
|
|
169
|
+
output_chaps(part.name)
|
|
170
170
|
input_files['CHAPS'] << %Q(\\input{#{part.name}.tex}\n)
|
|
171
171
|
else
|
|
172
172
|
input_files['CHAPS'] << %Q(\\part{#{part.name}}\n)
|
|
@@ -175,7 +175,7 @@ module ReVIEW
|
|
|
175
175
|
|
|
176
176
|
part.chapters.each do |chap|
|
|
177
177
|
filename = File.basename(chap.path, '.*')
|
|
178
|
-
output_chaps(filename
|
|
178
|
+
output_chaps(filename)
|
|
179
179
|
input_files['PREDEF'] << "\\input{#{filename}.tex}\n" if chap.on_predef?
|
|
180
180
|
input_files['CHAPS'] << "\\input{#{filename}.tex}\n" if chap.on_chaps?
|
|
181
181
|
input_files['APPENDIX'] << "\\input{#{filename}.tex}\n" if chap.on_appendix?
|
|
@@ -189,7 +189,7 @@ module ReVIEW
|
|
|
189
189
|
def build_pdf
|
|
190
190
|
template = template_content
|
|
191
191
|
Dir.chdir(@path) do
|
|
192
|
-
File.open("./#{@mastertex}.tex", 'wb') { |f| f.write
|
|
192
|
+
File.open("./#{@mastertex}.tex", 'wb') { |f| f.write template }
|
|
193
193
|
|
|
194
194
|
call_hook('hook_beforetexcompile')
|
|
195
195
|
|
|
@@ -250,18 +250,18 @@ module ReVIEW
|
|
|
250
250
|
end
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
-
def generate_pdf
|
|
253
|
+
def generate_pdf
|
|
254
254
|
remove_old_file
|
|
255
255
|
erb_config
|
|
256
256
|
@path = build_path
|
|
257
257
|
begin
|
|
258
258
|
@compile_errors = nil
|
|
259
259
|
|
|
260
|
-
book = ReVIEW::Book.load(
|
|
260
|
+
book = ReVIEW::Book.load(@basedir)
|
|
261
261
|
book.config = @config
|
|
262
262
|
@converter = ReVIEW::Converter.new(book, ReVIEW::LATEXBuilder.new)
|
|
263
263
|
|
|
264
|
-
@input_files = make_input_files(book
|
|
264
|
+
@input_files = make_input_files(book)
|
|
265
265
|
|
|
266
266
|
check_compile_status(@config['ignore-errors'])
|
|
267
267
|
|
|
@@ -281,11 +281,11 @@ module ReVIEW
|
|
|
281
281
|
|
|
282
282
|
FileUtils.cp(File.join(@path, "#{@mastertex}.pdf"), pdf_filepath)
|
|
283
283
|
ensure
|
|
284
|
-
remove_entry_secure
|
|
284
|
+
remove_entry_secure(@path) unless @config['debug']
|
|
285
285
|
end
|
|
286
286
|
end
|
|
287
287
|
|
|
288
|
-
def output_chaps(filename
|
|
288
|
+
def output_chaps(filename)
|
|
289
289
|
@logger.info "compiling #{filename}.tex"
|
|
290
290
|
begin
|
|
291
291
|
@converter.convert(filename + '.re', File.join(@path, filename + '.tex'))
|
|
@@ -454,7 +454,7 @@ module ReVIEW
|
|
|
454
454
|
def erb_content(file)
|
|
455
455
|
@texcompiler = File.basename(@config['texcommand'], '.*')
|
|
456
456
|
erb = ReVIEW::Template.load(file, '-')
|
|
457
|
-
@logger.debug
|
|
457
|
+
@logger.debug("erb processes #{File.basename(file)}") if @config['debug']
|
|
458
458
|
erb.result(binding)
|
|
459
459
|
end
|
|
460
460
|
|
|
@@ -489,7 +489,7 @@ module ReVIEW
|
|
|
489
489
|
f.print erb_content(File.join(dirname, fname))
|
|
490
490
|
end
|
|
491
491
|
else
|
|
492
|
-
FileUtils.cp
|
|
492
|
+
FileUtils.cp(File.join(dirname, fname), copybase)
|
|
493
493
|
end
|
|
494
494
|
end
|
|
495
495
|
end
|
|
@@ -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,21 +137,30 @@ 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
|
+
list_header(id, caption, lang)
|
|
144
|
+
rescue KeyError
|
|
145
|
+
error "no such list: #{id}"
|
|
146
|
+
end
|
|
147
|
+
blank
|
|
148
|
+
list_body(id, lines, lang)
|
|
141
149
|
blank
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def list_header(id, caption, _lang)
|
|
142
153
|
if get_chap
|
|
143
154
|
puts %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
|
144
155
|
else
|
|
145
156
|
puts %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
|
146
157
|
end
|
|
147
|
-
blank
|
|
148
158
|
end
|
|
149
159
|
|
|
150
160
|
def list_body(_id, lines, _lang)
|
|
151
161
|
lines.each do |line|
|
|
152
162
|
puts detab(line)
|
|
153
163
|
end
|
|
154
|
-
blank
|
|
155
164
|
end
|
|
156
165
|
|
|
157
166
|
def base_block(_type, lines, caption = nil)
|
|
@@ -169,7 +178,7 @@ module ReVIEW
|
|
|
169
178
|
end
|
|
170
179
|
|
|
171
180
|
def emlist(lines, caption = nil, _lang = nil)
|
|
172
|
-
base_block
|
|
181
|
+
base_block('emlist', lines, caption)
|
|
173
182
|
end
|
|
174
183
|
|
|
175
184
|
def emlistnum(lines, caption = nil, _lang = nil)
|
|
@@ -181,19 +190,30 @@ module ReVIEW
|
|
|
181
190
|
blank
|
|
182
191
|
end
|
|
183
192
|
|
|
193
|
+
def listnum(lines, id, caption, lang = nil)
|
|
194
|
+
blank
|
|
195
|
+
begin
|
|
196
|
+
list_header(id, caption, lang)
|
|
197
|
+
rescue KeyError
|
|
198
|
+
error "no such list: #{id}"
|
|
199
|
+
end
|
|
200
|
+
blank
|
|
201
|
+
listnum_body(lines, lang)
|
|
202
|
+
blank
|
|
203
|
+
end
|
|
204
|
+
|
|
184
205
|
def listnum_body(lines, _lang)
|
|
185
206
|
lines.each_with_index do |line, i|
|
|
186
207
|
puts((i + 1).to_s.rjust(2) + ": #{line}")
|
|
187
208
|
end
|
|
188
|
-
blank
|
|
189
209
|
end
|
|
190
210
|
|
|
191
211
|
def cmd(lines, caption = nil)
|
|
192
|
-
base_block
|
|
212
|
+
base_block('cmd', lines, caption)
|
|
193
213
|
end
|
|
194
214
|
|
|
195
215
|
def quote(lines)
|
|
196
|
-
base_parablock
|
|
216
|
+
base_parablock('quote', lines, nil)
|
|
197
217
|
end
|
|
198
218
|
|
|
199
219
|
def image(_lines, id, caption, _metric = nil)
|
|
@@ -207,56 +227,27 @@ module ReVIEW
|
|
|
207
227
|
end
|
|
208
228
|
|
|
209
229
|
def texequation(lines, id = nil, caption = '')
|
|
230
|
+
blank
|
|
231
|
+
texequation_header(id, caption)
|
|
232
|
+
puts lines.join("\n")
|
|
233
|
+
blank
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def texequation_header(id, caption)
|
|
210
237
|
if id
|
|
211
|
-
blank
|
|
212
238
|
if get_chap
|
|
213
239
|
puts "#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
|
214
240
|
else
|
|
215
241
|
puts "#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
|
216
242
|
end
|
|
217
243
|
end
|
|
218
|
-
|
|
219
|
-
puts lines.join("\n")
|
|
220
|
-
blank
|
|
221
244
|
end
|
|
222
245
|
|
|
223
|
-
def table(lines, id = nil, caption = nil)
|
|
224
|
-
|
|
225
|
-
|
|
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
|
|
246
|
+
def table(lines, id = nil, caption = nil, noblank = nil)
|
|
247
|
+
unless noblank
|
|
248
|
+
blank
|
|
258
249
|
end
|
|
259
|
-
|
|
250
|
+
super(lines, id, caption)
|
|
260
251
|
end
|
|
261
252
|
|
|
262
253
|
def table_header(id, caption)
|
|
@@ -345,8 +336,8 @@ module ReVIEW
|
|
|
345
336
|
end
|
|
346
337
|
|
|
347
338
|
def bibpaper(lines, id, caption)
|
|
348
|
-
bibpaper_header
|
|
349
|
-
bibpaper_bibpaper
|
|
339
|
+
bibpaper_header(id, caption)
|
|
340
|
+
bibpaper_bibpaper(id, caption, lines) unless lines.empty?
|
|
350
341
|
end
|
|
351
342
|
|
|
352
343
|
def bibpaper_header(id, caption)
|
|
@@ -355,7 +346,7 @@ module ReVIEW
|
|
|
355
346
|
end
|
|
356
347
|
|
|
357
348
|
def bibpaper_bibpaper(_id, _caption, lines)
|
|
358
|
-
|
|
349
|
+
puts split_paragraph(lines).join("\n")
|
|
359
350
|
end
|
|
360
351
|
|
|
361
352
|
def inline_bib(id)
|
|
@@ -472,87 +463,87 @@ module ReVIEW
|
|
|
472
463
|
end
|
|
473
464
|
|
|
474
465
|
def flushright(lines)
|
|
475
|
-
base_parablock
|
|
466
|
+
base_parablock('flushright', lines, nil)
|
|
476
467
|
end
|
|
477
468
|
|
|
478
469
|
def centering(lines)
|
|
479
|
-
base_parablock
|
|
470
|
+
base_parablock('centering', lines, nil)
|
|
480
471
|
end
|
|
481
472
|
|
|
482
473
|
def note(lines, caption = nil)
|
|
483
|
-
base_parablock
|
|
474
|
+
base_parablock('note', lines, caption)
|
|
484
475
|
end
|
|
485
476
|
|
|
486
477
|
def memo(lines, caption = nil)
|
|
487
|
-
base_parablock
|
|
478
|
+
base_parablock('memo', lines, caption)
|
|
488
479
|
end
|
|
489
480
|
|
|
490
481
|
def tip(lines, caption = nil)
|
|
491
|
-
base_parablock
|
|
482
|
+
base_parablock('tip', lines, caption)
|
|
492
483
|
end
|
|
493
484
|
|
|
494
485
|
def info(lines, caption = nil)
|
|
495
|
-
base_parablock
|
|
486
|
+
base_parablock('info', lines, caption)
|
|
496
487
|
end
|
|
497
488
|
|
|
498
489
|
def planning(lines, caption = nil)
|
|
499
|
-
base_parablock
|
|
490
|
+
base_parablock('planning', lines, caption)
|
|
500
491
|
end
|
|
501
492
|
|
|
502
493
|
def best(lines, caption = nil)
|
|
503
|
-
base_parablock
|
|
494
|
+
base_parablock('best', lines, caption)
|
|
504
495
|
end
|
|
505
496
|
|
|
506
497
|
def important(lines, caption = nil)
|
|
507
|
-
base_parablock
|
|
498
|
+
base_parablock('important', lines, caption)
|
|
508
499
|
end
|
|
509
500
|
|
|
510
501
|
def security(lines, caption = nil)
|
|
511
|
-
base_parablock
|
|
502
|
+
base_parablock('security', lines, caption)
|
|
512
503
|
end
|
|
513
504
|
|
|
514
505
|
def caution(lines, caption = nil)
|
|
515
|
-
base_parablock
|
|
506
|
+
base_parablock('caution', lines, caption)
|
|
516
507
|
end
|
|
517
508
|
|
|
518
509
|
def term(lines)
|
|
519
|
-
base_parablock
|
|
510
|
+
base_parablock('term', lines, nil)
|
|
520
511
|
end
|
|
521
512
|
|
|
522
513
|
def link(lines, caption = nil)
|
|
523
|
-
base_parablock
|
|
514
|
+
base_parablock('link', lines, caption)
|
|
524
515
|
end
|
|
525
516
|
|
|
526
517
|
def notice(lines, caption = nil)
|
|
527
|
-
base_parablock
|
|
518
|
+
base_parablock('notice', lines, caption)
|
|
528
519
|
end
|
|
529
520
|
|
|
530
521
|
def point(lines, caption = nil)
|
|
531
|
-
base_parablock
|
|
522
|
+
base_parablock('point', lines, caption)
|
|
532
523
|
end
|
|
533
524
|
|
|
534
525
|
def shoot(lines, caption = nil)
|
|
535
|
-
base_parablock
|
|
526
|
+
base_parablock('shoot', lines, caption)
|
|
536
527
|
end
|
|
537
528
|
|
|
538
529
|
def reference(lines)
|
|
539
|
-
base_parablock
|
|
530
|
+
base_parablock('reference', lines, nil)
|
|
540
531
|
end
|
|
541
532
|
|
|
542
533
|
def practice(lines)
|
|
543
|
-
base_parablock
|
|
534
|
+
base_parablock('practice', lines, nil)
|
|
544
535
|
end
|
|
545
536
|
|
|
546
537
|
def expert(lines)
|
|
547
|
-
base_parablock
|
|
538
|
+
base_parablock('expert', lines, nil)
|
|
548
539
|
end
|
|
549
540
|
|
|
550
541
|
def insn(lines, caption = nil)
|
|
551
|
-
base_block
|
|
542
|
+
base_block('insn', lines, caption)
|
|
552
543
|
end
|
|
553
544
|
|
|
554
545
|
def warning(lines, caption = nil)
|
|
555
|
-
base_parablock
|
|
546
|
+
base_parablock('warning', lines, caption)
|
|
556
547
|
end
|
|
557
548
|
|
|
558
549
|
alias_method :box, :insn
|
|
@@ -573,7 +564,7 @@ module ReVIEW
|
|
|
573
564
|
end
|
|
574
565
|
|
|
575
566
|
def bpo(lines)
|
|
576
|
-
base_block
|
|
567
|
+
base_block('bpo', lines, nil)
|
|
577
568
|
end
|
|
578
569
|
|
|
579
570
|
def inline_dtp(_str)
|
|
@@ -623,7 +614,7 @@ module ReVIEW
|
|
|
623
614
|
end
|
|
624
615
|
|
|
625
616
|
def source(lines, caption = nil, _lang = nil)
|
|
626
|
-
base_block
|
|
617
|
+
base_block('source', lines, caption)
|
|
627
618
|
end
|
|
628
619
|
|
|
629
620
|
def inline_labelref(_idref)
|