review 4.0.0 → 5.1.1
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 +31 -0
- data/.github/workflows/ruby-win.yml +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +141 -38
- data/Dockerfile +21 -5
- data/NEWS.ja.md +338 -1
- data/NEWS.md +339 -2
- data/README.md +11 -7
- data/Rakefile +7 -2
- data/appveyor.yml +0 -20
- data/bin/review +2 -4
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -12
- data/bin/review-checkdep +2 -5
- data/bin/review-compile +11 -20
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +5 -86
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +3 -5
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +5 -5
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +55 -12
- data/doc/config.yml.sample-simple +4 -3
- data/doc/format.ja.md +119 -17
- data/doc/format.md +106 -17
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +42 -0
- data/doc/pdfmaker.md +41 -0
- data/doc/quickstart.ja.md +55 -25
- data/doc/quickstart.md +47 -17
- data/lib/review.rb +1 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +69 -30
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +33 -26
- data/lib/review/book/index.rb +39 -206
- data/lib/review/book/index/item.rb +8 -2
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +26 -11
- data/lib/review/book/volume.rb +5 -5
- data/lib/review/builder.rb +124 -27
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +3 -2
- data/lib/review/compiler.rb +197 -91
- data/lib/review/configure.rb +95 -9
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +116 -117
- data/lib/review/epubmaker/content.rb +113 -0
- data/lib/review/epubmaker/epubcommon.rb +372 -0
- data/lib/review/epubmaker/epubv2.rb +178 -0
- data/lib/review/epubmaker/epubv3.rb +231 -0
- data/lib/review/epubmaker/producer.rb +168 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/exception.rb +6 -0
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +132 -87
- data/lib/review/htmlutils.rb +8 -11
- data/lib/review/i18n.rb +2 -1
- data/lib/review/idgxmlbuilder.rb +156 -76
- data/lib/review/idgxmlmaker.rb +22 -18
- data/lib/review/img_math.rb +245 -0
- data/lib/review/index_builder.rb +654 -0
- data/lib/review/init.rb +17 -18
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +173 -43
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/logger.rb +42 -3
- data/lib/review/makerhelper.rb +12 -187
- data/lib/review/markdownbuilder.rb +51 -2
- data/lib/review/pdfmaker.rb +78 -73
- data/lib/review/plaintextbuilder.rb +98 -14
- data/lib/review/preprocessor.rb +18 -12
- data/lib/review/rstbuilder.rb +28 -9
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +6 -0
- data/lib/review/textmaker.rb +21 -19
- data/lib/review/textutils.rb +3 -12
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +91 -24
- data/lib/review/update.rb +12 -13
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +34 -33
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +2 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/.gitignore +1 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config.yml +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +26 -6
- data/samples/syntax-book/Gemfile +1 -1
- data/samples/syntax-book/ch01.re +3 -1
- data/samples/syntax-book/ch02.re +28 -21
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/review.rake +23 -8
- data/templates/html/_colophon.html.erb +23 -0
- data/templates/html/_colophon_history.html.erb +9 -0
- data/templates/html/_cover.html.erb +10 -0
- data/templates/html/_part_body.html.erb +6 -0
- data/templates/html/_titlepage.html.erb +20 -0
- data/templates/html/layout-html5.html.erb +6 -0
- data/templates/html/layout-xhtml1.html.erb +6 -0
- data/templates/latex/config.erb +41 -29
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +47 -22
- data/templates/latex/review-jlreq/review-jlreq.cls +25 -24
- data/templates/latex/review-jlreq/review-style.sty +6 -1
- data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
- data/templates/latex/review-jsbook/README.md +7 -5
- data/templates/latex/review-jsbook/review-base.sty +47 -21
- data/templates/latex/review-jsbook/review-jsbook.cls +12 -2
- data/templates/latex/review-jsbook/review-style.sty +6 -1
- data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
- data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
- data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
- data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
- data/templates/web/html/layout-html5.html.erb +9 -8
- data/templates/web/html/layout-xhtml1.html.erb +6 -0
- data/test/assets/header_listener.html +35 -0
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/syntax_book_index_detail.txt +58 -0
- data/test/assets/test_template.tex +12 -9
- data/test/assets/test_template_backmatter.tex +12 -9
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +62 -63
- data/test/test_book_chapter.rb +99 -56
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +24 -15
- data/test/test_catalog.rb +1 -0
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +170 -126
- data/test/test_epubmaker.rb +249 -129
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +23 -11
- data/test/test_htmlbuilder.rb +956 -76
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +568 -10
- data/test/test_idgxmlmaker_cmd.rb +50 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +62 -52
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +1056 -30
- data/test/test_latexbuilder_v2.rb +52 -12
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +7 -7
- data/test/test_makerhelper.rb +0 -12
- data/test/test_markdownbuilder.rb +32 -0
- data/test/test_pdfmaker.rb +100 -11
- data/test/test_pdfmaker_cmd.rb +101 -7
- data/test/test_plaintextbuilder.rb +531 -25
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +25 -1
- data/test/test_sec_counter.rb +156 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +58 -0
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +365 -10
- data/test/test_update.rb +44 -44
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_zip_exporter.rb +5 -6
- data/vendor/gentombow/LICENSE +1 -1
- data/vendor/gentombow/Makefile +0 -1
- data/vendor/gentombow/bounddvi-en.pdf +0 -0
- data/vendor/gentombow/bounddvi-en.tex +1 -0
- data/vendor/gentombow/bounddvi.pdf +0 -0
- data/vendor/gentombow/bounddvi.sty +30 -7
- data/vendor/gentombow/bounddvi.tex +1 -0
- data/vendor/gentombow/create_archive.sh +1 -0
- data/vendor/gentombow/gentombow-ja.pdf +0 -0
- data/vendor/gentombow/gentombow-ja.tex +9 -0
- data/vendor/gentombow/gentombow.pdf +0 -0
- data/vendor/gentombow/gentombow.sty +32 -10
- data/vendor/gentombow/gentombow.tex +8 -0
- data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
- data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +74 -31
- data/vendor/jsclasses/jis/jsbook.cls +74 -31
- data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +4 -16
- data/vendor/jsclasses/jis/jspf.cls +73 -30
- data/vendor/jsclasses/jis/jsreport.cls +74 -31
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +74 -31
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +4 -17
- data/vendor/jsclasses/jis/okuverb.ins +9 -0
- data/vendor/jsclasses/jis/okuverb.sty +1 -13
- data/vendor/jsclasses/jis/winjis.sty +23 -19
- data/vendor/jsclasses/jsarticle.cls +74 -31
- data/vendor/jsclasses/jsbook.cls +74 -31
- data/vendor/jsclasses/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +4 -16
- data/vendor/jsclasses/jspf.cls +73 -30
- data/vendor/jsclasses/jsreport.cls +74 -31
- data/vendor/jsclasses/jsverb.ins +9 -0
- data/vendor/jsclasses/jsverb.pdf +0 -0
- data/vendor/jsclasses/jsverb.sty +1 -13
- data/vendor/jsclasses/kiyou.cls +74 -31
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +4 -17
- data/vendor/jsclasses/okuverb.ins +9 -0
- data/vendor/jsclasses/okuverb.pdf +0 -0
- data/vendor/jsclasses/okuverb.sty +1 -13
- data/vendor/jsclasses/tests/relfont.tex +10 -0
- data/vendor/jsclasses/winjis.sty +23 -19
- metadata +109 -20
- data/.rubocop_todo.yml +0 -7
- data/lib/epubmaker.rb +0 -23
- data/lib/epubmaker/content.rb +0 -110
- data/lib/epubmaker/epubcommon.rb +0 -441
- data/lib/epubmaker/epubv2.rb +0 -143
- data/lib/epubmaker/epubv3.rb +0 -233
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/lineinput.rb +0 -155
- data/lib/review/book/compilable.rb +0 -178
- 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/init.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2018-
|
2
|
+
# Copyright (c) 2018-2021 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
|
@@ -82,6 +82,9 @@ module ReVIEW
|
|
82
82
|
opts.on('', '--epub-version VERSION', 'define EPUB version.') do |version|
|
83
83
|
@epub_version = version
|
84
84
|
end
|
85
|
+
opts.on('', '--without-config-comment', "don't include comments in config.yml.") do
|
86
|
+
@without_config_comment = true
|
87
|
+
end
|
85
88
|
opts.on('', '--without-doc', "don't generate doc files.") do
|
86
89
|
@without_doc = true
|
87
90
|
end
|
@@ -111,9 +114,7 @@ module ReVIEW
|
|
111
114
|
exit 1
|
112
115
|
end
|
113
116
|
|
114
|
-
|
115
|
-
|
116
|
-
initdir
|
117
|
+
File.expand_path(args[0])
|
117
118
|
end
|
118
119
|
|
119
120
|
def generate_dir(dir)
|
@@ -132,8 +133,7 @@ module ReVIEW
|
|
132
133
|
end
|
133
134
|
|
134
135
|
def generate_catalog_file(dir)
|
135
|
-
File.
|
136
|
-
file.write <<-EOS
|
136
|
+
File.write(File.join(dir, 'catalog.yml'), <<-EOS)
|
137
137
|
PREDEF:
|
138
138
|
|
139
139
|
CHAPS:
|
@@ -144,7 +144,6 @@ APPENDIX:
|
|
144
144
|
POSTDEF:
|
145
145
|
|
146
146
|
EOS
|
147
|
-
end
|
148
147
|
end
|
149
148
|
|
150
149
|
def generate_images_dir(dir)
|
@@ -176,6 +175,10 @@ EOS
|
|
176
175
|
content.gsub!(/^#\s*texdocumentclass:.*$/, %Q(texdocumentclass: ["#{@template}", "#{@tex_documentclass_opts[@template]}"]))
|
177
176
|
end
|
178
177
|
|
178
|
+
if @without_config_comment
|
179
|
+
content = content.split("\n").delete_if { |l| l.strip.start_with?('#') || l.strip.empty? }.join("\n")
|
180
|
+
end
|
181
|
+
|
179
182
|
File.open(File.join(dir, 'config.yml'), 'w') { |f| f.write content }
|
180
183
|
if @webui && !@web_result[2].empty?
|
181
184
|
File.open(File.join(dir, 'config-ebook.yml'), 'w') do |f|
|
@@ -206,9 +209,9 @@ EOT
|
|
206
209
|
FileUtils.cp(Dir.glob(File.join(tdir, '*.*')), texmacrodir)
|
207
210
|
|
208
211
|
if @template == 'review-jsbook'
|
209
|
-
# provide jsbook from vendor/. current version is
|
212
|
+
# provide jsbook from vendor/. current version is 2020/10/09
|
210
213
|
FileUtils.cp(File.join(@review_dir, 'vendor/jsclasses/jsbook.cls'), File.join(texmacrodir, 'jsbook.cls'))
|
211
|
-
# provide gentombow from vendor/. current version is
|
214
|
+
# provide gentombow from vendor/. current version is 2019/07/21 v0.9k
|
212
215
|
FileUtils.cp(File.join(@review_dir, 'vendor/gentombow/gentombow.sty'), File.join(texmacrodir, 'gentombow.sty'))
|
213
216
|
end
|
214
217
|
end
|
@@ -216,13 +219,11 @@ EOT
|
|
216
219
|
def generate_rakefile(dir)
|
217
220
|
FileUtils.mkdir_p(File.join(dir, 'lib/tasks'))
|
218
221
|
|
219
|
-
File.
|
220
|
-
file.write <<-EOS
|
222
|
+
File.write(File.join(dir, 'Rakefile'), <<-EOS)
|
221
223
|
Dir.glob('lib/tasks/*.rake').sort.each do |file|
|
222
224
|
load(file)
|
223
225
|
end
|
224
226
|
EOS
|
225
|
-
end
|
226
227
|
|
227
228
|
FileUtils.cp(File.join(@review_dir, 'samples/sample-book/src/lib/tasks/review.rake'),
|
228
229
|
File.join(dir, 'lib/tasks/review.rake'))
|
@@ -233,14 +234,12 @@ EOS
|
|
233
234
|
end
|
234
235
|
|
235
236
|
def generate_gemfile(dir)
|
236
|
-
File.
|
237
|
-
file.write <<-EOS
|
237
|
+
File.write(File.join(dir, 'Gemfile'), <<-EOS)
|
238
238
|
source 'https://rubygems.org'
|
239
239
|
|
240
240
|
gem 'rake'
|
241
241
|
gem 'review', '#{ReVIEW::VERSION}'
|
242
242
|
EOS
|
243
|
-
end
|
244
243
|
end
|
245
244
|
|
246
245
|
def generate_doc(dir)
|
@@ -287,12 +286,12 @@ EOS
|
|
287
286
|
begin
|
288
287
|
Zip::File.open(filename) do |zip|
|
289
288
|
zip.each do |entry|
|
290
|
-
fname = entry.name.
|
289
|
+
fname = entry.name.tr('\\', '/')
|
291
290
|
if fname =~ /__MACOSX/ || fname =~ /\.DS_Store/
|
292
291
|
next
|
293
292
|
end
|
294
293
|
|
295
|
-
if fname
|
294
|
+
if fname.start_with?('/') || fname =~ /\.\./ # simple fool proof
|
296
295
|
made = nil
|
297
296
|
break
|
298
297
|
end
|
@@ -335,7 +334,7 @@ EOS
|
|
335
334
|
# validation
|
336
335
|
if @web_result
|
337
336
|
@web_result.each do |s|
|
338
|
-
if s !~ /\A[a-z0-9=_
|
337
|
+
if s !~ /\A[a-z0-9=_,.-]*\Z/i
|
339
338
|
@web_result = nil
|
340
339
|
break
|
341
340
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Copyright (c) 2021 Kenshi Muto
|
2
|
+
#
|
3
|
+
# This program is free software.
|
4
|
+
# You can distribute or modify this program under the terms of
|
5
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
6
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
7
|
+
#
|
8
|
+
require 'review/logger'
|
9
|
+
module ReVIEW
|
10
|
+
class LaTeXBox
|
11
|
+
def initialize
|
12
|
+
@logger = ReVIEW.logger
|
13
|
+
end
|
14
|
+
|
15
|
+
def tcbox(config)
|
16
|
+
ret = ''
|
17
|
+
|
18
|
+
%w[column note memo tip info warning important caution notice].each do |name|
|
19
|
+
if config['pdfmaker'].nil? || config['pdfmaker']['boxsetting'].nil? ||
|
20
|
+
config['pdfmaker']['boxsetting'][name].nil? ||
|
21
|
+
config['pdfmaker']['boxsetting'][name]['style'].nil?
|
22
|
+
next
|
23
|
+
end
|
24
|
+
|
25
|
+
options = '[]'
|
26
|
+
options_with_caption = '[]'
|
27
|
+
if config['pdfmaker']['boxsetting'][name]['options']
|
28
|
+
options = "[#{config['pdfmaker']['boxsetting'][name]['options']}]"
|
29
|
+
options_with_caption = options
|
30
|
+
end
|
31
|
+
|
32
|
+
if config['pdfmaker']['boxsetting'][name]['options_with_caption']
|
33
|
+
options_with_caption = "[#{config['pdfmaker']['boxsetting'][name]['options_with_caption']}]"
|
34
|
+
end
|
35
|
+
|
36
|
+
ret << <<EOT
|
37
|
+
\\renewenvironment{review#{name}}[1][]{%
|
38
|
+
\\csdef{rv@tmp@withcaption}{true}
|
39
|
+
\\notblank{##1}{
|
40
|
+
\\begin{rv@#{config['pdfmaker']['boxsetting'][name]['style']}@caption}{##1}#{options_with_caption}
|
41
|
+
}{
|
42
|
+
\\csundef{rv@tmp@withcaption}
|
43
|
+
\\begin{rv@#{config['pdfmaker']['boxsetting'][name]['style']}@nocaption}#{options}
|
44
|
+
}
|
45
|
+
}{
|
46
|
+
\\ifcsdef{rv@tmp@withcaption}{
|
47
|
+
\\end{rv@#{config['pdfmaker']['boxsetting'][name]['style']}@caption}
|
48
|
+
}{
|
49
|
+
\\end{rv@#{config['pdfmaker']['boxsetting'][name]['style']}@nocaption}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
EOT
|
53
|
+
end
|
54
|
+
|
55
|
+
ret
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/review/latexbuilder.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (c) 2002-2007 Minero Aoki
|
2
2
|
# 2008-2009 Minero Aoki, Kenshi Muto
|
3
|
-
# 2010-
|
3
|
+
# 2010-2021 Minero Aoki, Kenshi Muto, TAKAHASHI Masayoshi
|
4
4
|
#
|
5
5
|
# This program is free software.
|
6
6
|
# You can distribute or modify this program under the terms of
|
@@ -51,6 +51,7 @@ module ReVIEW
|
|
51
51
|
@index_db = load_idxdb(@book.config['pdfmaker']['makeindex_dic'])
|
52
52
|
end
|
53
53
|
return true unless @book.config['pdfmaker']['makeindex_mecab']
|
54
|
+
|
54
55
|
begin
|
55
56
|
begin
|
56
57
|
require 'MeCab'
|
@@ -60,7 +61,7 @@ module ReVIEW
|
|
60
61
|
require 'nkf'
|
61
62
|
@index_mecab = MeCab::Tagger.new(@book.config['pdfmaker']['makeindex_mecab_opts'])
|
62
63
|
rescue LoadError
|
63
|
-
|
64
|
+
warn 'not found MeCab'
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -100,7 +101,21 @@ module ReVIEW
|
|
100
101
|
if @chapter.is_a?(ReVIEW::Book::Part) && !@book.config.check_version('2', exception: false)
|
101
102
|
puts '\end{reviewpart}'
|
102
103
|
end
|
103
|
-
@output.string
|
104
|
+
solve_nest(@output.string)
|
105
|
+
end
|
106
|
+
|
107
|
+
def solve_nest(s)
|
108
|
+
check_nest
|
109
|
+
s.gsub("\\end{description}\n\n\x01→dl←\x01\n", "\n").
|
110
|
+
gsub("\x01→/dl←\x01", "\\end{description}←END\x01").
|
111
|
+
gsub("\\end{itemize}\n\n\x01→ul←\x01\n", "\n").
|
112
|
+
gsub("\x01→/ul←\x01", "\\end{itemize}←END\x01").
|
113
|
+
gsub("\\end{enumerate}\n\n\x01→ol←\x01\n", "\n").
|
114
|
+
gsub("\x01→/ol←\x01", "\\end{enumerate}←END\x01").
|
115
|
+
gsub("\\end{description}←END\x01\n\n\\begin{description}", '').
|
116
|
+
gsub("\\end{itemize}←END\x01\n\n\\begin{itemize}", '').
|
117
|
+
gsub("\\end{enumerate}←END\x01\n\n\\begin{enumerate}", '').
|
118
|
+
gsub("←END\x01", '')
|
104
119
|
end
|
105
120
|
|
106
121
|
HEADLINE = {
|
@@ -166,10 +181,10 @@ module ReVIEW
|
|
166
181
|
end
|
167
182
|
|
168
183
|
def nodisp_begin(level, _label, caption)
|
169
|
-
if @output.pos
|
170
|
-
blank
|
171
|
-
else
|
184
|
+
if @output.pos == 0
|
172
185
|
puts macro('clearpage')
|
186
|
+
else
|
187
|
+
blank
|
173
188
|
end
|
174
189
|
puts macro('addcontentsline', 'toc', HEADLINE[level], compile_inline(caption))
|
175
190
|
# FIXME: headings
|
@@ -212,7 +227,53 @@ module ReVIEW
|
|
212
227
|
@doc_status[:column] = nil
|
213
228
|
end
|
214
229
|
|
230
|
+
def common_block_begin(type, caption = nil)
|
231
|
+
check_nested_minicolumn
|
232
|
+
if @book.config.check_version('2', exception: false)
|
233
|
+
type = 'minicolumn'
|
234
|
+
end
|
235
|
+
|
236
|
+
@doc_status[:minicolumn] = type
|
237
|
+
print "\\begin{review#{type}}"
|
238
|
+
|
239
|
+
@doc_status[:caption] = true
|
240
|
+
if @book.config.check_version('2', exception: false)
|
241
|
+
puts
|
242
|
+
if caption.present?
|
243
|
+
puts "\\reviewminicolumntitle{#{compile_inline(caption)}}"
|
244
|
+
end
|
245
|
+
else
|
246
|
+
if caption.present?
|
247
|
+
print "[#{compile_inline(caption)}]"
|
248
|
+
end
|
249
|
+
puts
|
250
|
+
end
|
251
|
+
@doc_status[:caption] = nil
|
252
|
+
end
|
253
|
+
|
254
|
+
def common_block_end(type)
|
255
|
+
if @book.config.check_version('2', exception: false)
|
256
|
+
type = 'minicolumn'
|
257
|
+
end
|
258
|
+
|
259
|
+
puts "\\end{review#{type}}"
|
260
|
+
@doc_status[:minicolumn] = nil
|
261
|
+
end
|
262
|
+
|
263
|
+
CAPTION_TITLES.each do |name|
|
264
|
+
class_eval %Q(
|
265
|
+
def #{name}_begin(caption = nil)
|
266
|
+
common_block_begin('#{name}', caption)
|
267
|
+
end
|
268
|
+
|
269
|
+
def #{name}_end
|
270
|
+
common_block_end('#{name}')
|
271
|
+
end
|
272
|
+
), __FILE__, __LINE__ - 8
|
273
|
+
end
|
274
|
+
|
215
275
|
def captionblock(type, lines, caption)
|
276
|
+
check_nested_minicolumn
|
216
277
|
if @book.config.check_version('2', exception: false)
|
217
278
|
type = 'minicolumn'
|
218
279
|
end
|
@@ -274,6 +335,7 @@ module ReVIEW
|
|
274
335
|
blank
|
275
336
|
puts '\begin{enumerate}'
|
276
337
|
return true unless @ol_num
|
338
|
+
|
277
339
|
puts "\\setcounter{enumi}{#{@ol_num - 1}}"
|
278
340
|
@ol_num = nil
|
279
341
|
end
|
@@ -299,8 +361,7 @@ module ReVIEW
|
|
299
361
|
end
|
300
362
|
|
301
363
|
def dt(str)
|
302
|
-
str.
|
303
|
-
str.sub!(/\]/) { '\rbrack{}' }
|
364
|
+
str = str.gsub('[', '\lbrack{}').gsub(']', '\rbrack{}')
|
304
365
|
puts '\item[' + str + '] \mbox{} \\\\'
|
305
366
|
end
|
306
367
|
|
@@ -404,18 +465,19 @@ module ReVIEW
|
|
404
465
|
|
405
466
|
def common_code_block(id, lines, command, caption, _lang)
|
406
467
|
@doc_status[:caption] = true
|
468
|
+
captionstr = nil
|
407
469
|
unless @book.config.check_version('2', exception: false)
|
408
470
|
puts '\\begin{reviewlistblock}'
|
409
471
|
end
|
410
472
|
if caption.present?
|
411
473
|
if command =~ /emlist/ || command =~ /cmd/ || command =~ /source/
|
412
|
-
|
474
|
+
captionstr = macro(command + 'caption', compile_inline(caption))
|
413
475
|
else
|
414
476
|
begin
|
415
477
|
if get_chap.nil?
|
416
|
-
|
478
|
+
captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
417
479
|
else
|
418
|
-
|
480
|
+
captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
419
481
|
end
|
420
482
|
rescue KeyError
|
421
483
|
error "no such list: #{id}"
|
@@ -423,6 +485,11 @@ module ReVIEW
|
|
423
485
|
end
|
424
486
|
end
|
425
487
|
@doc_status[:caption] = nil
|
488
|
+
|
489
|
+
if caption_top?('list') && captionstr
|
490
|
+
puts captionstr
|
491
|
+
end
|
492
|
+
|
426
493
|
body = ''
|
427
494
|
lines.each_with_index do |line, idx|
|
428
495
|
body.concat(yield(line, idx))
|
@@ -430,6 +497,11 @@ module ReVIEW
|
|
430
497
|
puts macro('begin', command)
|
431
498
|
print body
|
432
499
|
puts macro('end', command)
|
500
|
+
|
501
|
+
if !caption_top?('list') && captionstr
|
502
|
+
puts captionstr
|
503
|
+
end
|
504
|
+
|
433
505
|
unless @book.config.check_version('2', exception: false)
|
434
506
|
puts '\\end{reviewlistblock}'
|
435
507
|
end
|
@@ -482,10 +554,20 @@ module ReVIEW
|
|
482
554
|
def image_header(id, caption)
|
483
555
|
end
|
484
556
|
|
557
|
+
def parse_metric(type, metric)
|
558
|
+
s = super(type, metric)
|
559
|
+
if @book.config['pdfmaker']['use_original_image_size'] && s.empty? && !metric.present?
|
560
|
+
return ' ' # pass empty to \reviewincludegraphics
|
561
|
+
end
|
562
|
+
|
563
|
+
s
|
564
|
+
end
|
565
|
+
|
485
566
|
def handle_metric(str)
|
486
|
-
if @book.config['image_scale2width'] && str =~ /\Ascale=([\d.]+)\Z/
|
567
|
+
if @book.config['pdfmaker']['image_scale2width'] && str =~ /\Ascale=([\d.]+)\Z/
|
487
568
|
return "width=#{$1}\\maxwidth"
|
488
569
|
end
|
570
|
+
|
489
571
|
str
|
490
572
|
end
|
491
573
|
|
@@ -493,11 +575,25 @@ module ReVIEW
|
|
493
575
|
array.join(',')
|
494
576
|
end
|
495
577
|
|
496
|
-
def image_image(id, caption, metric)
|
578
|
+
def image_image(id, caption = '', metric = nil)
|
579
|
+
captionstr = nil
|
580
|
+
@doc_status[:caption] = true
|
581
|
+
if @book.config.check_version('2', exception: false)
|
582
|
+
captionstr = macro('caption', compile_inline(caption)) + "\n"
|
583
|
+
else
|
584
|
+
captionstr = macro('reviewimagecaption', compile_inline(caption)) + "\n"
|
585
|
+
end
|
586
|
+
captionstr << macro('label', image_label(id))
|
587
|
+
@doc_status[:caption] = nil
|
588
|
+
|
497
589
|
metrics = parse_metric('latex', metric)
|
498
590
|
# image is always bound here
|
499
591
|
puts "\\begin{reviewimage}%%#{id}"
|
500
592
|
|
593
|
+
if caption_top?('image')
|
594
|
+
puts captionstr
|
595
|
+
end
|
596
|
+
|
501
597
|
command = 'reviewincludegraphics'
|
502
598
|
if @book.config.check_version('2', exception: false)
|
503
599
|
command = 'includegraphics'
|
@@ -508,15 +604,11 @@ module ReVIEW
|
|
508
604
|
else
|
509
605
|
puts "\\#{command}[width=\\maxwidth]{#{@chapter.image(id).path}}"
|
510
606
|
end
|
511
|
-
@doc_status[:caption] = true
|
512
607
|
|
513
|
-
|
514
|
-
puts
|
515
|
-
else
|
516
|
-
puts macro('reviewimagecaption', compile_inline(caption)) if caption.present?
|
608
|
+
unless caption_top?('image')
|
609
|
+
puts captionstr
|
517
610
|
end
|
518
|
-
|
519
|
-
puts macro('label', image_label(id))
|
611
|
+
|
520
612
|
puts '\end{reviewimage}'
|
521
613
|
end
|
522
614
|
|
@@ -571,7 +663,8 @@ module ReVIEW
|
|
571
663
|
end
|
572
664
|
private :bib_label
|
573
665
|
|
574
|
-
def column_label(id, chapter =
|
666
|
+
def column_label(id, chapter = nil)
|
667
|
+
chapter ||= @chapter
|
575
668
|
filename = chapter.id
|
576
669
|
num = chapter.column(id).number
|
577
670
|
"column:#{filename}:#{num}"
|
@@ -581,9 +674,21 @@ module ReVIEW
|
|
581
674
|
def indepimage(lines, id, caption = nil, metric = nil)
|
582
675
|
metrics = parse_metric('latex', metric)
|
583
676
|
|
677
|
+
captionstr = nil
|
678
|
+
if caption.present?
|
679
|
+
@doc_status[:caption] = true
|
680
|
+
captionstr = macro('reviewindepimagecaption',
|
681
|
+
%Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)}))
|
682
|
+
@doc_status[:caption] = nil
|
683
|
+
end
|
684
|
+
|
584
685
|
if @chapter.image(id).path
|
585
686
|
puts "\\begin{reviewimage}%%#{id}"
|
586
687
|
|
688
|
+
if caption_top?('image') && captionstr
|
689
|
+
puts captionstr
|
690
|
+
end
|
691
|
+
|
587
692
|
command = 'reviewincludegraphics'
|
588
693
|
if @book.config.check_version('2', exception: false)
|
589
694
|
command = 'includegraphics'
|
@@ -597,18 +702,15 @@ module ReVIEW
|
|
597
702
|
else
|
598
703
|
warn "image not bound: #{id}"
|
599
704
|
puts '\begin{reviewdummyimage}'
|
600
|
-
puts "--[[path = #{id} (#{existence(id)})]]--"
|
705
|
+
puts "--[[path = #{escape(id)} (#{existence(id)})]]--"
|
601
706
|
lines.each do |line|
|
602
707
|
puts detab(line.rstrip)
|
603
708
|
end
|
604
709
|
end
|
605
710
|
|
606
|
-
|
607
|
-
|
608
|
-
puts macro('reviewindepimagecaption',
|
609
|
-
%Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)}))
|
711
|
+
if !caption_top?('image') && captionstr
|
712
|
+
puts captionstr
|
610
713
|
end
|
611
|
-
@doc_status[:caption] = nil
|
612
714
|
|
613
715
|
if @chapter.image(id).path
|
614
716
|
puts '\end{reviewimage}'
|
@@ -630,7 +732,9 @@ module ReVIEW
|
|
630
732
|
|
631
733
|
sepidx, rows = parse_table_rows(lines)
|
632
734
|
begin
|
633
|
-
|
735
|
+
if caption_top?('table') && caption.present?
|
736
|
+
table_header(id, caption)
|
737
|
+
end
|
634
738
|
rescue KeyError
|
635
739
|
error "no such table: #{id}"
|
636
740
|
end
|
@@ -638,6 +742,9 @@ module ReVIEW
|
|
638
742
|
table_rows(sepidx, rows)
|
639
743
|
table_end
|
640
744
|
if caption.present?
|
745
|
+
unless caption_top?('table')
|
746
|
+
table_header(id, caption)
|
747
|
+
end
|
641
748
|
puts '\end{table}'
|
642
749
|
end
|
643
750
|
blank
|
@@ -800,12 +907,16 @@ module ReVIEW
|
|
800
907
|
return
|
801
908
|
end
|
802
909
|
|
910
|
+
captionstr = nil
|
803
911
|
begin
|
804
912
|
if caption.present?
|
805
913
|
puts "\\begin{table}[h]%%#{id}"
|
806
914
|
@doc_status[:caption] = true
|
807
|
-
|
915
|
+
captionstr = macro('reviewimgtablecaption', compile_inline(caption))
|
808
916
|
@doc_status[:caption] = nil
|
917
|
+
if caption_top?('table')
|
918
|
+
puts captionstr
|
919
|
+
end
|
809
920
|
end
|
810
921
|
puts macro('label', table_label(id))
|
811
922
|
rescue ReVIEW::KeyError
|
@@ -814,6 +925,9 @@ module ReVIEW
|
|
814
925
|
imgtable_image(id, caption, metric)
|
815
926
|
|
816
927
|
if caption.present?
|
928
|
+
unless caption_top?('table')
|
929
|
+
puts captionstr
|
930
|
+
end
|
817
931
|
puts '\end{table}'
|
818
932
|
end
|
819
933
|
blank
|
@@ -853,22 +967,31 @@ module ReVIEW
|
|
853
967
|
|
854
968
|
def texequation(lines, id = nil, caption = '')
|
855
969
|
blank
|
970
|
+
captionstr = nil
|
856
971
|
|
857
972
|
if id
|
858
973
|
puts macro('begin', 'reviewequationblock')
|
859
974
|
if get_chap.nil?
|
860
|
-
|
975
|
+
captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
861
976
|
else
|
862
|
-
|
977
|
+
captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
863
978
|
end
|
864
979
|
end
|
865
980
|
|
981
|
+
if caption_top?('equation') && captionstr
|
982
|
+
puts captionstr
|
983
|
+
end
|
984
|
+
|
866
985
|
puts macro('begin', 'equation*')
|
867
986
|
lines.each do |line|
|
868
987
|
puts line
|
869
988
|
end
|
870
989
|
puts macro('end', 'equation*')
|
871
990
|
|
991
|
+
if !caption_top?('equation') && captionstr
|
992
|
+
puts captionstr
|
993
|
+
end
|
994
|
+
|
872
995
|
if id
|
873
996
|
puts macro('end', 'reviewequationblock')
|
874
997
|
end
|
@@ -888,6 +1011,7 @@ module ReVIEW
|
|
888
1011
|
|
889
1012
|
def direct(lines, fmt)
|
890
1013
|
return unless fmt == 'latex'
|
1014
|
+
|
891
1015
|
lines.each do |line|
|
892
1016
|
puts line
|
893
1017
|
end
|
@@ -895,6 +1019,7 @@ module ReVIEW
|
|
895
1019
|
|
896
1020
|
def comment(lines, comment = nil)
|
897
1021
|
return true unless @book.config['draft']
|
1022
|
+
|
898
1023
|
lines ||= []
|
899
1024
|
unless comment.blank?
|
900
1025
|
lines.unshift(escape(comment))
|
@@ -926,7 +1051,7 @@ module ReVIEW
|
|
926
1051
|
def inline_chapref(id)
|
927
1052
|
title = super
|
928
1053
|
if @book.config['chapterlink']
|
929
|
-
"\\
|
1054
|
+
"\\reviewchapref{#{title}}{chap:#{id}}"
|
930
1055
|
else
|
931
1056
|
title
|
932
1057
|
end
|
@@ -937,7 +1062,7 @@ module ReVIEW
|
|
937
1062
|
|
938
1063
|
def inline_chap(id)
|
939
1064
|
if @book.config['chapterlink']
|
940
|
-
"\\
|
1065
|
+
"\\reviewchapref{#{@book.chapter_index.number(id)}}{chap:#{id}}"
|
941
1066
|
else
|
942
1067
|
@book.chapter_index.number(id)
|
943
1068
|
end
|
@@ -949,7 +1074,7 @@ module ReVIEW
|
|
949
1074
|
def inline_title(id)
|
950
1075
|
title = super
|
951
1076
|
if @book.config['chapterlink']
|
952
|
-
"\\
|
1077
|
+
"\\reviewchapref{#{title}}{chap:#{id}}"
|
953
1078
|
else
|
954
1079
|
title
|
955
1080
|
end
|
@@ -1019,7 +1144,7 @@ module ReVIEW
|
|
1019
1144
|
def inline_fn(id)
|
1020
1145
|
if @book.config['footnotetext']
|
1021
1146
|
macro("footnotemark[#{@chapter.footnote(id).number}]", '')
|
1022
|
-
elsif @doc_status[:caption] || @doc_status[:table] || @doc_status[:column]
|
1147
|
+
elsif @doc_status[:caption] || @doc_status[:table] || @doc_status[:column] || @doc_status[:dt]
|
1023
1148
|
@foottext[id] = @chapter.footnote(id).number
|
1024
1149
|
macro('protect\\footnotemark', '')
|
1025
1150
|
else
|
@@ -1112,6 +1237,10 @@ module ReVIEW
|
|
1112
1237
|
end
|
1113
1238
|
end
|
1114
1239
|
|
1240
|
+
def inline_ins(str)
|
1241
|
+
macro('reviewinsert', escape(str))
|
1242
|
+
end
|
1243
|
+
|
1115
1244
|
def inline_del(str)
|
1116
1245
|
macro('reviewstrike', escape(str))
|
1117
1246
|
end
|
@@ -1144,7 +1273,7 @@ module ReVIEW
|
|
1144
1273
|
str = I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
|
1145
1274
|
end
|
1146
1275
|
if @book.config['chapterlink']
|
1147
|
-
anchor = n.
|
1276
|
+
anchor = n.tr('.', '-')
|
1148
1277
|
macro('reviewsecref', str, sec_label(anchor))
|
1149
1278
|
else
|
1150
1279
|
str
|
@@ -1159,7 +1288,7 @@ module ReVIEW
|
|
1159
1288
|
error "unknown column: #{id}"
|
1160
1289
|
end
|
1161
1290
|
|
1162
|
-
def inline_raw(str)
|
1291
|
+
def inline_raw(str) # rubocop:disable Lint/UselessMethodDefinition
|
1163
1292
|
super(str)
|
1164
1293
|
end
|
1165
1294
|
|
@@ -1242,22 +1371,23 @@ module ReVIEW
|
|
1242
1371
|
end
|
1243
1372
|
|
1244
1373
|
def index(str)
|
1374
|
+
# XXX: mendex/upmendex specific
|
1245
1375
|
sa = str.split('<<>>')
|
1246
1376
|
|
1247
1377
|
sa.map! do |item|
|
1248
1378
|
if @index_db[item]
|
1249
|
-
escape_index(
|
1379
|
+
escape_mendex_key(escape_index(@index_db[item])) + '@' + escape_mendex_display(escape_index(escape(item)))
|
1250
1380
|
else
|
1251
1381
|
if item =~ /\A[[:ascii:]]+\Z/ || @index_mecab.nil?
|
1252
|
-
esc_item = escape_index(escape(item))
|
1253
|
-
if esc_item
|
1254
|
-
"#{escape_index(item)}@#{esc_item}"
|
1255
|
-
else
|
1382
|
+
esc_item = escape_mendex_display(escape_index(escape(item)))
|
1383
|
+
if esc_item == item
|
1256
1384
|
esc_item
|
1385
|
+
else
|
1386
|
+
"#{escape_mendex_key(escape_index(item))}@#{esc_item}"
|
1257
1387
|
end
|
1258
1388
|
else
|
1259
1389
|
yomi = NKF.nkf('-w --hiragana', @index_mecab.parse(item).force_encoding('UTF-8').chomp)
|
1260
|
-
escape_index(
|
1390
|
+
escape_mendex_key(escape_index(yomi)) + '@' + escape_mendex_display(escape_index(escape(item)))
|
1261
1391
|
end
|
1262
1392
|
end
|
1263
1393
|
end
|