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/lineinput.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright (c) 2009-2019 Minero Aoki, Kenshi Muto, Masayoshi Takahashi
|
2
|
+
# Copyright (c) 2002-2007 Minero Aoki
|
3
|
+
#
|
4
|
+
# This program is free software.
|
5
|
+
# You can distribute or modify this program under the terms of
|
6
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
7
|
+
#
|
8
|
+
|
9
|
+
module ReVIEW
|
10
|
+
class Location
|
11
|
+
def initialize(filename, f)
|
12
|
+
@filename = filename
|
13
|
+
@f = f
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :filename
|
17
|
+
|
18
|
+
def lineno
|
19
|
+
@f.lineno
|
20
|
+
end
|
21
|
+
|
22
|
+
def string
|
23
|
+
begin
|
24
|
+
"#{@filename}:#{@f.lineno}"
|
25
|
+
rescue
|
26
|
+
"#{@filename}:nil"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :to_s, :string
|
31
|
+
end
|
32
|
+
end
|
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
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2012-
|
1
|
+
# Copyright (c) 2012-2020 Yuto HAYAMIZU, Kenshi Muto
|
2
2
|
#
|
3
3
|
# This program is free software.
|
4
4
|
# You can distribute or modify this program under the terms of
|
@@ -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
|
@@ -112,6 +112,22 @@ module ReVIEW
|
|
112
112
|
\\end{document}
|
113
113
|
EOB
|
114
114
|
|
115
|
+
hashes = File.readlines(File.join(math_dir, '__IMGMATH_BODY__.map')).sort.uniq
|
116
|
+
File.write(File.join(math_dir, '__IMGMATH_BODY__.map'), hashes.join)
|
117
|
+
|
118
|
+
File.open(File.join(math_dir, '__IMGMATH_BODY__.tex'), 'w') do |f|
|
119
|
+
File.open(File.join(math_dir, '__IMGMATH_BODY__.map')) do |map|
|
120
|
+
map.each_line do |l|
|
121
|
+
l.chomp!
|
122
|
+
f.puts "% #{l}"
|
123
|
+
f.puts File.read(File.join(math_dir, "__IMGMATH_BODY__#{l}.tex"))
|
124
|
+
File.unlink(File.join(math_dir, "__IMGMATH_BODY__#{l}.tex"))
|
125
|
+
f.puts '\\clearpage'
|
126
|
+
f.puts
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
115
131
|
math_dir = File.realpath(math_dir)
|
116
132
|
Dir.mktmpdir do |tmpdir|
|
117
133
|
FileUtils.cp([File.join(math_dir, '__IMGMATH_BODY__.tex'),
|
@@ -139,8 +155,10 @@ EOB
|
|
139
155
|
FileUtils.rm_f([File.join(math_dir, '__IMGMATH_BODY__.tex'),
|
140
156
|
File.join(math_dir, '__IMGMATH_BODY__.map')])
|
141
157
|
end
|
158
|
+
module_function :make_math_images
|
142
159
|
|
143
160
|
def make_math_images_pdfcrop(dir, tex_path, math_dir)
|
161
|
+
# rubocop:disable Metrics/BlockLength
|
144
162
|
Dir.chdir(dir) do
|
145
163
|
dvi_path = '__IMGMATH__.dvi'
|
146
164
|
pdf_path = '__IMGMATH__.pdf'
|
@@ -155,7 +173,6 @@ EOB
|
|
155
173
|
raise CompileError
|
156
174
|
end
|
157
175
|
end
|
158
|
-
|
159
176
|
args = @config['imgmath_options']['pdfcrop_cmd'].shellsplit
|
160
177
|
args.map! do |m|
|
161
178
|
m.sub('%i', pdf_path).
|
@@ -201,6 +218,7 @@ EOB
|
|
201
218
|
args = @config['imgmath_options']['pdfcrop_pixelize_cmd'].shellsplit
|
202
219
|
args.map! do |m|
|
203
220
|
m.sub('%i', pdf_path2).
|
221
|
+
sub('%t', @config['imgmath_options']['format']).
|
204
222
|
sub('%o', File.join(math_dir, "_gen_#{key}.#{@config['imgmath_options']['format']}")).
|
205
223
|
sub('%O', File.join(math_dir, "_gen_#{key}")).
|
206
224
|
sub('%p', page.to_s)
|
@@ -213,6 +231,7 @@ EOB
|
|
213
231
|
end
|
214
232
|
end
|
215
233
|
end
|
234
|
+
# rubocop:enable Metrics/BlockLength
|
216
235
|
end
|
217
236
|
|
218
237
|
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,30 +65,39 @@ 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
|
|
85
|
+
def listnum_body(lines, lang)
|
86
|
+
lang ||= ''
|
87
|
+
puts "```#{lang}"
|
88
|
+
lines.each_with_index do |line, i|
|
89
|
+
puts((i + 1).to_s.rjust(2) + ": #{detab(line)}")
|
90
|
+
end
|
91
|
+
puts '```'
|
92
|
+
end
|
93
|
+
|
83
94
|
def ul_begin
|
84
95
|
blank if @ul_indent == 0
|
85
96
|
@ul_indent += 1
|
86
97
|
end
|
87
98
|
|
88
99
|
def ul_item_begin(lines)
|
89
|
-
puts ' ' * (@ul_indent - 1) + '* ' + lines
|
100
|
+
puts ' ' * (@ul_indent - 1) + '* ' + join_lines_to_paragraph(lines)
|
90
101
|
end
|
91
102
|
|
92
103
|
def ul_item_end
|
@@ -102,7 +113,7 @@ module ReVIEW
|
|
102
113
|
end
|
103
114
|
|
104
115
|
def ol_item(lines, num)
|
105
|
-
puts "#{num}. #{lines
|
116
|
+
puts "#{num}. #{join_lines_to_paragraph(lines)}"
|
106
117
|
end
|
107
118
|
|
108
119
|
def ol_end
|
@@ -118,7 +129,7 @@ module ReVIEW
|
|
118
129
|
end
|
119
130
|
|
120
131
|
def dd(lines)
|
121
|
-
puts "<dd>#{lines
|
132
|
+
puts "<dd>#{join_lines_to_paragraph(lines)}</dd>"
|
122
133
|
end
|
123
134
|
|
124
135
|
def dl_end
|
@@ -127,9 +138,9 @@ module ReVIEW
|
|
127
138
|
|
128
139
|
def emlist(lines, caption = nil, lang = nil)
|
129
140
|
blank
|
130
|
-
if caption
|
141
|
+
if caption.present?
|
131
142
|
puts caption
|
132
|
-
|
143
|
+
blank
|
133
144
|
end
|
134
145
|
lang ||= ''
|
135
146
|
puts "```#{lang}"
|
@@ -229,7 +240,11 @@ module ReVIEW
|
|
229
240
|
'jpg'
|
230
241
|
end
|
231
242
|
|
232
|
-
def cmd(lines)
|
243
|
+
def cmd(lines, caption = nil)
|
244
|
+
if caption.present?
|
245
|
+
puts caption
|
246
|
+
blank
|
247
|
+
end
|
233
248
|
puts '```shell-session'
|
234
249
|
lines.each do |line|
|
235
250
|
puts detab(line)
|
@@ -237,32 +252,12 @@ module ReVIEW
|
|
237
252
|
puts '```'
|
238
253
|
end
|
239
254
|
|
240
|
-
def
|
241
|
-
rows = []
|
242
|
-
sepidx = nil
|
243
|
-
lines.each_with_index do |line, idx|
|
244
|
-
if /\A[\=\-]{12}/ =~ line
|
245
|
-
# just ignore
|
246
|
-
# error "too many table separator" if sepidx
|
247
|
-
sepidx ||= idx
|
248
|
-
next
|
249
|
-
end
|
250
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
251
|
-
end
|
252
|
-
rows = adjust_n_cols(rows)
|
253
|
-
|
254
|
-
begin
|
255
|
-
table_header id, caption unless caption.nil?
|
256
|
-
rescue KeyError
|
257
|
-
error "no such table: #{id}"
|
258
|
-
end
|
259
|
-
table_begin rows.first.size
|
260
|
-
return if rows.empty?
|
255
|
+
def table_rows(sepidx, rows)
|
261
256
|
if sepidx
|
262
257
|
sepidx.times do
|
263
258
|
tr(rows.shift.map { |s| th(s) })
|
264
259
|
end
|
265
|
-
table_border
|
260
|
+
table_border(rows.first.size)
|
266
261
|
rows.each do |cols|
|
267
262
|
tr(cols.map { |s| td(s) })
|
268
263
|
end
|
@@ -272,7 +267,6 @@ module ReVIEW
|
|
272
267
|
tr([th(h)] + cs.map { |s| td(s) })
|
273
268
|
end
|
274
269
|
end
|
275
|
-
table_end
|
276
270
|
end
|
277
271
|
|
278
272
|
def table_header(id, caption)
|
@@ -348,7 +342,7 @@ module ReVIEW
|
|
348
342
|
return unless @book.config['draft']
|
349
343
|
lines ||= []
|
350
344
|
unless comment.blank?
|
351
|
-
lines.unshift
|
345
|
+
lines.unshift(comment)
|
352
346
|
end
|
353
347
|
str = lines.join('<br />')
|
354
348
|
puts %Q(<div class="red">#{escape(str)}</div>)
|
@@ -373,7 +367,7 @@ module ReVIEW
|
|
373
367
|
|
374
368
|
def flushright(lines)
|
375
369
|
puts %Q(<div class="flushright">)
|
376
|
-
puts lines.join
|
370
|
+
puts split_paragraph(lines).join("\n")
|
377
371
|
puts %Q(</div>)
|
378
372
|
end
|
379
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-2020 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
|
@@ -100,6 +100,7 @@ module ReVIEW
|
|
100
100
|
def parse_opts(args)
|
101
101
|
cmd_config = {}
|
102
102
|
opts = OptionParser.new
|
103
|
+
@buildonly = nil
|
103
104
|
|
104
105
|
opts.banner = 'Usage: review-pdfmaker configfile'
|
105
106
|
opts.version = ReVIEW::VERSION
|
@@ -109,6 +110,7 @@ module ReVIEW
|
|
109
110
|
end
|
110
111
|
opts.on('--[no-]debug', 'Keep temporary files.') { |debug| cmd_config['debug'] = debug }
|
111
112
|
opts.on('--ignore-errors', 'Ignore review-compile errors.') { cmd_config['ignore-errors'] = true }
|
113
|
+
opts.on('-y', '--only file1,file2,...', 'Build only specified files.') { |v| @buildonly = v.split(/\s*,\s*/).map { |m| m.strip.sub(/\.re\Z/, '') } }
|
112
114
|
|
113
115
|
opts.parse!(args)
|
114
116
|
if args.size != 1
|
@@ -153,21 +155,26 @@ module ReVIEW
|
|
153
155
|
end
|
154
156
|
|
155
157
|
begin
|
156
|
-
generate_pdf
|
158
|
+
generate_pdf
|
157
159
|
rescue ApplicationError => e
|
158
160
|
raise if @config['debug']
|
159
161
|
error(e.message)
|
160
162
|
end
|
161
163
|
end
|
162
164
|
|
163
|
-
def make_input_files(book
|
165
|
+
def make_input_files(book)
|
164
166
|
input_files = Hash.new { |h, key| h[key] = '' }
|
165
167
|
book.parts.each do |part|
|
166
168
|
if part.name.present?
|
167
169
|
@config['use_part'] = true
|
168
170
|
if part.file?
|
169
|
-
|
170
|
-
|
171
|
+
if @buildonly && !@buildonly.include?(part.name)
|
172
|
+
warn "skip #{part.name}.re"
|
173
|
+
input_files['CHAPS'] << %Q(\\part{}\n)
|
174
|
+
else
|
175
|
+
output_chaps(part.name)
|
176
|
+
input_files['CHAPS'] << %Q(\\input{#{part.name}.tex}\n)
|
177
|
+
end
|
171
178
|
else
|
172
179
|
input_files['CHAPS'] << %Q(\\part{#{part.name}}\n)
|
173
180
|
end
|
@@ -175,11 +182,18 @@ module ReVIEW
|
|
175
182
|
|
176
183
|
part.chapters.each do |chap|
|
177
184
|
filename = File.basename(chap.path, '.*')
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
185
|
+
entry = "\\input{#{filename}.tex}\n"
|
186
|
+
if @buildonly && !@buildonly.include?(filename)
|
187
|
+
warn "skip #{filename}.re"
|
188
|
+
entry = "\\chapter{}\n"
|
189
|
+
else
|
190
|
+
output_chaps(filename)
|
191
|
+
end
|
192
|
+
|
193
|
+
input_files['PREDEF'] << entry if chap.on_predef?
|
194
|
+
input_files['CHAPS'] << entry if chap.on_chaps?
|
195
|
+
input_files['APPENDIX'] << entry if chap.on_appendix?
|
196
|
+
input_files['POSTDEF'] << entry if chap.on_postdef?
|
183
197
|
end
|
184
198
|
end
|
185
199
|
|
@@ -189,7 +203,7 @@ module ReVIEW
|
|
189
203
|
def build_pdf
|
190
204
|
template = template_content
|
191
205
|
Dir.chdir(@path) do
|
192
|
-
File.open("./#{@mastertex}.tex", 'wb') { |f| f.write
|
206
|
+
File.open("./#{@mastertex}.tex", 'wb') { |f| f.write template }
|
193
207
|
|
194
208
|
call_hook('hook_beforetexcompile')
|
195
209
|
|
@@ -235,8 +249,9 @@ module ReVIEW
|
|
235
249
|
end
|
236
250
|
|
237
251
|
call_hook('hook_beforemakeindex')
|
238
|
-
if @config['pdfmaker']['makeindex'] && File.
|
252
|
+
if @config['pdfmaker']['makeindex'] && File.size?("#{@mastertex}.idx")
|
239
253
|
system_or_raise(*[makeindex_command, makeindex_options, @mastertex].flatten.compact)
|
254
|
+
system_or_raise(*[texcommand, texoptions, "#{@mastertex}.tex"].flatten.compact)
|
240
255
|
end
|
241
256
|
call_hook('hook_aftermakeindex')
|
242
257
|
|
@@ -250,18 +265,18 @@ module ReVIEW
|
|
250
265
|
end
|
251
266
|
end
|
252
267
|
|
253
|
-
def generate_pdf
|
268
|
+
def generate_pdf
|
254
269
|
remove_old_file
|
255
270
|
erb_config
|
256
271
|
@path = build_path
|
257
272
|
begin
|
258
273
|
@compile_errors = nil
|
259
274
|
|
260
|
-
book = ReVIEW::Book.load(
|
275
|
+
book = ReVIEW::Book.load(@basedir)
|
261
276
|
book.config = @config
|
262
277
|
@converter = ReVIEW::Converter.new(book, ReVIEW::LATEXBuilder.new)
|
263
278
|
|
264
|
-
@input_files = make_input_files(book
|
279
|
+
@input_files = make_input_files(book)
|
265
280
|
|
266
281
|
check_compile_status(@config['ignore-errors'])
|
267
282
|
|
@@ -281,11 +296,11 @@ module ReVIEW
|
|
281
296
|
|
282
297
|
FileUtils.cp(File.join(@path, "#{@mastertex}.pdf"), pdf_filepath)
|
283
298
|
ensure
|
284
|
-
remove_entry_secure
|
299
|
+
remove_entry_secure(@path) unless @config['debug']
|
285
300
|
end
|
286
301
|
end
|
287
302
|
|
288
|
-
def output_chaps(filename
|
303
|
+
def output_chaps(filename)
|
289
304
|
@logger.info "compiling #{filename}.tex"
|
290
305
|
begin
|
291
306
|
@converter.convert(filename + '.re', File.join(@path, filename + '.tex'))
|
@@ -454,12 +469,19 @@ module ReVIEW
|
|
454
469
|
def erb_content(file)
|
455
470
|
@texcompiler = File.basename(@config['texcommand'], '.*')
|
456
471
|
erb = ReVIEW::Template.load(file, '-')
|
457
|
-
@logger.debug
|
472
|
+
@logger.debug("erb processes #{File.basename(file)}") if @config['debug']
|
458
473
|
erb.result(binding)
|
459
474
|
end
|
460
475
|
|
461
476
|
def latex_config
|
462
|
-
erb_content(File.expand_path('./latex/config.erb', ReVIEW::Template::TEMPLATE_DIR))
|
477
|
+
result = erb_content(File.expand_path('./latex/config.erb', ReVIEW::Template::TEMPLATE_DIR))
|
478
|
+
local_config_file = File.join(@basedir, 'layouts', 'config-local.tex.erb')
|
479
|
+
if File.exist?(local_config_file)
|
480
|
+
result << "%% BEGIN: config-local.tex.erb\n"
|
481
|
+
result << erb_content(local_config_file)
|
482
|
+
result << "%% END: config-local.tex.erb\n"
|
483
|
+
end
|
484
|
+
result
|
463
485
|
end
|
464
486
|
|
465
487
|
def template_content
|
@@ -489,7 +511,7 @@ module ReVIEW
|
|
489
511
|
f.print erb_content(File.join(dirname, fname))
|
490
512
|
end
|
491
513
|
else
|
492
|
-
FileUtils.cp
|
514
|
+
FileUtils.cp(File.join(dirname, fname), copybase)
|
493
515
|
end
|
494
516
|
end
|
495
517
|
end
|