review 5.3.0 → 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 +1 -1
- data/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +1 -322
- data/NEWS.ja.md +48 -0
- data/NEWS.md +48 -0
- 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 +6 -8
- data/bin/review-index +1 -1
- data/bin/review-preproc +1 -1
- data/bin/review-validate +2 -2
- data/doc/config.yml.sample +7 -1
- data/doc/config.yml.sample-simple +1 -1
- data/lib/review/book/base.rb +3 -3
- data/lib/review/book/book_unit.rb +1 -1
- data/lib/review/book/chapter.rb +1 -1
- data/lib/review/book/index.rb +3 -3
- data/lib/review/book/part.rb +12 -13
- data/lib/review/book/volume.rb +1 -1
- data/lib/review/builder.rb +10 -12
- data/lib/review/catalog.rb +5 -5
- data/lib/review/compiler.rb +13 -13
- 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 +44 -42
- data/lib/review/epubmaker/epubv2.rb +2 -1
- data/lib/review/epubmaker/epubv3.rb +5 -4
- data/lib/review/epubmaker/producer.rb +3 -3
- data/lib/review/epubmaker/reviewheaderlistener.rb +1 -1
- data/lib/review/epubmaker.rb +32 -31
- data/lib/review/extentions/string.rb +1 -1
- data/lib/review/htmlbuilder.rb +16 -15
- data/lib/review/htmlutils.rb +17 -17
- data/lib/review/i18n.rb +3 -3
- data/lib/review/idgxmlbuilder.rb +22 -21
- data/lib/review/idgxmlmaker.rb +15 -13
- data/lib/review/index_builder.rb +4 -20
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbuilder.rb +30 -32
- data/lib/review/lineinput.rb +3 -3
- data/lib/review/location.rb +1 -1
- data/lib/review/logger.rb +21 -21
- data/lib/review/makerhelper.rb +3 -3
- data/lib/review/markdownbuilder.rb +6 -6
- data/lib/review/pdfmaker.rb +23 -19
- data/lib/review/plaintextbuilder.rb +5 -5
- data/lib/review/preprocessor/repository.rb +1 -1
- data/lib/review/preprocessor.rb +5 -5
- data/lib/review/textmaker.rb +20 -18
- data/lib/review/textutils.rb +3 -5
- data/lib/review/topbuilder.rb +71 -12
- data/lib/review/update.rb +16 -8
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +32 -32
- data/lib/review/webtocprinter.rb +10 -10
- data/lib/review/yamlloader.rb +35 -2
- data/review.gemspec +1 -0
- data/samples/sample-book/src/config.yml +0 -1
- data/templates/html/_titlepage.html.erb +9 -17
- data/templates/opf/opf_manifest_epubv2.opf.erb +1 -1
- data/templates/opf/opf_manifest_epubv3.opf.erb +1 -1
- data/test/book_test_helper.rb +10 -10
- data/test/test_epub3maker.rb +3 -3
- data/test/test_epubmaker.rb +14 -29
- data/test/test_epubmaker_cmd.rb +2 -2
- data/test/test_htmlbuilder.rb +4 -5
- data/test/test_idgxmlbuilder.rb +10 -10
- data/test/test_idgxmlmaker_cmd.rb +1 -1
- data/test/test_img_math.rb +11 -2
- data/test/test_latexbuilder.rb +2 -3
- data/test/test_pdfmaker_cmd.rb +10 -10
- data/test/test_textmaker_cmd.rb +1 -1
- data/test/test_topbuilder.rb +151 -11
- data/test/test_yamlloader.rb +28 -42
- metadata +8 -7
@@ -55,21 +55,21 @@ def main
|
|
55
55
|
end
|
56
56
|
# chaps and parts
|
57
57
|
if File.exist?("#{dir}/CHAPS")
|
58
|
-
if File.exist?("#{dir}/PART")
|
59
|
-
|
58
|
+
catalog << if File.exist?("#{dir}/PART")
|
59
|
+
parse_parts(File.read("#{dir}/PART"),
|
60
60
|
File.read("#{dir}/CHAPS"))
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
else
|
62
|
+
parse_chaps(File.read("#{dir}/CHAPS"))
|
63
|
+
end
|
64
64
|
end
|
65
65
|
# postdef
|
66
66
|
if File.exist?("#{dir}/POSTDEF")
|
67
67
|
postdef = File.read("#{dir}/POSTDEF")
|
68
|
-
if ask_yes?('Do you want to convert POSTDEF into APPENDIX? [y/n]')
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
catalog << if ask_yes?('Do you want to convert POSTDEF into APPENDIX? [y/n]')
|
69
|
+
parse_postdef(postdef, true)
|
70
|
+
else
|
71
|
+
parse_postdef(postdef)
|
72
|
+
end
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -99,11 +99,11 @@ def parse_chaps(str)
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def parse_postdef(str, to_appendix = false)
|
102
|
-
if to_appendix
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
102
|
+
header = if to_appendix
|
103
|
+
"APPENDIX:\n"
|
104
|
+
else
|
105
|
+
"POSTDEF:\n"
|
106
|
+
end
|
107
107
|
parse_internal(str, header) + "\n"
|
108
108
|
end
|
109
109
|
|
data/bin/review-check
CHANGED
@@ -18,7 +18,7 @@ include ReVIEW::TextUtils
|
|
18
18
|
|
19
19
|
def sigmain
|
20
20
|
Signal.trap(:INT) { exit 1 }
|
21
|
-
|
21
|
+
unless RUBY_PLATFORM.match?(/mswin(?!ce)|mingw|cygwin|bccwin/)
|
22
22
|
Signal.trap(:PIPE, 'IGNORE')
|
23
23
|
end
|
24
24
|
main
|
@@ -95,7 +95,7 @@ end
|
|
95
95
|
def find_line(lines, re)
|
96
96
|
# single line?
|
97
97
|
lines.each_with_index do |line, idx|
|
98
|
-
if re
|
98
|
+
if re&.match?(line)
|
99
99
|
return line.gsub(re, '<<<\&>>>'), idx
|
100
100
|
end
|
101
101
|
end
|
@@ -104,7 +104,7 @@ def find_line(lines, re)
|
|
104
104
|
i = 0
|
105
105
|
while i < lines.size - 1
|
106
106
|
str = lines[i] + lines[i + 1]
|
107
|
-
return str.gsub(re, '<<<\&>>>'), i if re
|
107
|
+
return str.gsub(re, '<<<\&>>>'), i if re&.match?(str)
|
108
108
|
|
109
109
|
i += 1
|
110
110
|
end
|
@@ -118,7 +118,7 @@ def words_re(rc)
|
|
118
118
|
File.foreach(rc) do |line|
|
119
119
|
next if line[0, 1] == '#'
|
120
120
|
|
121
|
-
if /
|
121
|
+
if / !/.match?(line)
|
122
122
|
line, n = *line.split('!', 2)
|
123
123
|
nega.push(n.strip)
|
124
124
|
end
|
@@ -141,7 +141,7 @@ def each_paragraph(f)
|
|
141
141
|
yield [$1], f.filename, f.lineno
|
142
142
|
when %r<\A//\w.*\{\s*\z>
|
143
143
|
while line = f.gets
|
144
|
-
break if %r{//\}}
|
144
|
+
break if %r{//\}}.match?(line)
|
145
145
|
end
|
146
146
|
when /\A=/
|
147
147
|
yield [line.slice(/\A=+(?:\[.*?\])?\s+(.*)/, 1).strip], f.lineno
|
@@ -150,8 +150,8 @@ def each_paragraph(f)
|
|
150
150
|
lineno = f.lineno
|
151
151
|
while line = f.gets
|
152
152
|
break if line.strip.empty?
|
153
|
-
break if %r{\A(?:=|//[\w\}])}
|
154
|
-
next if /\A
|
153
|
+
break if %r{\A(?:=|//[\w\}])}.match?(line)
|
154
|
+
next if /\A\#@/.match?(line)
|
155
155
|
|
156
156
|
buf.push(line.strip)
|
157
157
|
end
|
data/bin/review-compile
CHANGED
@@ -22,7 +22,7 @@ DEFAULT_CONFIG_FILENAME = 'config.yml'.freeze
|
|
22
22
|
|
23
23
|
def main
|
24
24
|
Signal.trap(:INT) { exit 1 }
|
25
|
-
|
25
|
+
unless RUBY_PLATFORM.match?(/mswin(?!ce)|mingw|cygwin|bccwin/)
|
26
26
|
Signal.trap(:PIPE, 'IGNORE')
|
27
27
|
end
|
28
28
|
_main
|
@@ -34,11 +34,9 @@ def _main
|
|
34
34
|
@logger = ReVIEW.logger
|
35
35
|
@mode = :files
|
36
36
|
@basedir = nil
|
37
|
-
if File.basename($PROGRAM_NAME).start_with?('review2')
|
38
|
-
|
39
|
-
|
40
|
-
@target = nil
|
41
|
-
end
|
37
|
+
@target = if File.basename($PROGRAM_NAME).start_with?('review2')
|
38
|
+
File.basename($PROGRAM_NAME, '.rb').sub('review2', '')
|
39
|
+
end
|
42
40
|
@check_only = false
|
43
41
|
@output_filename = nil
|
44
42
|
|
@@ -52,13 +50,13 @@ def _main
|
|
52
50
|
error! "#{@config['yaml']} not found." unless File.exist?(@config['yaml'])
|
53
51
|
begin
|
54
52
|
@config.deep_merge!(loader.load_file(@config['yaml']))
|
55
|
-
rescue => e
|
53
|
+
rescue StandardError => e
|
56
54
|
error! "yaml error #{e.message}"
|
57
55
|
end
|
58
56
|
elsif File.exist?(DEFAULT_CONFIG_FILENAME)
|
59
57
|
begin
|
60
58
|
@config.deep_merge!(loader.load_file(DEFAULT_CONFIG_FILENAME))
|
61
|
-
rescue => e
|
59
|
+
rescue StandardError => e
|
62
60
|
error! "yaml error #{e.message}"
|
63
61
|
end
|
64
62
|
end
|
data/bin/review-index
CHANGED
data/bin/review-preproc
CHANGED
data/bin/review-validate
CHANGED
@@ -41,7 +41,7 @@ ARGF.each do |line|
|
|
41
41
|
unless %w[list emlist listnum emlistnum cmd image table].include?(block)
|
42
42
|
@logger.warn "#{ln}: found '#{$1}' without the head space. Is it correct?"
|
43
43
|
end
|
44
|
-
elsif
|
44
|
+
elsif /\A\*\s+/.match?(line)
|
45
45
|
# itemize
|
46
46
|
unless %w[list emlist listnum emlistnum cmd image table].include?(block)
|
47
47
|
@logger.warn "#{ln}: found '*' without the head space. Is it correct?"
|
@@ -53,7 +53,7 @@ ARGF.each do |line|
|
|
53
53
|
elsif block == 'table'
|
54
54
|
next if line.start_with?('#@')
|
55
55
|
|
56
|
-
|
56
|
+
unless line.start_with?('-----')
|
57
57
|
# table
|
58
58
|
colcount = line.split("\t").size
|
59
59
|
if maxcolcount == 0
|
data/doc/config.yml.sample
CHANGED
@@ -87,7 +87,7 @@ aut: ["青木峰郎", "武藤健志", "高橋征義", "角征典"]
|
|
87
87
|
debug: null
|
88
88
|
|
89
89
|
# 固有IDに使用するドメイン。指定しない場合には、時刻に基づくランダムUUIDが入る
|
90
|
-
# urnid: urn:uuid:
|
90
|
+
# urnid: urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff
|
91
91
|
#
|
92
92
|
# ISBN。省略した場合はurnidが入る
|
93
93
|
# isbn: null
|
@@ -442,3 +442,9 @@ pdfmaker:
|
|
442
442
|
# options_with_caption: "colbacktitle=black!25!white"
|
443
443
|
#
|
444
444
|
# pdfmaker:階層を使うものはここまで
|
445
|
+
# textmaker:
|
446
|
+
# 表見出しの表現の設定
|
447
|
+
# nullの場合は区切り線(------------)で見出し行と通常の行を分ける。
|
448
|
+
# trueの場合は見出しを★〜☆で囲み(太字と同様)、区切り線を入れない。
|
449
|
+
# th_bold: null
|
450
|
+
# textmaker:階層を使うものはここまで
|
@@ -25,7 +25,7 @@ date: 2018-11-11
|
|
25
25
|
history: [["2012-01-30"],["2016-04-20","2016-05-03"],["2018-11-11"]]
|
26
26
|
rights: (C) 2016-2020 Re:VIEW Commiters, some rights reserved.
|
27
27
|
description: sample config.yml file for Re:VIEW book
|
28
|
-
urnid: urn:uuid:
|
28
|
+
# urnid: urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff
|
29
29
|
# isbn: null
|
30
30
|
|
31
31
|
## Book Structure
|
data/lib/review/book/base.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2022 Minero Aoki, Kenshi Muto, Masayoshi Takahashi
|
3
3
|
# 2002-2008 Minero Aoki
|
4
4
|
#
|
5
5
|
# This program is free software.
|
@@ -214,7 +214,7 @@ module ReVIEW
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def load_config(filename)
|
217
|
-
new_conf =
|
217
|
+
new_conf = YAMLLoader.safe_load_file(filename)
|
218
218
|
@config.merge!(new_conf)
|
219
219
|
end
|
220
220
|
|
@@ -408,7 +408,7 @@ module ReVIEW
|
|
408
408
|
end
|
409
409
|
|
410
410
|
def filename_join(*args)
|
411
|
-
File.join(args.
|
411
|
+
File.join(args.compact)
|
412
412
|
end
|
413
413
|
end
|
414
414
|
end
|
data/lib/review/book/chapter.rb
CHANGED
data/lib/review/book/index.rb
CHANGED
@@ -45,7 +45,7 @@ module ReVIEW
|
|
45
45
|
|
46
46
|
def [](id)
|
47
47
|
@index.fetch(id)
|
48
|
-
rescue
|
48
|
+
rescue StandardError
|
49
49
|
index_keys = @index.keys.map { |i| i.split('|').last }.flatten # unfold all ids
|
50
50
|
if index_keys.each_with_object(Hash.new(0)) { |i, h| h[i] += 1 }. # number of occurrences
|
51
51
|
select { |k, v| k == id && v > 1 }.present? # detect duplicated
|
@@ -84,14 +84,14 @@ module ReVIEW
|
|
84
84
|
begin
|
85
85
|
chapter = chapter_item.content
|
86
86
|
chapter.format_number
|
87
|
-
rescue # part
|
87
|
+
rescue StandardError # part
|
88
88
|
I18n.t('part', chapter.number)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
def title(id)
|
93
93
|
@index.fetch(id).content.title
|
94
|
-
rescue # non-file part
|
94
|
+
rescue StandardError # non-file part
|
95
95
|
@index.fetch(id).content.name
|
96
96
|
end
|
97
97
|
|
data/lib/review/book/part.rb
CHANGED
@@ -14,11 +14,11 @@ module ReVIEW
|
|
14
14
|
def self.mkpart_from_namelistfile(book, path)
|
15
15
|
chaps = []
|
16
16
|
File.read(path, mode: 'rt:BOM|utf-8').split.each_with_index do |name, number|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
chaps << if /PREDEF/.match?(path)
|
18
|
+
Chapter.mkchap(book, name)
|
19
|
+
else
|
20
|
+
Chapter.mkchap(book, name, number + 1)
|
21
|
+
end
|
22
22
|
end
|
23
23
|
Part.mkpart(chaps)
|
24
24
|
end
|
@@ -47,11 +47,11 @@ module ReVIEW
|
|
47
47
|
else
|
48
48
|
@content = ''
|
49
49
|
end
|
50
|
-
if file?
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
@title = if file?
|
51
|
+
nil
|
52
|
+
else
|
53
|
+
name
|
54
|
+
end
|
55
55
|
@volume = nil
|
56
56
|
|
57
57
|
super()
|
@@ -78,11 +78,10 @@ module ReVIEW
|
|
78
78
|
|
79
79
|
def volume
|
80
80
|
if @number && file?
|
81
|
-
|
81
|
+
Volume.count_file(File.join(@book.config['contentdir'], @path))
|
82
82
|
else
|
83
|
-
|
83
|
+
Volume.new(0, 0, 0)
|
84
84
|
end
|
85
|
-
vol
|
86
85
|
end
|
87
86
|
|
88
87
|
def file?
|
data/lib/review/book/volume.rb
CHANGED
data/lib/review/builder.rb
CHANGED
@@ -62,11 +62,11 @@ module ReVIEW
|
|
62
62
|
if @book && @book.config
|
63
63
|
@img_math ||= ReVIEW::ImgMath.new(@book.config)
|
64
64
|
if words_file_path = @book.config['words_file']
|
65
|
-
if words_file_path.is_a?(String)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
words_files = if words_file_path.is_a?(String)
|
66
|
+
[words_file_path]
|
67
|
+
else
|
68
|
+
words_file_path
|
69
|
+
end
|
70
70
|
words_files.each do |f|
|
71
71
|
load_words(f)
|
72
72
|
end
|
@@ -134,11 +134,9 @@ module ReVIEW
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def load_words(file)
|
137
|
-
if File.exist?(file)
|
138
|
-
|
139
|
-
|
140
|
-
@dictionary[row[0]] = row[1]
|
141
|
-
end
|
137
|
+
if File.exist?(file) && /\.csv\Z/i.match?(file)
|
138
|
+
CSV.foreach(file) do |row|
|
139
|
+
@dictionary[row[0]] = row[1]
|
142
140
|
end
|
143
141
|
end
|
144
142
|
end
|
@@ -537,8 +535,8 @@ module ReVIEW
|
|
537
535
|
params = metric.split(/,\s*/)
|
538
536
|
results = []
|
539
537
|
params.each do |param|
|
540
|
-
if
|
541
|
-
next unless
|
538
|
+
if /\A.+?::/.match?(param)
|
539
|
+
next unless /\A#{type}::/.match?(param)
|
542
540
|
|
543
541
|
param.sub!(/\A#{type}::/, '')
|
544
542
|
end
|
data/lib/review/catalog.rb
CHANGED
@@ -4,11 +4,11 @@ require 'date'
|
|
4
4
|
module ReVIEW
|
5
5
|
class Catalog
|
6
6
|
def initialize(file)
|
7
|
-
if file.respond_to?(:read)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
@yaml = if file.respond_to?(:read)
|
8
|
+
YAMLLoader.safe_load(file.read)
|
9
|
+
else ## as Object
|
10
|
+
file
|
11
|
+
end
|
12
12
|
@yaml ||= {}
|
13
13
|
end
|
14
14
|
|
data/lib/review/compiler.rb
CHANGED
@@ -44,7 +44,7 @@ module ReVIEW
|
|
44
44
|
|
45
45
|
def non_escaped_commands
|
46
46
|
if @builder.highlight?
|
47
|
-
%i[list emlist listnum emlistnum cmd]
|
47
|
+
%i[list emlist listnum emlistnum cmd source]
|
48
48
|
else
|
49
49
|
[]
|
50
50
|
end
|
@@ -71,7 +71,7 @@ module ReVIEW
|
|
71
71
|
attr_reader :name
|
72
72
|
|
73
73
|
def check_args(args)
|
74
|
-
unless @argc_spec === args.size
|
74
|
+
unless @argc_spec === args.size # rubocop:disable Style/CaseEquality
|
75
75
|
raise CompileError, "wrong # of parameters (block command //#{@name}, expect #{@argc_spec} but #{args.size})"
|
76
76
|
end
|
77
77
|
|
@@ -467,7 +467,7 @@ module ReVIEW
|
|
467
467
|
def compile_ulist(f)
|
468
468
|
level = 0
|
469
469
|
f.while_match(/\A\s+\*|\A\#@/) do |line|
|
470
|
-
next if
|
470
|
+
next if /\A\#@/.match?(line)
|
471
471
|
|
472
472
|
buf = [text(line.sub(/\*+/, '').strip)]
|
473
473
|
f.while_match(/\A\s+(?!\*)\S/) do |cont|
|
@@ -510,7 +510,7 @@ module ReVIEW
|
|
510
510
|
def compile_olist(f)
|
511
511
|
@builder.ol_begin
|
512
512
|
f.while_match(/\A\s+\d+\.|\A\#@/) do |line|
|
513
|
-
next if
|
513
|
+
next if /\A\#@/.match?(line)
|
514
514
|
|
515
515
|
num = line.match(/(\d+)\./)[1]
|
516
516
|
buf = [text(line.sub(/\d+\./, '').strip)]
|
@@ -572,7 +572,7 @@ module ReVIEW
|
|
572
572
|
f.until_match(%r{\A//\}}) do |line|
|
573
573
|
if ignore_inline
|
574
574
|
buf.push(line.chomp)
|
575
|
-
elsif line
|
575
|
+
elsif !/\A\#@/.match?(line)
|
576
576
|
buf.push(text(line.rstrip, true))
|
577
577
|
end
|
578
578
|
end
|
@@ -643,7 +643,7 @@ module ReVIEW
|
|
643
643
|
str.gsub(/@<(\w+)>([$|])(.+?)(\2)/) do
|
644
644
|
op = $1
|
645
645
|
arg = $3
|
646
|
-
if
|
646
|
+
if /[\x01\x02\x03\x04]/.match?(arg)
|
647
647
|
error "invalid character in '#{str}'", location: location
|
648
648
|
end
|
649
649
|
replaced = arg.tr('@', "\x01").tr('\\', "\x02").tr('{', "\x03").tr('}', "\x04")
|
@@ -671,17 +671,17 @@ module ReVIEW
|
|
671
671
|
end
|
672
672
|
result = ''
|
673
673
|
until words.empty?
|
674
|
-
if in_non_escaped_command? && block_mode
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
674
|
+
result << if in_non_escaped_command? && block_mode
|
675
|
+
revert_replace_fence(words.shift)
|
676
|
+
else
|
677
|
+
@builder.nofunc_text(revert_replace_fence(words.shift))
|
678
|
+
end
|
679
679
|
break if words.empty?
|
680
680
|
|
681
681
|
result << compile_inline(revert_replace_fence(words.shift.gsub(/\\\}/, '}').gsub(/\\\\/, '\\')))
|
682
682
|
end
|
683
683
|
result
|
684
|
-
rescue => e
|
684
|
+
rescue StandardError => e
|
685
685
|
error e.message, location: location
|
686
686
|
end
|
687
687
|
public :text # called from builder
|
@@ -696,7 +696,7 @@ module ReVIEW
|
|
696
696
|
end
|
697
697
|
|
698
698
|
@builder.__send__("inline_#{op}", arg)
|
699
|
-
rescue => e
|
699
|
+
rescue StandardError => e
|
700
700
|
error e.message, location: location
|
701
701
|
@builder.nofunc_text(str)
|
702
702
|
end
|
data/lib/review/configure.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2012-
|
2
|
+
# Copyright (c) 2012-2022 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
|
@@ -141,6 +141,9 @@ module ReVIEW
|
|
141
141
|
'force_include_images' => [],
|
142
142
|
'cover_linear' => nil,
|
143
143
|
'back_footnote' => nil
|
144
|
+
},
|
145
|
+
'textmaker' => {
|
146
|
+
'th_bold' => nil
|
144
147
|
}
|
145
148
|
]
|
146
149
|
conf.maker = nil
|
@@ -155,7 +158,7 @@ module ReVIEW
|
|
155
158
|
begin
|
156
159
|
loader = ReVIEW::YAMLLoader.new
|
157
160
|
conf.deep_merge!(loader.load_file(yamlfile))
|
158
|
-
rescue => e
|
161
|
+
rescue StandardError => e
|
159
162
|
raise ReVIEW::ConfigError, "yaml error #{e.message}"
|
160
163
|
end
|
161
164
|
end
|
data/lib/review/epub2html.rb
CHANGED
@@ -13,7 +13,7 @@ require 'review/version'
|
|
13
13
|
|
14
14
|
begin
|
15
15
|
require 'cgi/escape'
|
16
|
-
rescue
|
16
|
+
rescue StandardError
|
17
17
|
require 'cgi/util'
|
18
18
|
end
|
19
19
|
|
@@ -62,10 +62,10 @@ EOT
|
|
62
62
|
def parse_epub(epubname)
|
63
63
|
Zip::File.open(epubname) do |zio|
|
64
64
|
zio.each do |entry|
|
65
|
-
if
|
65
|
+
if /.+\.opf\Z/.match?(entry.name)
|
66
66
|
opf = entry.get_input_stream.read
|
67
67
|
@opfxml = REXML::Document.new(opf)
|
68
|
-
elsif
|
68
|
+
elsif /.+\.x?html\Z/.match?(entry.name)
|
69
69
|
@htmls[entry.name.sub('OEBPS/', '')] = entry.get_input_stream.read.force_encoding('utf-8')
|
70
70
|
end
|
71
71
|
end
|
@@ -107,15 +107,15 @@ EOT
|
|
107
107
|
end
|
108
108
|
|
109
109
|
file, anc = href.split('#', 2)
|
110
|
-
if anc
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
110
|
+
anc = if anc
|
111
|
+
if file.empty?
|
112
|
+
"#{sanitize(fname)}_#{sanitize(anc)}"
|
113
|
+
else
|
114
|
+
"#{sanitize(file)}_#{sanitize(anc)}"
|
115
|
+
end
|
116
|
+
else
|
117
|
+
sanitize(file)
|
118
|
+
end
|
119
119
|
|
120
120
|
e.attributes['href'] = "##{anc}"
|
121
121
|
end
|