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/init.rb
CHANGED
|
@@ -18,12 +18,12 @@ module ReVIEW
|
|
|
18
18
|
new.execute(*args)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
TEX_DOCUMENTCLASS_OPTS = {
|
|
22
|
-
'review-jsbook' => 'media=print,paper=a5',
|
|
23
|
-
'review-jlreq' => 'media=print,paper=a5'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
def initialize
|
|
22
|
+
@tex_documentclass_opts = {
|
|
23
|
+
'review-jsbook' => 'media=print,paper=a5',
|
|
24
|
+
'review-jlreq' => 'media=print,paper=a5'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
27
|
@template = 'review-jsbook'
|
|
28
28
|
@logger = ReVIEW.logger
|
|
29
29
|
@review_dir = File.dirname(File.expand_path('..', __dir__))
|
|
@@ -32,15 +32,25 @@ module ReVIEW
|
|
|
32
32
|
def execute(*args)
|
|
33
33
|
initdir = parse_options(args)
|
|
34
34
|
|
|
35
|
+
if @webui
|
|
36
|
+
start_webui
|
|
37
|
+
unless @web_result
|
|
38
|
+
@logger.error 'Aborted.'
|
|
39
|
+
exit 1
|
|
40
|
+
end
|
|
41
|
+
@template = @web_result[0]
|
|
42
|
+
@tex_documentclass_opts[@template] = @web_result[1]
|
|
43
|
+
end
|
|
44
|
+
|
|
35
45
|
generate_dir(initdir) do |dir|
|
|
36
46
|
generate_catalog_file(dir)
|
|
37
47
|
generate_sample(dir)
|
|
38
48
|
generate_images_dir(dir)
|
|
39
49
|
generate_cover_image(dir)
|
|
40
|
-
generate_layout(dir)
|
|
41
50
|
generate_style(dir)
|
|
42
51
|
generate_texmacro(dir)
|
|
43
52
|
generate_config(dir)
|
|
53
|
+
generate_gitignore(dir)
|
|
44
54
|
generate_locale(dir) if @locale
|
|
45
55
|
generate_rakefile(dir)
|
|
46
56
|
generate_gemfile(dir)
|
|
@@ -50,6 +60,9 @@ module ReVIEW
|
|
|
50
60
|
end
|
|
51
61
|
|
|
52
62
|
def parse_options(args)
|
|
63
|
+
@port = 18000
|
|
64
|
+
@bind = '0'
|
|
65
|
+
|
|
53
66
|
opts = OptionParser.new
|
|
54
67
|
opts.version = ReVIEW::VERSION
|
|
55
68
|
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [option] dirname"
|
|
@@ -63,7 +76,7 @@ module ReVIEW
|
|
|
63
76
|
opts.on('-l', '--locale', 'generate locale.yml file.') do
|
|
64
77
|
@locale = true
|
|
65
78
|
end
|
|
66
|
-
opts.on('--latex-template name', 'specify LaTeX template name. (default: review-jsbook)') do |tname|
|
|
79
|
+
opts.on('-t', '--latex-template name', 'specify LaTeX template name. (default: review-jsbook)') do |tname|
|
|
67
80
|
@template = tname
|
|
68
81
|
end
|
|
69
82
|
opts.on('', '--epub-version VERSION', 'define EPUB version.') do |version|
|
|
@@ -75,6 +88,15 @@ module ReVIEW
|
|
|
75
88
|
opts.on('-p', '--package archivefile', 'extract from local or network archive.') do |archive|
|
|
76
89
|
@archive = archive
|
|
77
90
|
end
|
|
91
|
+
opts.on('-w', '--wizard', 'launch Web based layout configuration.') do
|
|
92
|
+
@webui = true
|
|
93
|
+
end
|
|
94
|
+
opts.on('', '--port port', 'port to use for Web based layout configuration. (default: 18000)') do |port|
|
|
95
|
+
@port = port
|
|
96
|
+
end
|
|
97
|
+
opts.on('', '--bind bindaddress', 'address to use for Web based layout configuration. (default: 0 (any))') do |bind|
|
|
98
|
+
@bind = bind
|
|
99
|
+
end
|
|
78
100
|
|
|
79
101
|
begin
|
|
80
102
|
opts.parse!(args)
|
|
@@ -99,7 +121,7 @@ module ReVIEW
|
|
|
99
121
|
@logger.error "#{dir} already exists."
|
|
100
122
|
exit 1
|
|
101
123
|
end
|
|
102
|
-
FileUtils.mkdir_p
|
|
124
|
+
FileUtils.mkdir_p(dir)
|
|
103
125
|
yield dir
|
|
104
126
|
end
|
|
105
127
|
|
|
@@ -109,10 +131,6 @@ module ReVIEW
|
|
|
109
131
|
end
|
|
110
132
|
end
|
|
111
133
|
|
|
112
|
-
def generate_layout(dir)
|
|
113
|
-
FileUtils.mkdir_p File.join(dir, 'layouts')
|
|
114
|
-
end
|
|
115
|
-
|
|
116
134
|
def generate_catalog_file(dir)
|
|
117
135
|
File.open(File.join(dir, 'catalog.yml'), 'w') do |file|
|
|
118
136
|
file.write <<-EOS
|
|
@@ -154,31 +172,49 @@ EOS
|
|
|
154
172
|
content.gsub!(/^#.*htmlversion:.*$/, 'htmlversion: 4')
|
|
155
173
|
end
|
|
156
174
|
|
|
157
|
-
if
|
|
158
|
-
content.gsub!(/^#\s*texdocumentclass:.*$/, %Q(texdocumentclass: ["#{@template}", "#{
|
|
175
|
+
if @tex_documentclass_opts[@template]
|
|
176
|
+
content.gsub!(/^#\s*texdocumentclass:.*$/, %Q(texdocumentclass: ["#{@template}", "#{@tex_documentclass_opts[@template]}"]))
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
File.open(File.join(dir, 'config.yml'), 'w') { |f| f.write content }
|
|
180
|
+
if @webui && !@web_result[2].empty?
|
|
181
|
+
File.open(File.join(dir, 'config-ebook.yml'), 'w') do |f|
|
|
182
|
+
f.puts <<EOT
|
|
183
|
+
# for ebook PDF
|
|
184
|
+
# REVIEW_CONFIG_FILE=config.yml rake pdf
|
|
185
|
+
inherit: ["config.yml"]
|
|
186
|
+
# bookname: book-ebook
|
|
187
|
+
texdocumentclass: ["#{@web_result[0]}", "#{@web_result[2]}"]
|
|
188
|
+
EOT
|
|
189
|
+
end
|
|
159
190
|
end
|
|
191
|
+
end
|
|
160
192
|
|
|
161
|
-
|
|
193
|
+
def generate_gitignore(dir)
|
|
194
|
+
FileUtils.cp(File.join(@review_dir, 'samples/sample-book/src/.gitignore'), dir)
|
|
162
195
|
end
|
|
163
196
|
|
|
164
197
|
def generate_style(dir)
|
|
165
|
-
FileUtils.cp
|
|
198
|
+
FileUtils.cp(File.join(@review_dir, 'samples/sample-book/src/style.css'), dir)
|
|
166
199
|
end
|
|
167
200
|
|
|
168
201
|
def generate_texmacro(dir)
|
|
169
202
|
texmacrodir = File.join(dir, 'sty')
|
|
170
|
-
FileUtils.mkdir_p
|
|
203
|
+
FileUtils.mkdir_p(texmacrodir)
|
|
171
204
|
tdir = File.join(@review_dir, 'templates/latex', @template)
|
|
172
205
|
@logger.error "#{tdir} not found." unless File.exist?(tdir)
|
|
173
|
-
FileUtils.cp
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
206
|
+
FileUtils.cp(Dir.glob(File.join(tdir, '*.*')), texmacrodir)
|
|
207
|
+
|
|
208
|
+
if @template == 'review-jsbook'
|
|
209
|
+
# provide jsbook from vendor/. current version is 2018/06/23
|
|
210
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/jsclasses/jsbook.cls'), File.join(texmacrodir, 'jsbook.cls'))
|
|
211
|
+
# provide gentombow from vendor/. current version is 2018/08/30 v0.9j
|
|
212
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/gentombow/gentombow.sty'), File.join(texmacrodir, 'gentombow.sty'))
|
|
213
|
+
end
|
|
178
214
|
end
|
|
179
215
|
|
|
180
216
|
def generate_rakefile(dir)
|
|
181
|
-
FileUtils.mkdir_p
|
|
217
|
+
FileUtils.mkdir_p(File.join(dir, 'lib/tasks'))
|
|
182
218
|
|
|
183
219
|
File.open(File.join(dir, 'Rakefile'), 'w') do |file|
|
|
184
220
|
file.write <<-EOS
|
|
@@ -193,7 +229,7 @@ EOS
|
|
|
193
229
|
end
|
|
194
230
|
|
|
195
231
|
def generate_locale(dir)
|
|
196
|
-
FileUtils.cp
|
|
232
|
+
FileUtils.cp(File.join(@review_dir, 'lib/review/i18n.yml'), File.join(dir, 'locale.yml'))
|
|
197
233
|
end
|
|
198
234
|
|
|
199
235
|
def generate_gemfile(dir)
|
|
@@ -209,9 +245,9 @@ EOS
|
|
|
209
245
|
|
|
210
246
|
def generate_doc(dir)
|
|
211
247
|
docdir = File.join(dir, 'doc')
|
|
212
|
-
FileUtils.mkdir_p
|
|
248
|
+
FileUtils.mkdir_p(docdir)
|
|
213
249
|
md_files = Dir.glob(File.join(@review_dir, 'doc/*.md')).map.to_a
|
|
214
|
-
FileUtils.cp
|
|
250
|
+
FileUtils.cp(md_files, docdir)
|
|
215
251
|
end
|
|
216
252
|
|
|
217
253
|
def download_and_extract_archive(dir, filename)
|
|
@@ -271,5 +307,53 @@ EOS
|
|
|
271
307
|
@logger.error "#{originalfilename} seems invalid or broken zip file: #{e.message}"
|
|
272
308
|
end
|
|
273
309
|
end
|
|
310
|
+
|
|
311
|
+
def start_webui
|
|
312
|
+
require 'webrick'
|
|
313
|
+
web_config = {
|
|
314
|
+
BindAddress: @bind,
|
|
315
|
+
Port: @port,
|
|
316
|
+
HTTPVersion: WEBrick::HTTPVersion.new('1.1'),
|
|
317
|
+
AccessLog: [[File.open(IO::NULL, 'w'), '']]
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
bind_address = (@bind == '0') ? '<thishost>' : @bind
|
|
321
|
+
puts "Please access http://#{bind_address}:#{web_config[:Port]} from Web browser."
|
|
322
|
+
begin
|
|
323
|
+
@web_server = WEBrick::HTTPServer.new(web_config)
|
|
324
|
+
rescue StandardError => e
|
|
325
|
+
@logger.error "Error: #{e}"
|
|
326
|
+
exit 1
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
@web_result = nil
|
|
330
|
+
web_mounts
|
|
331
|
+
|
|
332
|
+
trap(:INT) { @web_server.shutdown }
|
|
333
|
+
@web_server.start
|
|
334
|
+
|
|
335
|
+
# validation
|
|
336
|
+
if @web_result
|
|
337
|
+
@web_result.each do |s|
|
|
338
|
+
if s !~ /\A[a-z0-9=_,\.-]*\Z/i
|
|
339
|
+
@web_result = nil
|
|
340
|
+
break
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
end
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def web_mounts
|
|
347
|
+
htmldir = File.join(@review_dir, 'lib', 'review', 'init-web')
|
|
348
|
+
@web_server.mount('/', WEBrick::HTTPServlet::FileHandler, File.join(htmldir, 'index.html'))
|
|
349
|
+
@web_server.mount('/review-layout-design.js', WEBrick::HTTPServlet::FileHandler, File.join(htmldir, 'review-layout-design.js'))
|
|
350
|
+
|
|
351
|
+
@web_server.mount_proc('/finish') do |req, res|
|
|
352
|
+
@web_result = [req.query['cls'], req.query['result_print'], req.query['result_ebook']]
|
|
353
|
+
res.content_type = 'text/html'
|
|
354
|
+
res.body = File.read(File.join(htmldir, 'finish.html'))
|
|
355
|
+
@web_server.shutdown
|
|
356
|
+
end
|
|
357
|
+
end
|
|
274
358
|
end
|
|
275
359
|
end
|
data/lib/review/latexbuilder.rb
CHANGED
|
@@ -32,7 +32,6 @@ module ReVIEW
|
|
|
32
32
|
@blank_needed = false
|
|
33
33
|
@latex_tsize = nil
|
|
34
34
|
@tsize = nil
|
|
35
|
-
@table_caption = nil
|
|
36
35
|
@cellwidth = nil
|
|
37
36
|
@ol_num = nil
|
|
38
37
|
@first_line_num = nil
|
|
@@ -257,7 +256,11 @@ module ReVIEW
|
|
|
257
256
|
end
|
|
258
257
|
|
|
259
258
|
def ul_item(lines)
|
|
260
|
-
str = lines
|
|
259
|
+
str = join_lines_to_paragraph(lines)
|
|
260
|
+
unless @book.config['join_lines_by_lang']
|
|
261
|
+
str = lines.map(&:chomp).join("\n")
|
|
262
|
+
end
|
|
263
|
+
|
|
261
264
|
str.sub!(/\A(\[)/) { '\lbrack{}' }
|
|
262
265
|
puts '\item ' + str
|
|
263
266
|
end
|
|
@@ -276,7 +279,11 @@ module ReVIEW
|
|
|
276
279
|
end
|
|
277
280
|
|
|
278
281
|
def ol_item(lines, _num)
|
|
279
|
-
str = lines
|
|
282
|
+
str = join_lines_to_paragraph(lines)
|
|
283
|
+
unless @book.config['join_lines_by_lang']
|
|
284
|
+
str = lines.map(&:chomp).join("\n")
|
|
285
|
+
end
|
|
286
|
+
|
|
280
287
|
str.sub!(/\A(\[)/) { '\lbrack{}' }
|
|
281
288
|
puts '\item ' + str
|
|
282
289
|
end
|
|
@@ -298,7 +305,11 @@ module ReVIEW
|
|
|
298
305
|
end
|
|
299
306
|
|
|
300
307
|
def dd(lines)
|
|
301
|
-
|
|
308
|
+
if @book.config['join_lines_by_lang']
|
|
309
|
+
puts join_lines_to_paragraph(lines)
|
|
310
|
+
else
|
|
311
|
+
puts lines.map(&:chomp).join("\n")
|
|
312
|
+
end
|
|
302
313
|
end
|
|
303
314
|
|
|
304
315
|
def dl_end
|
|
@@ -308,8 +319,10 @@ module ReVIEW
|
|
|
308
319
|
|
|
309
320
|
def paragraph(lines)
|
|
310
321
|
blank
|
|
311
|
-
|
|
312
|
-
puts
|
|
322
|
+
if @book.config['join_lines_by_lang']
|
|
323
|
+
puts join_lines_to_paragraph(lines)
|
|
324
|
+
else
|
|
325
|
+
lines.each { |line| puts line }
|
|
313
326
|
end
|
|
314
327
|
blank
|
|
315
328
|
end
|
|
@@ -319,22 +332,35 @@ module ReVIEW
|
|
|
319
332
|
end
|
|
320
333
|
|
|
321
334
|
def read(lines)
|
|
322
|
-
latex_block
|
|
335
|
+
latex_block('quotation', lines)
|
|
323
336
|
end
|
|
324
337
|
|
|
325
338
|
alias_method :lead, :read
|
|
326
339
|
|
|
340
|
+
def highlight?
|
|
341
|
+
@book.config['highlight'] &&
|
|
342
|
+
@book.config['highlight']['latex']
|
|
343
|
+
end
|
|
344
|
+
|
|
327
345
|
def highlight_listings?
|
|
328
346
|
@book.config['highlight'] && @book.config['highlight']['latex'] == 'listings'
|
|
329
347
|
end
|
|
330
348
|
private :highlight_listings?
|
|
331
349
|
|
|
350
|
+
def code_line(_type, line, _idx, _id, _caption, _lang)
|
|
351
|
+
detab(line) + "\n"
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def code_line_num(_type, line, first_line_num, idx, _id, _caption, _lang)
|
|
355
|
+
detab((idx + first_line_num).to_s.rjust(2) + ': ' + line) + "\n"
|
|
356
|
+
end
|
|
357
|
+
|
|
332
358
|
def emlist(lines, caption = nil, lang = nil)
|
|
333
359
|
blank
|
|
334
360
|
if highlight_listings?
|
|
335
361
|
common_code_block_lst(nil, lines, 'reviewemlistlst', 'title', caption, lang)
|
|
336
362
|
else
|
|
337
|
-
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line,
|
|
363
|
+
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line, idx| code_line('emlist', line, idx, nil, caption, lang) }
|
|
338
364
|
end
|
|
339
365
|
end
|
|
340
366
|
|
|
@@ -344,7 +370,7 @@ module ReVIEW
|
|
|
344
370
|
if highlight_listings?
|
|
345
371
|
common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang, first_line_num: first_line_num)
|
|
346
372
|
else
|
|
347
|
-
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line, idx|
|
|
373
|
+
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line, idx| code_line_num('emlistnum', line, first_line_num, idx, nil, caption, lang) }
|
|
348
374
|
end
|
|
349
375
|
end
|
|
350
376
|
|
|
@@ -353,7 +379,7 @@ module ReVIEW
|
|
|
353
379
|
if highlight_listings?
|
|
354
380
|
common_code_block_lst(id, lines, 'reviewlistlst', 'caption', caption, lang)
|
|
355
381
|
else
|
|
356
|
-
common_code_block(id, lines, 'reviewlist', caption, lang) { |line,
|
|
382
|
+
common_code_block(id, lines, 'reviewlist', caption, lang) { |line, idx| code_line('list', line, idx, id, caption, lang) }
|
|
357
383
|
end
|
|
358
384
|
end
|
|
359
385
|
|
|
@@ -363,7 +389,7 @@ module ReVIEW
|
|
|
363
389
|
if highlight_listings?
|
|
364
390
|
common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang, first_line_num: first_line_num)
|
|
365
391
|
else
|
|
366
|
-
common_code_block(id, lines, 'reviewlist', caption, lang) { |line, idx|
|
|
392
|
+
common_code_block(id, lines, 'reviewlist', caption, lang) { |line, idx| code_line_num('listnum', line, first_line_num, idx, id, caption, lang) }
|
|
367
393
|
end
|
|
368
394
|
end
|
|
369
395
|
|
|
@@ -372,7 +398,7 @@ module ReVIEW
|
|
|
372
398
|
common_code_block_lst(nil, lines, 'reviewcmdlst', 'title', caption, lang)
|
|
373
399
|
else
|
|
374
400
|
blank
|
|
375
|
-
common_code_block(nil, lines, 'reviewcmd', caption, lang) { |line,
|
|
401
|
+
common_code_block(nil, lines, 'reviewcmd', caption, lang) { |line, idx| code_line('cmd', line, idx, nil, caption, lang) }
|
|
376
402
|
end
|
|
377
403
|
end
|
|
378
404
|
|
|
@@ -414,7 +440,7 @@ module ReVIEW
|
|
|
414
440
|
if title == 'title' && caption.blank? && @book.config.check_version('2', exception: false)
|
|
415
441
|
print '\vspace{-1.5em}'
|
|
416
442
|
end
|
|
417
|
-
body = lines.inject('') { |i, j| i + detab(
|
|
443
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
|
418
444
|
args = make_code_block_args(title, caption, lang, first_line_num: first_line_num)
|
|
419
445
|
puts %Q(\\begin{#{command}}[#{args}])
|
|
420
446
|
print body
|
|
@@ -449,7 +475,7 @@ module ReVIEW
|
|
|
449
475
|
if highlight_listings?
|
|
450
476
|
common_code_block_lst(nil, lines, 'reviewsourcelst', 'title', caption, lang)
|
|
451
477
|
else
|
|
452
|
-
common_code_block(nil, lines, 'reviewsource', caption, lang) { |line,
|
|
478
|
+
common_code_block(nil, lines, 'reviewsource', caption, lang) { |line, idx| code_line('source', line, idx, nil, caption, lang) }
|
|
453
479
|
end
|
|
454
480
|
end
|
|
455
481
|
|
|
@@ -514,7 +540,7 @@ module ReVIEW
|
|
|
514
540
|
end
|
|
515
541
|
|
|
516
542
|
def existence(id)
|
|
517
|
-
@chapter.
|
|
543
|
+
@chapter.image_bound?(id) ? 'exist' : 'not exist'
|
|
518
544
|
end
|
|
519
545
|
private :existence
|
|
520
546
|
|
|
@@ -594,26 +620,30 @@ module ReVIEW
|
|
|
594
620
|
alias_method :numberlessimage, :indepimage
|
|
595
621
|
|
|
596
622
|
def table(lines, id = nil, caption = nil)
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
# error "too many table separator" if sepidx
|
|
603
|
-
sepidx ||= idx
|
|
604
|
-
next
|
|
623
|
+
if caption.present?
|
|
624
|
+
if @book.config.check_version('2', exception: false)
|
|
625
|
+
puts "\\begin{table}[h]%%#{id}"
|
|
626
|
+
else
|
|
627
|
+
puts "\\begin{table}%%#{id}"
|
|
605
628
|
end
|
|
606
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
|
607
629
|
end
|
|
608
|
-
rows = adjust_n_cols(rows)
|
|
609
|
-
error 'no rows in the table' if rows.empty?
|
|
610
630
|
|
|
631
|
+
sepidx, rows = parse_table_rows(lines)
|
|
611
632
|
begin
|
|
612
633
|
table_header(id, caption) if caption.present?
|
|
613
634
|
rescue KeyError
|
|
614
635
|
error "no such table: #{id}"
|
|
615
636
|
end
|
|
616
637
|
table_begin(rows.first.size)
|
|
638
|
+
table_rows(sepidx, rows)
|
|
639
|
+
table_end
|
|
640
|
+
if caption.present?
|
|
641
|
+
puts '\end{table}'
|
|
642
|
+
end
|
|
643
|
+
blank
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
def table_rows(sepidx, rows)
|
|
617
647
|
if sepidx
|
|
618
648
|
sepidx.times do
|
|
619
649
|
cno = -1
|
|
@@ -640,31 +670,18 @@ module ReVIEW
|
|
|
640
670
|
end)
|
|
641
671
|
end
|
|
642
672
|
end
|
|
643
|
-
table_end
|
|
644
673
|
end
|
|
645
674
|
|
|
646
675
|
def table_header(id, caption)
|
|
647
676
|
if id.nil?
|
|
648
677
|
if caption.present?
|
|
649
|
-
@table_caption = true
|
|
650
678
|
@doc_status[:caption] = true
|
|
651
|
-
if @book.config.check_version('2', exception: false)
|
|
652
|
-
puts "\\begin{table}[h]%%#{id}"
|
|
653
|
-
else
|
|
654
|
-
puts "\\begin{table}%%#{id}"
|
|
655
|
-
end
|
|
656
679
|
puts macro('reviewtablecaption*', compile_inline(caption))
|
|
657
680
|
@doc_status[:caption] = nil
|
|
658
681
|
end
|
|
659
682
|
else
|
|
660
683
|
if caption.present?
|
|
661
|
-
@table_caption = true
|
|
662
684
|
@doc_status[:caption] = true
|
|
663
|
-
if @book.config.check_version('2', exception: false)
|
|
664
|
-
puts "\\begin{table}[h]%%#{id}"
|
|
665
|
-
else
|
|
666
|
-
puts "\\begin{table}%%#{id}"
|
|
667
|
-
end
|
|
668
685
|
puts macro('reviewtablecaption', compile_inline(caption))
|
|
669
686
|
@doc_status[:caption] = nil
|
|
670
687
|
end
|
|
@@ -767,12 +784,9 @@ module ReVIEW
|
|
|
767
784
|
|
|
768
785
|
def table_end
|
|
769
786
|
puts macro('end', 'reviewtable')
|
|
770
|
-
puts '\end{table}' if @table_caption
|
|
771
|
-
@table_caption = nil
|
|
772
787
|
@tsize = nil
|
|
773
788
|
@latex_tsize = nil
|
|
774
789
|
@cellwidth = nil
|
|
775
|
-
blank
|
|
776
790
|
end
|
|
777
791
|
|
|
778
792
|
def emtable(lines, caption = nil)
|
|
@@ -780,17 +794,16 @@ module ReVIEW
|
|
|
780
794
|
end
|
|
781
795
|
|
|
782
796
|
def imgtable(lines, id, caption = nil, metric = nil)
|
|
783
|
-
unless @chapter.
|
|
797
|
+
unless @chapter.image_bound?(id)
|
|
784
798
|
warn "image not bound: #{id}"
|
|
785
|
-
image_dummy
|
|
799
|
+
image_dummy(id, caption, lines)
|
|
786
800
|
return
|
|
787
801
|
end
|
|
788
802
|
|
|
789
803
|
begin
|
|
790
804
|
if caption.present?
|
|
791
|
-
@table_caption = true
|
|
792
|
-
@doc_status[:caption] = true
|
|
793
805
|
puts "\\begin{table}[h]%%#{id}"
|
|
806
|
+
@doc_status[:caption] = true
|
|
794
807
|
puts macro('reviewimgtablecaption', compile_inline(caption))
|
|
795
808
|
@doc_status[:caption] = nil
|
|
796
809
|
end
|
|
@@ -800,8 +813,9 @@ module ReVIEW
|
|
|
800
813
|
end
|
|
801
814
|
imgtable_image(id, caption, metric)
|
|
802
815
|
|
|
803
|
-
|
|
804
|
-
|
|
816
|
+
if caption.present?
|
|
817
|
+
puts '\end{table}'
|
|
818
|
+
end
|
|
805
819
|
blank
|
|
806
820
|
end
|
|
807
821
|
|
|
@@ -824,17 +838,17 @@ module ReVIEW
|
|
|
824
838
|
end
|
|
825
839
|
|
|
826
840
|
def quote(lines)
|
|
827
|
-
latex_block
|
|
841
|
+
latex_block('quote', lines)
|
|
828
842
|
end
|
|
829
843
|
|
|
830
844
|
def center(lines)
|
|
831
|
-
latex_block
|
|
845
|
+
latex_block('center', lines)
|
|
832
846
|
end
|
|
833
847
|
|
|
834
848
|
alias_method :centering, :center
|
|
835
849
|
|
|
836
850
|
def flushright(lines)
|
|
837
|
-
latex_block
|
|
851
|
+
latex_block('flushright', lines)
|
|
838
852
|
end
|
|
839
853
|
|
|
840
854
|
def texequation(lines, id = nil, caption = '')
|
|
@@ -851,7 +865,7 @@ module ReVIEW
|
|
|
851
865
|
|
|
852
866
|
puts macro('begin', 'equation*')
|
|
853
867
|
lines.each do |line|
|
|
854
|
-
puts
|
|
868
|
+
puts line
|
|
855
869
|
end
|
|
856
870
|
puts macro('end', 'equation*')
|
|
857
871
|
|
|
@@ -883,7 +897,7 @@ module ReVIEW
|
|
|
883
897
|
return true unless @book.config['draft']
|
|
884
898
|
lines ||= []
|
|
885
899
|
unless comment.blank?
|
|
886
|
-
lines.unshift
|
|
900
|
+
lines.unshift(escape(comment))
|
|
887
901
|
end
|
|
888
902
|
str = lines.join('\par ')
|
|
889
903
|
puts macro('pdfcomment', str)
|
|
@@ -995,6 +1009,9 @@ module ReVIEW
|
|
|
995
1009
|
|
|
996
1010
|
def footnote(id, content)
|
|
997
1011
|
if @book.config['footnotetext'] || @foottext[id]
|
|
1012
|
+
if @doc_status[:column]
|
|
1013
|
+
warn "//footnote[#{id}] is in the column block. It is recommended to move out of the column block."
|
|
1014
|
+
end
|
|
998
1015
|
puts macro("footnotetext[#{@chapter.footnote(id).number}]", compile_inline(content.strip))
|
|
999
1016
|
end
|
|
1000
1017
|
end
|
|
@@ -1215,7 +1232,12 @@ module ReVIEW
|
|
|
1215
1232
|
end
|
|
1216
1233
|
|
|
1217
1234
|
def bibpaper_bibpaper(_id, _caption, lines)
|
|
1218
|
-
|
|
1235
|
+
if @book.config['join_lines_by_lang']
|
|
1236
|
+
print split_paragraph(lines).join("\n\n")
|
|
1237
|
+
else
|
|
1238
|
+
print split_paragraph(lines).map(&:chomp).join("\n")
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1219
1241
|
puts ''
|
|
1220
1242
|
end
|
|
1221
1243
|
|