review 5.1.1 → 5.4.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-tex.yml +6 -2
- data/.github/workflows/ruby-win.yml +6 -2
- data/.github/workflows/ruby.yml +6 -2
- data/.rubocop.yml +5 -319
- data/NEWS.ja.md +149 -0
- data/NEWS.md +149 -1
- data/README.md +9 -8
- data/bin/review +1 -1
- data/bin/review-catalog-converter +15 -15
- data/bin/review-check +7 -7
- data/bin/review-compile +14 -23
- data/bin/review-index +1 -1
- data/bin/review-preproc +29 -35
- data/bin/review-validate +2 -2
- data/doc/config.yml.sample +9 -1
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +29 -3
- data/doc/format.md +32 -3
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review/book/base.rb +3 -3
- data/lib/review/book/book_unit.rb +13 -3
- data/lib/review/book/chapter.rb +1 -1
- data/lib/review/book/index.rb +7 -4
- data/lib/review/book/part.rb +12 -13
- data/lib/review/book/volume.rb +1 -1
- data/lib/review/builder.rb +92 -65
- data/lib/review/catalog.rb +6 -5
- data/lib/review/compiler.rb +76 -57
- data/lib/review/configure.rb +5 -2
- data/lib/review/epub2html.rb +12 -12
- data/lib/review/epubmaker/content.rb +1 -1
- data/lib/review/epubmaker/epubcommon.rb +47 -45
- data/lib/review/epubmaker/epubv2.rb +2 -1
- data/lib/review/epubmaker/epubv3.rb +5 -4
- data/lib/review/epubmaker/producer.rb +6 -7
- data/lib/review/epubmaker/reviewheaderlistener.rb +1 -1
- data/lib/review/epubmaker.rb +56 -67
- data/lib/review/exception.rb +7 -0
- data/lib/review/extentions/string.rb +1 -1
- data/lib/review/htmlbuilder.rb +90 -34
- data/lib/review/htmlutils.rb +17 -17
- data/lib/review/i18n.rb +3 -3
- data/lib/review/i18n.yml +6 -0
- data/lib/review/idgxmlbuilder.rb +61 -39
- data/lib/review/idgxmlmaker.rb +27 -26
- data/lib/review/img_math.rb +12 -18
- data/lib/review/index_builder.rb +94 -53
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbuilder.rb +84 -76
- data/lib/review/lineinput.rb +3 -3
- data/lib/review/location.rb +1 -1
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +69 -21
- data/lib/review/makerhelper.rb +8 -4
- data/lib/review/markdownbuilder.rb +21 -12
- data/lib/review/pdfmaker.rb +63 -42
- data/lib/review/plaintextbuilder.rb +16 -15
- data/lib/review/preprocessor/directive.rb +35 -0
- data/lib/review/preprocessor/line.rb +34 -0
- data/lib/review/preprocessor/repository.rb +177 -0
- data/lib/review/preprocessor.rb +94 -296
- data/lib/review/rstbuilder.rb +12 -3
- data/lib/review/template.rb +5 -1
- data/lib/review/textmaker.rb +32 -31
- data/lib/review/textutils.rb +5 -6
- data/lib/review/tocprinter.rb +12 -7
- data/lib/review/topbuilder.rb +96 -19
- data/lib/review/update.rb +16 -8
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +9 -9
- data/lib/review/webmaker.rb +45 -46
- data/lib/review/webtocprinter.rb +10 -10
- data/lib/review/yamlloader.rb +35 -2
- data/review.gemspec +2 -1
- data/samples/sample-book/src/config.yml +0 -1
- data/samples/sample-book/src/lib/tasks/review.rake +3 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/ch02.re +9 -0
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/html/_titlepage.html.erb +9 -17
- data/templates/latex/config.erb +3 -0
- data/templates/latex/review-jlreq/review-base.sty +4 -5
- data/templates/latex/review-jlreq/review-jlreq.cls +39 -5
- data/templates/latex/review-jsbook/review-base.sty +9 -3
- data/templates/latex/review-jsbook/review-jsbook.cls +32 -5
- data/templates/opf/opf_manifest_epubv2.opf.erb +1 -1
- data/templates/opf/opf_manifest_epubv3.opf.erb +1 -1
- data/test/assets/syntax_book_index_detail.txt +10 -8
- data/test/assets/test_template.tex +4 -1
- data/test/assets/test_template_backmatter.tex +4 -1
- data/test/book_test_helper.rb +10 -10
- data/test/test_book_chapter.rb +25 -2
- data/test/test_builder.rb +10 -8
- data/test/test_epub3maker.rb +3 -3
- data/test/test_epubmaker.rb +27 -37
- data/test/test_epubmaker_cmd.rb +14 -3
- data/test/test_htmlbuilder.rb +111 -31
- data/test/test_idgxmlbuilder.rb +41 -33
- data/test/test_idgxmlmaker_cmd.rb +1 -1
- data/test/test_img_math.rb +11 -2
- data/test/test_index.rb +30 -4
- data/test/test_latexbuilder.rb +46 -25
- data/test/test_latexbuilder_v2.rb +18 -10
- data/test/test_markdownbuilder.rb +13 -0
- data/test/test_pdfmaker.rb +19 -0
- data/test/test_pdfmaker_cmd.rb +10 -10
- data/test/test_plaintextbuilder.rb +46 -22
- data/test/test_preprocessor.rb +188 -1
- data/test/test_rstbuilder.rb +13 -0
- data/test/test_textmaker_cmd.rb +1 -1
- data/test/test_topbuilder.rb +195 -29
- data/test/test_yamlloader.rb +28 -42
- metadata +11 -6
data/lib/review/rstbuilder.rb
CHANGED
@@ -54,12 +54,12 @@ module ReVIEW
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def builder_init_file
|
57
|
+
super
|
57
58
|
@section = 0
|
58
59
|
@subsection = 0
|
59
60
|
@subsubsection = 0
|
60
61
|
@subsubsubsection = 0
|
61
62
|
@blank_seen = true
|
62
|
-
@sec_counter = SecCounter.new(5, @chapter)
|
63
63
|
@ul_indent = 0
|
64
64
|
@ol_indent = 0
|
65
65
|
@in_role = false
|
@@ -86,6 +86,7 @@ module ReVIEW
|
|
86
86
|
private :blank
|
87
87
|
|
88
88
|
def result
|
89
|
+
check_printendnotes
|
89
90
|
solve_nest(@output.string)
|
90
91
|
end
|
91
92
|
|
@@ -124,7 +125,7 @@ module ReVIEW
|
|
124
125
|
end
|
125
126
|
|
126
127
|
def ul_item(lines)
|
127
|
-
puts ' ' * (@ul_indent - 1) + "* #{join_lines_to_paragraph(lines)}"
|
128
|
+
puts (' ' * (@ul_indent - 1)) + "* #{join_lines_to_paragraph(lines)}"
|
128
129
|
end
|
129
130
|
|
130
131
|
def ul_end
|
@@ -138,7 +139,7 @@ module ReVIEW
|
|
138
139
|
end
|
139
140
|
|
140
141
|
def ol_item(lines, _num)
|
141
|
-
puts ' ' * (@ol_indent - 1) + "#. #{join_lines_to_paragraph(lines)}"
|
142
|
+
puts (' ' * (@ol_indent - 1)) + "#. #{join_lines_to_paragraph(lines)}"
|
142
143
|
end
|
143
144
|
|
144
145
|
def ol_end
|
@@ -367,6 +368,14 @@ module ReVIEW
|
|
367
368
|
" [##{id.sub(' ', '_')}]_ "
|
368
369
|
end
|
369
370
|
|
371
|
+
def inline_endnote(id)
|
372
|
+
" [(#{@chapter.endnote(id).number})]_ "
|
373
|
+
end
|
374
|
+
|
375
|
+
def endnote_item(id)
|
376
|
+
puts ".. [(#{@chapter.endnote(id).number})] #{compile_inline(@chapter.endnote(id).content)}"
|
377
|
+
end
|
378
|
+
|
370
379
|
def compile_ruby(base, ruby)
|
371
380
|
" :ruby:`#{base}`<#{ruby}>`_ "
|
372
381
|
end
|
data/lib/review/template.rb
CHANGED
@@ -19,7 +19,11 @@ module ReVIEW
|
|
19
19
|
return unless filename
|
20
20
|
|
21
21
|
content = File.read(filename)
|
22
|
-
@erb =
|
22
|
+
@erb = if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
|
23
|
+
ERB.new(content, trim_mode: mode)
|
24
|
+
else
|
25
|
+
ERB.new(content, nil, mode)
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def result(bind_data = nil)
|
data/lib/review/textmaker.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2018-
|
1
|
+
# Copyright (c) 2018-2022 Kenshi Muto
|
2
2
|
#
|
3
3
|
# This program is free software.
|
4
4
|
# You can distribute or modify this program under the terms of
|
@@ -17,10 +17,12 @@ require 'review/topbuilder'
|
|
17
17
|
require 'review/version'
|
18
18
|
require 'review/makerhelper'
|
19
19
|
require 'review/img_math'
|
20
|
+
require 'review/loggable'
|
20
21
|
|
21
22
|
module ReVIEW
|
22
23
|
class TEXTMaker
|
23
24
|
include MakerHelper
|
25
|
+
include Loggable
|
24
26
|
|
25
27
|
attr_accessor :config, :basedir
|
26
28
|
|
@@ -29,15 +31,7 @@ module ReVIEW
|
|
29
31
|
@logger = ReVIEW.logger
|
30
32
|
@plaintext = nil
|
31
33
|
@img_math = nil
|
32
|
-
|
33
|
-
|
34
|
-
def error(msg)
|
35
|
-
@logger.error msg
|
36
|
-
exit 1
|
37
|
-
end
|
38
|
-
|
39
|
-
def warn(msg)
|
40
|
-
@logger.warn msg
|
34
|
+
@compile_errors = nil
|
41
35
|
end
|
42
36
|
|
43
37
|
def self.execute(*args)
|
@@ -78,11 +72,16 @@ module ReVIEW
|
|
78
72
|
|
79
73
|
def execute(*args)
|
80
74
|
cmd_config, yamlfile = parse_opts(args)
|
81
|
-
error "#{yamlfile} not found." unless File.exist?(yamlfile)
|
75
|
+
error! "#{yamlfile} not found." unless File.exist?(yamlfile)
|
76
|
+
|
77
|
+
begin
|
78
|
+
@config = ReVIEW::Configure.create(maker: 'textmaker',
|
79
|
+
yamlfile: yamlfile,
|
80
|
+
config: cmd_config)
|
81
|
+
rescue ReVIEW::ConfigError => e
|
82
|
+
error! e.message
|
83
|
+
end
|
82
84
|
|
83
|
-
@config = ReVIEW::Configure.create(maker: 'textmaker',
|
84
|
-
yamlfile: yamlfile,
|
85
|
-
config: cmd_config)
|
86
85
|
@img_math = ReVIEW::ImgMath.new(@config, path_name: '_review_math_text')
|
87
86
|
|
88
87
|
I18n.setup(@config['language'])
|
@@ -92,7 +91,7 @@ module ReVIEW
|
|
92
91
|
rescue ApplicationError => e
|
93
92
|
raise if @config['debug']
|
94
93
|
|
95
|
-
error
|
94
|
+
error! e.message
|
96
95
|
end
|
97
96
|
|
98
97
|
if @config['math_format'] == 'imgmath'
|
@@ -109,16 +108,19 @@ module ReVIEW
|
|
109
108
|
@book = ReVIEW::Book::Base.new(@basedir, config: @config)
|
110
109
|
|
111
110
|
build_body(@path, yamlfile)
|
111
|
+
|
112
|
+
if @compile_errors
|
113
|
+
app_error 'compile error, No TEXT file output.'
|
114
|
+
end
|
112
115
|
end
|
113
116
|
|
114
117
|
def build_body(basetmpdir, _yamlfile)
|
115
118
|
base_path = Pathname.new(@basedir)
|
116
|
-
builder =
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
119
|
+
builder = if @plaintext
|
120
|
+
ReVIEW::PLAINTEXTBuilder.new(img_math: @img_math)
|
121
|
+
else
|
122
|
+
ReVIEW::TOPBuilder.new(img_math: @img_math)
|
123
|
+
end
|
122
124
|
@converter = ReVIEW::Converter.new(@book, builder)
|
123
125
|
@book.parts.each do |part|
|
124
126
|
if part.name.present?
|
@@ -144,13 +146,11 @@ module ReVIEW
|
|
144
146
|
end
|
145
147
|
|
146
148
|
def build_chap(chap, base_path, basetmpdir, ispart)
|
147
|
-
filename =
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
filename = Pathname.new(chap.path).relative_path_from(base_path).to_s
|
153
|
-
end
|
149
|
+
filename = if ispart.present?
|
150
|
+
chap.path
|
151
|
+
else
|
152
|
+
Pathname.new(chap.path).relative_path_from(base_path).to_s
|
153
|
+
end
|
154
154
|
id = File.basename(filename).sub(/\.re\Z/, '')
|
155
155
|
if @buildonly && !@buildonly.include?(id)
|
156
156
|
warn "skip #{id}.re"
|
@@ -161,9 +161,10 @@ module ReVIEW
|
|
161
161
|
|
162
162
|
begin
|
163
163
|
@converter.convert(filename, File.join(basetmpdir, textfile))
|
164
|
-
rescue => e
|
165
|
-
|
166
|
-
|
164
|
+
rescue StandardError => e
|
165
|
+
@compile_errors = true
|
166
|
+
error "compile error in #{filename} (#{e.class})"
|
167
|
+
error e.message
|
167
168
|
end
|
168
169
|
end
|
169
170
|
end
|
data/lib/review/textutils.rb
CHANGED
@@ -15,7 +15,7 @@ module ReVIEW
|
|
15
15
|
add = 0
|
16
16
|
len = nil
|
17
17
|
str.gsub("\t") do
|
18
|
-
len = ts - ($`.size + add) % ts
|
18
|
+
len = ts - (($`.size + add) % ts)
|
19
19
|
add += len - 1
|
20
20
|
' ' * len
|
21
21
|
end
|
@@ -72,11 +72,10 @@ module ReVIEW
|
|
72
72
|
end
|
73
73
|
|
74
74
|
# lazy than rule 3, but it looks better
|
75
|
-
if lazy &&
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
head !~ /\p{Hangul}/)
|
75
|
+
if lazy && ((%i[F W H].include?(Unicode::Eaw.property(tail)) &&
|
76
|
+
tail !~ /\p{Hangul}/) ||
|
77
|
+
(%i[F W H].include?(Unicode::Eaw.property(head)) &&
|
78
|
+
head !~ /\p{Hangul}/))
|
80
79
|
space = nil
|
81
80
|
end
|
82
81
|
end
|
data/lib/review/tocprinter.rb
CHANGED
@@ -69,12 +69,17 @@ module ReVIEW
|
|
69
69
|
|
70
70
|
def execute(*args)
|
71
71
|
parse_options(args)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
begin
|
73
|
+
@config = ReVIEW::Configure.create(yamlfile: @yamlfile)
|
74
|
+
@book = ReVIEW::Book::Base.new('.', config: @config)
|
75
|
+
unless File.readable?(@yamlfile)
|
76
|
+
raise ReVIEW::FileNotFound, "No such fiile or can't open #{@yamlfile}."
|
77
|
+
end
|
78
|
+
rescue ReVIEW::ConfigError, ReVIEW::FileNotFound, ReVIEW::CompileError, ReVIEW::ApplicationError => e
|
79
|
+
@logger.error e.message
|
76
80
|
exit 1
|
77
81
|
end
|
82
|
+
|
78
83
|
I18n.setup(@config['language'])
|
79
84
|
|
80
85
|
if @detail
|
@@ -226,9 +231,9 @@ module ReVIEW
|
|
226
231
|
|
227
232
|
case mode
|
228
233
|
when :list
|
229
|
-
(calc_linesize(line) - 1) / @book.page_metric.list.n_columns + 1
|
234
|
+
((calc_linesize(line) - 1) / @book.page_metric.list.n_columns) + 1
|
230
235
|
else # mode == :text
|
231
|
-
(calc_linesize(line) - 1) / @book.page_metric.text.n_columns + 1
|
236
|
+
((calc_linesize(line) - 1) / @book.page_metric.text.n_columns) + 1
|
232
237
|
end
|
233
238
|
end
|
234
239
|
|
@@ -257,7 +262,7 @@ module ReVIEW
|
|
257
262
|
compiler.compile(@book.chapter(chap.name))
|
258
263
|
rescue ReVIEW::ApplicationError => e
|
259
264
|
@logger.error e.message
|
260
|
-
|
265
|
+
''
|
261
266
|
end
|
262
267
|
end
|
263
268
|
|
data/lib/review/topbuilder.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2008-
|
1
|
+
# Copyright (c) 2008-2022 Minero Aoki, Kenshi Muto
|
2
2
|
# 2002-2006 Minero Aoki
|
3
3
|
#
|
4
4
|
# This program is free software.
|
@@ -105,7 +105,7 @@ module ReVIEW
|
|
105
105
|
list_header(id, caption, lang)
|
106
106
|
end
|
107
107
|
rescue KeyError
|
108
|
-
|
108
|
+
app_error "no such list: #{id}"
|
109
109
|
end
|
110
110
|
puts "◆→終了:#{@titles['list']}←◆"
|
111
111
|
blank
|
@@ -178,7 +178,7 @@ module ReVIEW
|
|
178
178
|
list_header(id, caption, lang)
|
179
179
|
end
|
180
180
|
rescue KeyError
|
181
|
-
|
181
|
+
app_error "no such list: #{id}"
|
182
182
|
end
|
183
183
|
puts "◆→終了:#{@titles['list']}←◆"
|
184
184
|
blank
|
@@ -202,7 +202,7 @@ module ReVIEW
|
|
202
202
|
if @chapter.image_bound?(id)
|
203
203
|
puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
|
204
204
|
else
|
205
|
-
warn "image not bound: #{id}"
|
205
|
+
warn "image not bound: #{id}", location: location
|
206
206
|
lines.each do |line|
|
207
207
|
puts line
|
208
208
|
end
|
@@ -262,13 +262,61 @@ module ReVIEW
|
|
262
262
|
blank
|
263
263
|
end
|
264
264
|
|
265
|
+
def table_rows(sepidx, rows)
|
266
|
+
if sepidx
|
267
|
+
sepidx.times do
|
268
|
+
tr(rows.shift.map { |s| th(s) })
|
269
|
+
end
|
270
|
+
if !@book.config['textmaker'] || !@book.config['textmaker']['th_bold']
|
271
|
+
puts '-' * 12
|
272
|
+
end
|
273
|
+
rows.each do |cols|
|
274
|
+
tr(cols.map { |s| td(s) })
|
275
|
+
end
|
276
|
+
else
|
277
|
+
rows.each do |cols|
|
278
|
+
h, *cs = *cols
|
279
|
+
tr([th(h)] + cs.map { |s| td(s) })
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
265
284
|
def th(str)
|
266
|
-
|
285
|
+
if @book.config['textmaker'] && @book.config['textmaker']['th_bold']
|
286
|
+
"★#{str}☆"
|
287
|
+
else
|
288
|
+
str
|
289
|
+
end
|
267
290
|
end
|
268
291
|
|
269
292
|
def table_end
|
270
293
|
end
|
271
294
|
|
295
|
+
def imgtable(lines, id, caption = nil, metric = nil)
|
296
|
+
metrics = parse_metric('top', metric)
|
297
|
+
metrics = " #{metrics}" if metrics.present?
|
298
|
+
blank
|
299
|
+
puts "◆→開始:#{@titles['table']}←◆"
|
300
|
+
if caption_top?('table') && caption.present?
|
301
|
+
table_header(id, caption)
|
302
|
+
end
|
303
|
+
|
304
|
+
if @chapter.image_bound?(id)
|
305
|
+
puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
|
306
|
+
else
|
307
|
+
warn "image not bound: #{id}", location: location
|
308
|
+
lines.each do |line|
|
309
|
+
puts line
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
if !caption_top?('table') && caption.present?
|
314
|
+
table_header(id, caption)
|
315
|
+
end
|
316
|
+
puts "◆→終了:#{@titles['table']}←◆"
|
317
|
+
blank
|
318
|
+
end
|
319
|
+
|
272
320
|
def comment(lines, comment = nil)
|
273
321
|
return unless @book.config['draft']
|
274
322
|
|
@@ -287,7 +335,25 @@ module ReVIEW
|
|
287
335
|
def inline_fn(id)
|
288
336
|
"【注#{@chapter.footnote(id).number}】"
|
289
337
|
rescue KeyError
|
290
|
-
|
338
|
+
app_error "unknown footnote: #{id}"
|
339
|
+
end
|
340
|
+
|
341
|
+
def inline_endnote(id)
|
342
|
+
"【後注#{@chapter.endnote(id).number}】"
|
343
|
+
rescue KeyError
|
344
|
+
app_error "unknown endnote: #{id}"
|
345
|
+
end
|
346
|
+
|
347
|
+
def endnote_begin
|
348
|
+
puts '◆→開始:後注←◆'
|
349
|
+
end
|
350
|
+
|
351
|
+
def endnote_end
|
352
|
+
puts '◆→終了:後注←◆'
|
353
|
+
end
|
354
|
+
|
355
|
+
def endnote_item(id)
|
356
|
+
puts "【後注#{@chapter.endnote(id).number}】#{compile_inline(@chapter.endnote(id).content)}"
|
291
357
|
end
|
292
358
|
|
293
359
|
def compile_ruby(base, ruby)
|
@@ -296,8 +362,9 @@ module ReVIEW
|
|
296
362
|
|
297
363
|
def compile_kw(word, alt)
|
298
364
|
if alt
|
299
|
-
|
300
|
-
else
|
365
|
+
"★#{word}☆(#{alt.strip})"
|
366
|
+
else
|
367
|
+
"★#{word}☆"
|
301
368
|
end
|
302
369
|
end
|
303
370
|
|
@@ -380,8 +447,8 @@ module ReVIEW
|
|
380
447
|
def inline_icon(id)
|
381
448
|
begin
|
382
449
|
"◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
|
383
|
-
rescue
|
384
|
-
warn "image not bound: #{id}"
|
450
|
+
rescue StandardError
|
451
|
+
warn "image not bound: #{id}", location: location
|
385
452
|
"◆→画像 #{id}←◆"
|
386
453
|
end
|
387
454
|
end
|
@@ -425,7 +492,7 @@ module ReVIEW
|
|
425
492
|
def inline_bib(id)
|
426
493
|
%Q([#{@chapter.bibpaper(id).number}])
|
427
494
|
rescue KeyError
|
428
|
-
|
495
|
+
app_error "unknown bib: #{id}"
|
429
496
|
end
|
430
497
|
|
431
498
|
def noindent
|
@@ -477,27 +544,37 @@ module ReVIEW
|
|
477
544
|
), __FILE__, __LINE__ - 11
|
478
545
|
end
|
479
546
|
|
480
|
-
def indepimage(
|
547
|
+
def indepimage(lines, id, caption = nil, metric = nil)
|
481
548
|
metrics = parse_metric('top', metric)
|
482
549
|
metrics = " #{metrics}" if metrics.present?
|
483
550
|
blank
|
551
|
+
puts "◆→開始:#{@titles['image']}←◆"
|
484
552
|
if caption_top?('image') && caption.present?
|
485
|
-
|
553
|
+
indepimage_header(id, caption)
|
554
|
+
blank
|
486
555
|
end
|
487
|
-
|
488
|
-
puts "
|
489
|
-
|
490
|
-
warn "image not bound: #{id}"
|
491
|
-
|
556
|
+
if @chapter.image_bound?(id)
|
557
|
+
puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
|
558
|
+
else
|
559
|
+
warn "image not bound: #{id}", location: location
|
560
|
+
lines.each do |line|
|
561
|
+
puts line
|
562
|
+
end
|
492
563
|
end
|
493
564
|
if !caption_top?('image') && caption.present?
|
494
|
-
|
565
|
+
blank
|
566
|
+
indepimage_header(id, caption)
|
495
567
|
end
|
568
|
+
puts "◆→終了:#{@titles['image']}←◆"
|
496
569
|
blank
|
497
570
|
end
|
498
571
|
|
499
572
|
alias_method :numberlessimage, :indepimage
|
500
573
|
|
574
|
+
def indepimage_header(_id, caption)
|
575
|
+
puts "図#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
576
|
+
end
|
577
|
+
|
501
578
|
def inline_code(str)
|
502
579
|
"△#{str}☆"
|
503
580
|
end
|
data/lib/review/update.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2018-
|
2
|
+
# Copyright (c) 2018-2022 Kenshi Muto
|
3
3
|
#
|
4
4
|
# This program is free software.
|
5
5
|
# You can distribute or modify this program under the terms of
|
@@ -165,7 +165,7 @@ module ReVIEW
|
|
165
165
|
|
166
166
|
Dir.glob(File.join(dir, '*.yml')).sort.each do |yml|
|
167
167
|
begin
|
168
|
-
config =
|
168
|
+
config = YAMLLoader.safe_load_file(yml)
|
169
169
|
if config['language'].present?
|
170
170
|
language = config['language']
|
171
171
|
end
|
@@ -226,9 +226,11 @@ module ReVIEW
|
|
226
226
|
|
227
227
|
def check_own_files(dir)
|
228
228
|
if File.exist?(File.join(dir, 'layouts/layout.tex.erb'))
|
229
|
+
# rubocop:disable Style/SoleNestedConditional
|
229
230
|
unless confirm('** There is custom layouts/layout.tex.erb file. Updating may break to make PDF until you fix layout.tex.erb. Do you really proceed to update? **', [], nil)
|
230
231
|
raise ApplicationError
|
231
232
|
end
|
233
|
+
# rubocop:enable Style/SoleNestedConditional
|
232
234
|
end
|
233
235
|
|
234
236
|
if File.exist?(File.join(dir, 'review-ext.rb'))
|
@@ -238,7 +240,7 @@ module ReVIEW
|
|
238
240
|
|
239
241
|
def update_version
|
240
242
|
@config_ymls.each do |yml|
|
241
|
-
config =
|
243
|
+
config = YAMLLoader.safe_load_file(yml)
|
242
244
|
if config['review_version'].to_f.round(1) == TARGET_VERSION.to_f.round(1)
|
243
245
|
next
|
244
246
|
end
|
@@ -265,10 +267,12 @@ module ReVIEW
|
|
265
267
|
target_rakefile = File.join(dir, 'Rakefile')
|
266
268
|
if File.exist?(target_rakefile)
|
267
269
|
if Digest::SHA256.hexdigest(File.read(target_rakefile)) != Digest::SHA256.hexdigest(File.read(master_rakefile))
|
270
|
+
# rubocop:disable Style/SoleNestedConditional
|
268
271
|
if confirm('%s will be overridden with Re:VIEW version (%s). Do you really proceed?', ['Rakefile', master_rakefile])
|
269
272
|
FileUtils.mv(target_rakefile, "#{target_rakefile}-old")
|
270
273
|
FileUtils.cp(master_rakefile, target_rakefile)
|
271
274
|
end
|
275
|
+
# rubocop:enable Style/SoleNestedConditional
|
272
276
|
end
|
273
277
|
else
|
274
278
|
@logger.info t('new file %s is created.', [target_rakefile]) unless @force
|
@@ -278,12 +282,14 @@ module ReVIEW
|
|
278
282
|
master_rakefile = File.join(@review_dir, 'samples/sample-book/src/lib/tasks/review.rake')
|
279
283
|
target_rakefile = File.join(taskdir, 'review.rake')
|
280
284
|
if File.exist?(target_rakefile)
|
285
|
+
# rubocop:disable Style/SoleNestedConditional
|
281
286
|
if Digest::SHA256.hexdigest(File.read(target_rakefile)) != Digest::SHA256.hexdigest(File.read(master_rakefile))
|
282
287
|
if confirm('%s will be overridden with Re:VIEW version (%s). Do you really proceed?', ['lib/tasks/review.rake', master_rakefile])
|
283
288
|
FileUtils.mv(target_rakefile, "#{target_rakefile}-old")
|
284
289
|
FileUtils.cp(master_rakefile, target_rakefile)
|
285
290
|
end
|
286
291
|
end
|
292
|
+
# rubocop:enable Style/SoleNestedConditional
|
287
293
|
else
|
288
294
|
@logger.info t('new file %s is created.', [target_rakefile]) unless @force
|
289
295
|
FileUtils.cp(master_rakefile, target_rakefile)
|
@@ -292,11 +298,13 @@ module ReVIEW
|
|
292
298
|
|
293
299
|
def update_epub_version
|
294
300
|
@epub_ymls.each do |yml|
|
295
|
-
config =
|
301
|
+
config = YAMLLoader.safe_load_file(yml)
|
296
302
|
if config['epubversion'].present? && config['epubversion'].to_f < EPUB_VERSION.to_f
|
303
|
+
# rubocop:disable Style/SoleNestedConditional
|
297
304
|
if confirm("%s: Update '%s' to '%s' from '%s'?", [File.basename(yml), 'epubversion', EPUB_VERSION, config['epubversion']])
|
298
305
|
rewrite_yml(yml, 'epubversion', EPUB_VERSION)
|
299
306
|
end
|
307
|
+
# rubocop:enable Style/SoleNestedConditional
|
300
308
|
end
|
301
309
|
if !config['htmlversion'].present? || config['htmlversion'].to_f >= HTML_VERSION.to_f
|
302
310
|
next
|
@@ -310,7 +318,7 @@ module ReVIEW
|
|
310
318
|
|
311
319
|
def update_locale
|
312
320
|
@locale_ymls.each do |yml|
|
313
|
-
config =
|
321
|
+
config = YAMLLoader.safe_load_file(yml)
|
314
322
|
if !config['chapter_quote'].present? || config['chapter_quote'].scan('%s').size != 1
|
315
323
|
next
|
316
324
|
end
|
@@ -324,7 +332,7 @@ module ReVIEW
|
|
324
332
|
|
325
333
|
def update_tex_parameters
|
326
334
|
@tex_ymls.each do |yml|
|
327
|
-
config =
|
335
|
+
config = YAMLLoader.safe_load_file(yml)
|
328
336
|
unless config['texdocumentclass']
|
329
337
|
next
|
330
338
|
end
|
@@ -510,7 +518,7 @@ module ReVIEW
|
|
510
518
|
|
511
519
|
def update_tex_command
|
512
520
|
@tex_ymls.each do |yml|
|
513
|
-
config =
|
521
|
+
config = YAMLLoader.safe_load_file(yml)
|
514
522
|
if !config['texcommand'] || config['texcommand'] !~ /\s+-/
|
515
523
|
next
|
516
524
|
end
|
@@ -535,7 +543,7 @@ module ReVIEW
|
|
535
543
|
|
536
544
|
def update_dvi_command
|
537
545
|
@tex_ymls.each do |yml|
|
538
|
-
config =
|
546
|
+
config = YAMLLoader.safe_load_file(yml)
|
539
547
|
if !config['dvicommand'] || config['dvicommand'] !~ /\s+-/
|
540
548
|
next
|
541
549
|
end
|
data/lib/review/version.rb
CHANGED
data/lib/review/volumeprinter.rb
CHANGED
@@ -27,15 +27,15 @@ module ReVIEW
|
|
27
27
|
|
28
28
|
def execute(*args)
|
29
29
|
parse_options(args)
|
30
|
-
@config = ReVIEW::Configure.create(yamlfile: @yamlfile)
|
31
|
-
@book = ReVIEW::Book::Base.new('.', config: @config)
|
32
|
-
unless File.readable?(@yamlfile)
|
33
|
-
@logger.error("No such fiile or can't open #{@yamlfile}.")
|
34
|
-
exit 1
|
35
|
-
end
|
36
|
-
I18n.setup(@book.config['language'])
|
37
|
-
|
38
30
|
begin
|
31
|
+
@config = ReVIEW::Configure.create(yamlfile: @yamlfile)
|
32
|
+
@book = ReVIEW::Book::Base.new('.', config: @config)
|
33
|
+
unless File.readable?(@yamlfile)
|
34
|
+
raise ReVIEW::FileNotFound, "No such fiile or can't open #{@yamlfile}."
|
35
|
+
end
|
36
|
+
|
37
|
+
I18n.setup(@book.config['language'])
|
38
|
+
|
39
39
|
@book.each_part do |part|
|
40
40
|
if part.number
|
41
41
|
print_chapter_volume(part)
|
@@ -44,7 +44,7 @@ module ReVIEW
|
|
44
44
|
print_chapter_volume(chap)
|
45
45
|
end
|
46
46
|
end
|
47
|
-
rescue ReVIEW::FileNotFound, ReVIEW::CompileError, ReVIEW::ApplicationError => e
|
47
|
+
rescue ReVIEW::ConfigError, ReVIEW::FileNotFound, ReVIEW::CompileError, ReVIEW::ApplicationError => e
|
48
48
|
@logger.error e.message
|
49
49
|
exit 1
|
50
50
|
end
|