review 3.1.0 → 5.0.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 +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +161 -34
- data/.travis.yml +16 -15
- data/Dockerfile +21 -5
- data/NEWS.ja.md +394 -0
- data/NEWS.md +395 -1
- data/README.md +10 -7
- data/appveyor.yml +1 -3
- data/bin/review-catalog-converter +5 -5
- data/bin/review-check +10 -12
- data/bin/review-checkdep +2 -2
- data/bin/review-compile +17 -23
- data/bin/review-epubmaker +3 -35
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +2 -89
- data/bin/review-preproc +13 -13
- data/bin/review-validate +4 -4
- data/bin/review-vol +4 -78
- data/doc/config.yml.sample +47 -12
- data/doc/config.yml.sample-simple +3 -2
- data/doc/format.ja.md +120 -17
- data/doc/format.md +119 -27
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- data/doc/quickstart.ja.md +45 -25
- data/doc/quickstart.md +37 -16
- data/lib/epubmaker/content.rb +3 -2
- data/lib/epubmaker/epubcommon.rb +34 -27
- data/lib/epubmaker/epubv2.rb +5 -6
- data/lib/epubmaker/epubv3.rb +21 -18
- data/lib/epubmaker/producer.rb +2 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +91 -96
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +155 -0
- data/lib/review/book/chapter.rb +48 -29
- data/lib/review/book/index.rb +46 -240
- data/lib/review/book/index/item.rb +46 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +45 -10
- data/lib/review/book/volume.rb +4 -5
- data/lib/review/builder.rb +172 -56
- data/lib/review/catalog.rb +14 -17
- data/lib/review/compiler.rb +219 -121
- data/lib/review/configure.rb +39 -7
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +43 -5
- data/lib/review/epubmaker.rb +69 -27
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +112 -101
- data/lib/review/htmlutils.rb +9 -13
- data/lib/review/i18n.rb +3 -3
- data/lib/review/idgxmlbuilder.rb +202 -78
- data/lib/review/idgxmlmaker.rb +186 -0
- data/lib/review/index_builder.rb +653 -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 +129 -46
- data/lib/review/latexbuilder.rb +255 -92
- 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 +35 -5
- data/lib/review/markdownbuilder.rb +50 -38
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +60 -57
- data/lib/review/plaintextbuilder.rb +154 -87
- data/lib/review/preprocessor.rb +20 -42
- data/lib/review/rstbuilder.rb +57 -38
- data/lib/review/sec_counter.rb +13 -0
- data/lib/review/textmaker.rb +23 -15
- data/lib/review/textutils.rb +76 -2
- data/lib/review/tocprinter.rb +230 -102
- data/lib/review/topbuilder.rb +139 -60
- data/lib/review/update.rb +24 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +98 -0
- data/lib/review/webmaker.rb +20 -24
- 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/Gemfile +1 -1
- 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 +39 -25
- data/templates/latex/layout.tex.erb +1 -0
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +161 -50
- data/templates/latex/review-jlreq/review-jlreq.cls +21 -22
- data/templates/latex/review-jlreq/review-style.sty +4 -1
- data/templates/latex/review-jsbook/README.md +46 -5
- data/templates/latex/review-jsbook/review-base.sty +123 -35
- data/templates/latex/review-jsbook/review-jsbook.cls +10 -4
- 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 +3 -3
- data/test/assets/test_template.tex +19 -7
- data/test/assets/test_template_backmatter.tex +19 -7
- data/test/book_test_helper.rb +11 -5
- data/test/test_book.rb +124 -79
- data/test/test_book_chapter.rb +97 -54
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +38 -13
- data/test/test_catalog.rb +24 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +2 -2
- data/test/test_epubmaker.rb +8 -0
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +18 -7
- data/test/test_htmlbuilder.rb +1491 -205
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +37 -37
- data/test/test_idgxmlbuilder.rb +744 -42
- data/test/test_idgxmlmaker_cmd.rb +46 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_index.rb +94 -44
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +1784 -161
- data/test/test_latexbuilder_v2.rb +671 -102
- data/test/test_logger.rb +17 -4
- data/test/test_makerhelper.rb +2 -14
- data/test/test_markdownbuilder.rb +137 -16
- data/test/test_md2inaobuilder.rb +32 -9
- data/test/test_pdfmaker.rb +30 -12
- data/test/test_pdfmaker_cmd.rb +100 -6
- data/test/test_plaintextbuilder.rb +791 -30
- data/test/test_preprocessor.rb +2 -16
- data/test/test_review_ext.rb +2 -1
- data/test/test_rstbuilder.rb +274 -27
- data/test/test_sec_counter.rb +156 -0
- data/test/test_textmaker_cmd.rb +54 -0
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +724 -34
- data/test/test_update.rb +20 -11
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_yamlloader.rb +13 -0
- 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 +65 -12
- data/.rubocop_todo.yml +0 -7
- data/lib/review/book/compilable.rb +0 -173
- 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 Masanori Kado, Masayoshi Takahashi, Kenshi Muto
|
2
|
+
# Copyright (c) 2018-2019 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
|
@@ -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,23 +76,35 @@ 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|
|
70
83
|
@epub_version = version
|
71
84
|
end
|
85
|
+
opts.on('', '--without-config-comment', "don't include comments in config.yml.") do
|
86
|
+
@without_config_comment = true
|
87
|
+
end
|
72
88
|
opts.on('', '--without-doc', "don't generate doc files.") do
|
73
89
|
@without_doc = true
|
74
90
|
end
|
75
91
|
opts.on('-p', '--package archivefile', 'extract from local or network archive.') do |archive|
|
76
92
|
@archive = archive
|
77
93
|
end
|
94
|
+
opts.on('-w', '--wizard', 'launch Web based layout configuration.') do
|
95
|
+
@webui = true
|
96
|
+
end
|
97
|
+
opts.on('', '--port port', 'port to use for Web based layout configuration. (default: 18000)') do |port|
|
98
|
+
@port = port
|
99
|
+
end
|
100
|
+
opts.on('', '--bind bindaddress', 'address to use for Web based layout configuration. (default: 0 (any))') do |bind|
|
101
|
+
@bind = bind
|
102
|
+
end
|
78
103
|
|
79
104
|
begin
|
80
105
|
opts.parse!(args)
|
81
|
-
rescue OptionParser::ParseError =>
|
82
|
-
@logger.error
|
106
|
+
rescue OptionParser::ParseError => e
|
107
|
+
@logger.error e.message
|
83
108
|
$stderr.puts opts.help
|
84
109
|
exit 1
|
85
110
|
end
|
@@ -89,9 +114,7 @@ module ReVIEW
|
|
89
114
|
exit 1
|
90
115
|
end
|
91
116
|
|
92
|
-
|
93
|
-
|
94
|
-
initdir
|
117
|
+
File.expand_path(args[0])
|
95
118
|
end
|
96
119
|
|
97
120
|
def generate_dir(dir)
|
@@ -99,7 +122,7 @@ module ReVIEW
|
|
99
122
|
@logger.error "#{dir} already exists."
|
100
123
|
exit 1
|
101
124
|
end
|
102
|
-
FileUtils.mkdir_p
|
125
|
+
FileUtils.mkdir_p(dir)
|
103
126
|
yield dir
|
104
127
|
end
|
105
128
|
|
@@ -109,13 +132,8 @@ module ReVIEW
|
|
109
132
|
end
|
110
133
|
end
|
111
134
|
|
112
|
-
def generate_layout(dir)
|
113
|
-
FileUtils.mkdir_p File.join(dir, 'layouts')
|
114
|
-
end
|
115
|
-
|
116
135
|
def generate_catalog_file(dir)
|
117
|
-
File.
|
118
|
-
file.write <<-EOS
|
136
|
+
File.write(File.join(dir, 'catalog.yml'), <<-EOS)
|
119
137
|
PREDEF:
|
120
138
|
|
121
139
|
CHAPS:
|
@@ -126,7 +144,6 @@ APPENDIX:
|
|
126
144
|
POSTDEF:
|
127
145
|
|
128
146
|
EOS
|
129
|
-
end
|
130
147
|
end
|
131
148
|
|
132
149
|
def generate_images_dir(dir)
|
@@ -154,64 +171,82 @@ EOS
|
|
154
171
|
content.gsub!(/^#.*htmlversion:.*$/, 'htmlversion: 4')
|
155
172
|
end
|
156
173
|
|
157
|
-
if
|
158
|
-
content.gsub!(/^#\s*texdocumentclass:.*$/, %Q(texdocumentclass: ["#{@template}", "#{
|
174
|
+
if @tex_documentclass_opts[@template]
|
175
|
+
content.gsub!(/^#\s*texdocumentclass:.*$/, %Q(texdocumentclass: ["#{@template}", "#{@tex_documentclass_opts[@template]}"]))
|
176
|
+
end
|
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
|
+
|
182
|
+
File.open(File.join(dir, 'config.yml'), 'w') { |f| f.write content }
|
183
|
+
if @webui && !@web_result[2].empty?
|
184
|
+
File.open(File.join(dir, 'config-ebook.yml'), 'w') do |f|
|
185
|
+
f.puts <<EOT
|
186
|
+
# for ebook PDF
|
187
|
+
# REVIEW_CONFIG_FILE=config.yml rake pdf
|
188
|
+
inherit: ["config.yml"]
|
189
|
+
# bookname: book-ebook
|
190
|
+
texdocumentclass: ["#{@web_result[0]}", "#{@web_result[2]}"]
|
191
|
+
EOT
|
192
|
+
end
|
159
193
|
end
|
194
|
+
end
|
160
195
|
|
161
|
-
|
196
|
+
def generate_gitignore(dir)
|
197
|
+
FileUtils.cp(File.join(@review_dir, 'samples/sample-book/src/.gitignore'), dir)
|
162
198
|
end
|
163
199
|
|
164
200
|
def generate_style(dir)
|
165
|
-
FileUtils.cp
|
201
|
+
FileUtils.cp(File.join(@review_dir, 'samples/sample-book/src/style.css'), dir)
|
166
202
|
end
|
167
203
|
|
168
204
|
def generate_texmacro(dir)
|
169
205
|
texmacrodir = File.join(dir, 'sty')
|
170
|
-
FileUtils.mkdir_p
|
206
|
+
FileUtils.mkdir_p(texmacrodir)
|
171
207
|
tdir = File.join(@review_dir, 'templates/latex', @template)
|
172
208
|
@logger.error "#{tdir} not found." unless File.exist?(tdir)
|
173
|
-
FileUtils.cp
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
209
|
+
FileUtils.cp(Dir.glob(File.join(tdir, '*.*')), texmacrodir)
|
210
|
+
|
211
|
+
if @template == 'review-jsbook'
|
212
|
+
# provide jsbook from vendor/. current version is 2018/06/23
|
213
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/jsclasses/jsbook.cls'), File.join(texmacrodir, 'jsbook.cls'))
|
214
|
+
# provide gentombow from vendor/. current version is 2018/08/30 v0.9j
|
215
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/gentombow/gentombow.sty'), File.join(texmacrodir, 'gentombow.sty'))
|
216
|
+
end
|
178
217
|
end
|
179
218
|
|
180
219
|
def generate_rakefile(dir)
|
181
|
-
FileUtils.mkdir_p
|
220
|
+
FileUtils.mkdir_p(File.join(dir, 'lib/tasks'))
|
182
221
|
|
183
|
-
File.
|
184
|
-
file.write <<-EOS
|
222
|
+
File.write(File.join(dir, 'Rakefile'), <<-EOS)
|
185
223
|
Dir.glob('lib/tasks/*.rake').sort.each do |file|
|
186
224
|
load(file)
|
187
225
|
end
|
188
226
|
EOS
|
189
|
-
end
|
190
227
|
|
191
228
|
FileUtils.cp(File.join(@review_dir, 'samples/sample-book/src/lib/tasks/review.rake'),
|
192
229
|
File.join(dir, 'lib/tasks/review.rake'))
|
193
230
|
end
|
194
231
|
|
195
232
|
def generate_locale(dir)
|
196
|
-
FileUtils.cp
|
233
|
+
FileUtils.cp(File.join(@review_dir, 'lib/review/i18n.yml'), File.join(dir, 'locale.yml'))
|
197
234
|
end
|
198
235
|
|
199
236
|
def generate_gemfile(dir)
|
200
|
-
File.
|
201
|
-
file.write <<-EOS
|
237
|
+
File.write(File.join(dir, 'Gemfile'), <<-EOS)
|
202
238
|
source 'https://rubygems.org'
|
203
239
|
|
204
240
|
gem 'rake'
|
205
241
|
gem 'review', '#{ReVIEW::VERSION}'
|
206
242
|
EOS
|
207
|
-
end
|
208
243
|
end
|
209
244
|
|
210
245
|
def generate_doc(dir)
|
211
246
|
docdir = File.join(dir, 'doc')
|
212
|
-
FileUtils.mkdir_p
|
247
|
+
FileUtils.mkdir_p(docdir)
|
213
248
|
md_files = Dir.glob(File.join(@review_dir, 'doc/*.md')).map.to_a
|
214
|
-
FileUtils.cp
|
249
|
+
FileUtils.cp(md_files, docdir)
|
215
250
|
end
|
216
251
|
|
217
252
|
def download_and_extract_archive(dir, filename)
|
@@ -226,8 +261,8 @@ EOS
|
|
226
261
|
begin
|
227
262
|
@logger.info "Downloading from #{filename}"
|
228
263
|
zipdata = Net::HTTP.get(URI.parse(filename))
|
229
|
-
rescue StandardError =>
|
230
|
-
@logger.error "Failed to download #{filename}: #{
|
264
|
+
rescue StandardError => e
|
265
|
+
@logger.error "Failed to download #{filename}: #{e.message}"
|
231
266
|
exit 1
|
232
267
|
end
|
233
268
|
|
@@ -256,7 +291,7 @@ EOS
|
|
256
291
|
next
|
257
292
|
end
|
258
293
|
|
259
|
-
if fname
|
294
|
+
if fname.start_with?('/') || fname =~ /\.\./ # simple fool proof
|
260
295
|
made = nil
|
261
296
|
break
|
262
297
|
end
|
@@ -267,8 +302,56 @@ EOS
|
|
267
302
|
made = true
|
268
303
|
end
|
269
304
|
raise Zip::Error unless made
|
270
|
-
rescue Zip::Error =>
|
271
|
-
@logger.error "#{originalfilename} seems invalid or broken zip file: #{
|
305
|
+
rescue Zip::Error => e
|
306
|
+
@logger.error "#{originalfilename} seems invalid or broken zip file: #{e.message}"
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def start_webui
|
311
|
+
require 'webrick'
|
312
|
+
web_config = {
|
313
|
+
BindAddress: @bind,
|
314
|
+
Port: @port,
|
315
|
+
HTTPVersion: WEBrick::HTTPVersion.new('1.1'),
|
316
|
+
AccessLog: [[File.open(IO::NULL, 'w'), '']]
|
317
|
+
}
|
318
|
+
|
319
|
+
bind_address = (@bind == '0') ? '<thishost>' : @bind
|
320
|
+
puts "Please access http://#{bind_address}:#{web_config[:Port]} from Web browser."
|
321
|
+
begin
|
322
|
+
@web_server = WEBrick::HTTPServer.new(web_config)
|
323
|
+
rescue StandardError => e
|
324
|
+
@logger.error "Error: #{e}"
|
325
|
+
exit 1
|
326
|
+
end
|
327
|
+
|
328
|
+
@web_result = nil
|
329
|
+
web_mounts
|
330
|
+
|
331
|
+
trap(:INT) { @web_server.shutdown }
|
332
|
+
@web_server.start
|
333
|
+
|
334
|
+
# validation
|
335
|
+
if @web_result
|
336
|
+
@web_result.each do |s|
|
337
|
+
if s !~ /\A[a-z0-9=_,.-]*\Z/i
|
338
|
+
@web_result = nil
|
339
|
+
break
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
def web_mounts
|
346
|
+
htmldir = File.join(@review_dir, 'lib', 'review', 'init-web')
|
347
|
+
@web_server.mount('/', WEBrick::HTTPServlet::FileHandler, File.join(htmldir, 'index.html'))
|
348
|
+
@web_server.mount('/review-layout-design.js', WEBrick::HTTPServlet::FileHandler, File.join(htmldir, 'review-layout-design.js'))
|
349
|
+
|
350
|
+
@web_server.mount_proc('/finish') do |req, res|
|
351
|
+
@web_result = [req.query['cls'], req.query['result_print'], req.query['result_ebook']]
|
352
|
+
res.content_type = 'text/html'
|
353
|
+
res.body = File.read(File.join(htmldir, 'finish.html'))
|
354
|
+
@web_server.shutdown
|
272
355
|
end
|
273
356
|
end
|
274
357
|
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-2020 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
|
@@ -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
|
@@ -61,7 +60,7 @@ module ReVIEW
|
|
61
60
|
require 'nkf'
|
62
61
|
@index_mecab = MeCab::Tagger.new(@book.config['pdfmaker']['makeindex_mecab_opts'])
|
63
62
|
rescue LoadError
|
64
|
-
|
63
|
+
warn 'not found MeCab'
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
@@ -101,7 +100,21 @@ module ReVIEW
|
|
101
100
|
if @chapter.is_a?(ReVIEW::Book::Part) && !@book.config.check_version('2', exception: false)
|
102
101
|
puts '\end{reviewpart}'
|
103
102
|
end
|
104
|
-
@output.string
|
103
|
+
solve_nest(@output.string)
|
104
|
+
end
|
105
|
+
|
106
|
+
def solve_nest(s)
|
107
|
+
check_nest
|
108
|
+
s.gsub("\\end{description}\n\n\x01→dl←\x01\n", "\n").
|
109
|
+
gsub("\x01→/dl←\x01", "\\end{description}←END\x01").
|
110
|
+
gsub("\\end{itemize}\n\n\x01→ul←\x01\n", "\n").
|
111
|
+
gsub("\x01→/ul←\x01", "\\end{itemize}←END\x01").
|
112
|
+
gsub("\\end{enumerate}\n\n\x01→ol←\x01\n", "\n").
|
113
|
+
gsub("\x01→/ol←\x01", "\\end{enumerate}←END\x01").
|
114
|
+
gsub("\\end{description}←END\x01\n\n\\begin{description}", '').
|
115
|
+
gsub("\\end{itemize}←END\x01\n\n\\begin{itemize}", '').
|
116
|
+
gsub("\\end{enumerate}←END\x01\n\n\\begin{enumerate}", '').
|
117
|
+
gsub("←END\x01", '')
|
105
118
|
end
|
106
119
|
|
107
120
|
HEADLINE = {
|
@@ -213,7 +226,53 @@ module ReVIEW
|
|
213
226
|
@doc_status[:column] = nil
|
214
227
|
end
|
215
228
|
|
229
|
+
def common_block_begin(type, caption = nil)
|
230
|
+
check_nested_minicolumn
|
231
|
+
if @book.config.check_version('2', exception: false)
|
232
|
+
type = 'minicolumn'
|
233
|
+
end
|
234
|
+
|
235
|
+
@doc_status[:minicolumn] = type
|
236
|
+
print "\\begin{review#{type}}"
|
237
|
+
|
238
|
+
@doc_status[:caption] = true
|
239
|
+
if @book.config.check_version('2', exception: false)
|
240
|
+
puts
|
241
|
+
if caption.present?
|
242
|
+
puts "\\reviewminicolumntitle{#{compile_inline(caption)}}"
|
243
|
+
end
|
244
|
+
else
|
245
|
+
if caption.present?
|
246
|
+
print "[#{compile_inline(caption)}]"
|
247
|
+
end
|
248
|
+
puts
|
249
|
+
end
|
250
|
+
@doc_status[:caption] = nil
|
251
|
+
end
|
252
|
+
|
253
|
+
def common_block_end(type)
|
254
|
+
if @book.config.check_version('2', exception: false)
|
255
|
+
type = 'minicolumn'
|
256
|
+
end
|
257
|
+
|
258
|
+
puts "\\end{review#{type}}"
|
259
|
+
@doc_status[:minicolumn] = nil
|
260
|
+
end
|
261
|
+
|
262
|
+
CAPTION_TITLES.each do |name|
|
263
|
+
class_eval %Q(
|
264
|
+
def #{name}_begin(caption = nil)
|
265
|
+
common_block_begin('#{name}', caption)
|
266
|
+
end
|
267
|
+
|
268
|
+
def #{name}_end
|
269
|
+
common_block_end('#{name}')
|
270
|
+
end
|
271
|
+
), __FILE__, __LINE__ - 8
|
272
|
+
end
|
273
|
+
|
216
274
|
def captionblock(type, lines, caption)
|
275
|
+
check_nested_minicolumn
|
217
276
|
if @book.config.check_version('2', exception: false)
|
218
277
|
type = 'minicolumn'
|
219
278
|
end
|
@@ -257,7 +316,11 @@ module ReVIEW
|
|
257
316
|
end
|
258
317
|
|
259
318
|
def ul_item(lines)
|
260
|
-
str = lines
|
319
|
+
str = join_lines_to_paragraph(lines)
|
320
|
+
unless @book.config['join_lines_by_lang']
|
321
|
+
str = lines.map(&:chomp).join("\n")
|
322
|
+
end
|
323
|
+
|
261
324
|
str.sub!(/\A(\[)/) { '\lbrack{}' }
|
262
325
|
puts '\item ' + str
|
263
326
|
end
|
@@ -276,7 +339,11 @@ module ReVIEW
|
|
276
339
|
end
|
277
340
|
|
278
341
|
def ol_item(lines, _num)
|
279
|
-
str = lines
|
342
|
+
str = join_lines_to_paragraph(lines)
|
343
|
+
unless @book.config['join_lines_by_lang']
|
344
|
+
str = lines.map(&:chomp).join("\n")
|
345
|
+
end
|
346
|
+
|
280
347
|
str.sub!(/\A(\[)/) { '\lbrack{}' }
|
281
348
|
puts '\item ' + str
|
282
349
|
end
|
@@ -292,13 +359,16 @@ module ReVIEW
|
|
292
359
|
end
|
293
360
|
|
294
361
|
def dt(str)
|
295
|
-
str.
|
296
|
-
str.sub!(/\]/) { '\rbrack{}' }
|
362
|
+
str = str.gsub('[', '\lbrack{}').gsub(']', '\rbrack{}')
|
297
363
|
puts '\item[' + str + '] \mbox{} \\\\'
|
298
364
|
end
|
299
365
|
|
300
366
|
def dd(lines)
|
301
|
-
|
367
|
+
if @book.config['join_lines_by_lang']
|
368
|
+
puts join_lines_to_paragraph(lines)
|
369
|
+
else
|
370
|
+
puts lines.map(&:chomp).join("\n")
|
371
|
+
end
|
302
372
|
end
|
303
373
|
|
304
374
|
def dl_end
|
@@ -308,8 +378,10 @@ module ReVIEW
|
|
308
378
|
|
309
379
|
def paragraph(lines)
|
310
380
|
blank
|
311
|
-
|
312
|
-
puts
|
381
|
+
if @book.config['join_lines_by_lang']
|
382
|
+
puts join_lines_to_paragraph(lines)
|
383
|
+
else
|
384
|
+
lines.each { |line| puts line }
|
313
385
|
end
|
314
386
|
blank
|
315
387
|
end
|
@@ -319,22 +391,35 @@ module ReVIEW
|
|
319
391
|
end
|
320
392
|
|
321
393
|
def read(lines)
|
322
|
-
latex_block
|
394
|
+
latex_block('quotation', lines)
|
323
395
|
end
|
324
396
|
|
325
397
|
alias_method :lead, :read
|
326
398
|
|
399
|
+
def highlight?
|
400
|
+
@book.config['highlight'] &&
|
401
|
+
@book.config['highlight']['latex']
|
402
|
+
end
|
403
|
+
|
327
404
|
def highlight_listings?
|
328
405
|
@book.config['highlight'] && @book.config['highlight']['latex'] == 'listings'
|
329
406
|
end
|
330
407
|
private :highlight_listings?
|
331
408
|
|
409
|
+
def code_line(_type, line, _idx, _id, _caption, _lang)
|
410
|
+
detab(line) + "\n"
|
411
|
+
end
|
412
|
+
|
413
|
+
def code_line_num(_type, line, first_line_num, idx, _id, _caption, _lang)
|
414
|
+
detab((idx + first_line_num).to_s.rjust(2) + ': ' + line) + "\n"
|
415
|
+
end
|
416
|
+
|
332
417
|
def emlist(lines, caption = nil, lang = nil)
|
333
418
|
blank
|
334
419
|
if highlight_listings?
|
335
420
|
common_code_block_lst(nil, lines, 'reviewemlistlst', 'title', caption, lang)
|
336
421
|
else
|
337
|
-
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line,
|
422
|
+
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line, idx| code_line('emlist', line, idx, nil, caption, lang) }
|
338
423
|
end
|
339
424
|
end
|
340
425
|
|
@@ -344,7 +429,7 @@ module ReVIEW
|
|
344
429
|
if highlight_listings?
|
345
430
|
common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang, first_line_num: first_line_num)
|
346
431
|
else
|
347
|
-
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line, idx|
|
432
|
+
common_code_block(nil, lines, 'reviewemlist', caption, lang) { |line, idx| code_line_num('emlistnum', line, first_line_num, idx, nil, caption, lang) }
|
348
433
|
end
|
349
434
|
end
|
350
435
|
|
@@ -353,7 +438,7 @@ module ReVIEW
|
|
353
438
|
if highlight_listings?
|
354
439
|
common_code_block_lst(id, lines, 'reviewlistlst', 'caption', caption, lang)
|
355
440
|
else
|
356
|
-
common_code_block(id, lines, 'reviewlist', caption, lang) { |line,
|
441
|
+
common_code_block(id, lines, 'reviewlist', caption, lang) { |line, idx| code_line('list', line, idx, id, caption, lang) }
|
357
442
|
end
|
358
443
|
end
|
359
444
|
|
@@ -363,7 +448,7 @@ module ReVIEW
|
|
363
448
|
if highlight_listings?
|
364
449
|
common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang, first_line_num: first_line_num)
|
365
450
|
else
|
366
|
-
common_code_block(id, lines, 'reviewlist', caption, lang) { |line, idx|
|
451
|
+
common_code_block(id, lines, 'reviewlist', caption, lang) { |line, idx| code_line_num('listnum', line, first_line_num, idx, id, caption, lang) }
|
367
452
|
end
|
368
453
|
end
|
369
454
|
|
@@ -372,24 +457,25 @@ module ReVIEW
|
|
372
457
|
common_code_block_lst(nil, lines, 'reviewcmdlst', 'title', caption, lang)
|
373
458
|
else
|
374
459
|
blank
|
375
|
-
common_code_block(nil, lines, 'reviewcmd', caption, lang) { |line,
|
460
|
+
common_code_block(nil, lines, 'reviewcmd', caption, lang) { |line, idx| code_line('cmd', line, idx, nil, caption, lang) }
|
376
461
|
end
|
377
462
|
end
|
378
463
|
|
379
464
|
def common_code_block(id, lines, command, caption, _lang)
|
380
465
|
@doc_status[:caption] = true
|
466
|
+
captionstr = nil
|
381
467
|
unless @book.config.check_version('2', exception: false)
|
382
468
|
puts '\\begin{reviewlistblock}'
|
383
469
|
end
|
384
470
|
if caption.present?
|
385
471
|
if command =~ /emlist/ || command =~ /cmd/ || command =~ /source/
|
386
|
-
|
472
|
+
captionstr = macro(command + 'caption', compile_inline(caption))
|
387
473
|
else
|
388
474
|
begin
|
389
475
|
if get_chap.nil?
|
390
|
-
|
476
|
+
captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
391
477
|
else
|
392
|
-
|
478
|
+
captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
393
479
|
end
|
394
480
|
rescue KeyError
|
395
481
|
error "no such list: #{id}"
|
@@ -397,6 +483,11 @@ module ReVIEW
|
|
397
483
|
end
|
398
484
|
end
|
399
485
|
@doc_status[:caption] = nil
|
486
|
+
|
487
|
+
if caption_top?('list') && captionstr
|
488
|
+
puts captionstr
|
489
|
+
end
|
490
|
+
|
400
491
|
body = ''
|
401
492
|
lines.each_with_index do |line, idx|
|
402
493
|
body.concat(yield(line, idx))
|
@@ -404,6 +495,11 @@ module ReVIEW
|
|
404
495
|
puts macro('begin', command)
|
405
496
|
print body
|
406
497
|
puts macro('end', command)
|
498
|
+
|
499
|
+
if !caption_top?('list') && captionstr
|
500
|
+
puts captionstr
|
501
|
+
end
|
502
|
+
|
407
503
|
unless @book.config.check_version('2', exception: false)
|
408
504
|
puts '\\end{reviewlistblock}'
|
409
505
|
end
|
@@ -414,7 +510,7 @@ module ReVIEW
|
|
414
510
|
if title == 'title' && caption.blank? && @book.config.check_version('2', exception: false)
|
415
511
|
print '\vspace{-1.5em}'
|
416
512
|
end
|
417
|
-
body = lines.inject('') { |i, j| i + detab(
|
513
|
+
body = lines.inject('') { |i, j| i + detab(j) + "\n" }
|
418
514
|
args = make_code_block_args(title, caption, lang, first_line_num: first_line_num)
|
419
515
|
puts %Q(\\begin{#{command}}[#{args}])
|
420
516
|
print body
|
@@ -449,15 +545,23 @@ module ReVIEW
|
|
449
545
|
if highlight_listings?
|
450
546
|
common_code_block_lst(nil, lines, 'reviewsourcelst', 'title', caption, lang)
|
451
547
|
else
|
452
|
-
common_code_block(nil, lines, 'reviewsource', caption, lang) { |line,
|
548
|
+
common_code_block(nil, lines, 'reviewsource', caption, lang) { |line, idx| code_line('source', line, idx, nil, caption, lang) }
|
453
549
|
end
|
454
550
|
end
|
455
551
|
|
456
552
|
def image_header(id, caption)
|
457
553
|
end
|
458
554
|
|
555
|
+
def parse_metric(type, metric)
|
556
|
+
s = super(type, metric)
|
557
|
+
if @book.config['pdfmaker']['use_original_image_size'] && s.empty? && !metric.present?
|
558
|
+
return ' ' # pass empty to \reviewincludegraphics
|
559
|
+
end
|
560
|
+
s
|
561
|
+
end
|
562
|
+
|
459
563
|
def handle_metric(str)
|
460
|
-
if @book.config['image_scale2width'] && str =~ /\Ascale=([\d.]+)\Z/
|
564
|
+
if @book.config['pdfmaker']['image_scale2width'] && str =~ /\Ascale=([\d.]+)\Z/
|
461
565
|
return "width=#{$1}\\maxwidth"
|
462
566
|
end
|
463
567
|
str
|
@@ -468,23 +572,39 @@ module ReVIEW
|
|
468
572
|
end
|
469
573
|
|
470
574
|
def image_image(id, caption, metric)
|
575
|
+
captionstr = nil
|
576
|
+
@doc_status[:caption] = true
|
577
|
+
if @book.config.check_version('2', exception: false)
|
578
|
+
captionstr = macro('caption', compile_inline(caption)) + "\n" if caption.present?
|
579
|
+
else
|
580
|
+
captionstr = macro('reviewimagecaption', compile_inline(caption)) + "\n" if caption.present?
|
581
|
+
end
|
582
|
+
captionstr << macro('label', image_label(id))
|
583
|
+
@doc_status[:caption] = nil
|
584
|
+
|
471
585
|
metrics = parse_metric('latex', metric)
|
472
586
|
# image is always bound here
|
473
587
|
puts "\\begin{reviewimage}%%#{id}"
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}"
|
588
|
+
|
589
|
+
if caption_top?('image') && captionstr
|
590
|
+
puts captionstr
|
478
591
|
end
|
479
|
-
@doc_status[:caption] = true
|
480
592
|
|
593
|
+
command = 'reviewincludegraphics'
|
481
594
|
if @book.config.check_version('2', exception: false)
|
482
|
-
|
595
|
+
command = 'includegraphics'
|
596
|
+
end
|
597
|
+
|
598
|
+
if metrics.present?
|
599
|
+
puts "\\#{command}[#{metrics}]{#{@chapter.image(id).path}}"
|
483
600
|
else
|
484
|
-
puts
|
601
|
+
puts "\\#{command}[width=\\maxwidth]{#{@chapter.image(id).path}}"
|
485
602
|
end
|
486
|
-
|
487
|
-
|
603
|
+
|
604
|
+
if !caption_top?('image') && captionstr
|
605
|
+
puts captionstr
|
606
|
+
end
|
607
|
+
|
488
608
|
puts '\end{reviewimage}'
|
489
609
|
end
|
490
610
|
|
@@ -508,7 +628,7 @@ module ReVIEW
|
|
508
628
|
end
|
509
629
|
|
510
630
|
def existence(id)
|
511
|
-
@chapter.
|
631
|
+
@chapter.image_bound?(id) ? 'exist' : 'not exist'
|
512
632
|
end
|
513
633
|
private :existence
|
514
634
|
|
@@ -539,7 +659,8 @@ module ReVIEW
|
|
539
659
|
end
|
540
660
|
private :bib_label
|
541
661
|
|
542
|
-
def column_label(id, chapter =
|
662
|
+
def column_label(id, chapter = nil)
|
663
|
+
chapter ||= @chapter
|
543
664
|
filename = chapter.id
|
544
665
|
num = chapter.column(id).number
|
545
666
|
"column:#{filename}:#{num}"
|
@@ -549,28 +670,43 @@ module ReVIEW
|
|
549
670
|
def indepimage(lines, id, caption = nil, metric = nil)
|
550
671
|
metrics = parse_metric('latex', metric)
|
551
672
|
|
673
|
+
captionstr = nil
|
674
|
+
if caption.present?
|
675
|
+
@doc_status[:caption] = true
|
676
|
+
captionstr = macro('reviewindepimagecaption',
|
677
|
+
%Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)}))
|
678
|
+
@doc_status[:caption] = nil
|
679
|
+
end
|
680
|
+
|
552
681
|
if @chapter.image(id).path
|
553
682
|
puts "\\begin{reviewimage}%%#{id}"
|
683
|
+
|
684
|
+
if caption_top?('image') && captionstr
|
685
|
+
puts captionstr
|
686
|
+
end
|
687
|
+
|
688
|
+
command = 'reviewincludegraphics'
|
689
|
+
if @book.config.check_version('2', exception: false)
|
690
|
+
command = 'includegraphics'
|
691
|
+
end
|
692
|
+
|
554
693
|
if metrics.present?
|
555
|
-
puts "
|
694
|
+
puts "\\#{command}[#{metrics}]{#{@chapter.image(id).path}}"
|
556
695
|
else
|
557
|
-
puts "
|
696
|
+
puts "\\#{command}[width=\\maxwidth]{#{@chapter.image(id).path}}"
|
558
697
|
end
|
559
698
|
else
|
560
699
|
warn "image not bound: #{id}"
|
561
700
|
puts '\begin{reviewdummyimage}'
|
562
|
-
puts "--[[path = #{id} (#{existence(id)})]]--"
|
701
|
+
puts "--[[path = #{escape(id)} (#{existence(id)})]]--"
|
563
702
|
lines.each do |line|
|
564
703
|
puts detab(line.rstrip)
|
565
704
|
end
|
566
705
|
end
|
567
706
|
|
568
|
-
|
569
|
-
|
570
|
-
puts macro('reviewindepimagecaption',
|
571
|
-
%Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)}))
|
707
|
+
if !caption_top?('image') && captionstr
|
708
|
+
puts captionstr
|
572
709
|
end
|
573
|
-
@doc_status[:caption] = nil
|
574
710
|
|
575
711
|
if @chapter.image(id).path
|
576
712
|
puts '\end{reviewimage}'
|
@@ -582,26 +718,35 @@ module ReVIEW
|
|
582
718
|
alias_method :numberlessimage, :indepimage
|
583
719
|
|
584
720
|
def table(lines, id = nil, caption = nil)
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
# error "too many table separator" if sepidx
|
591
|
-
sepidx ||= idx
|
592
|
-
next
|
721
|
+
if caption.present?
|
722
|
+
if @book.config.check_version('2', exception: false)
|
723
|
+
puts "\\begin{table}[h]%%#{id}"
|
724
|
+
else
|
725
|
+
puts "\\begin{table}%%#{id}"
|
593
726
|
end
|
594
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
595
727
|
end
|
596
|
-
rows = adjust_n_cols(rows)
|
597
728
|
|
729
|
+
sepidx, rows = parse_table_rows(lines)
|
598
730
|
begin
|
599
|
-
|
731
|
+
if caption_top?('table') && caption.present?
|
732
|
+
table_header(id, caption)
|
733
|
+
end
|
600
734
|
rescue KeyError
|
601
735
|
error "no such table: #{id}"
|
602
736
|
end
|
603
|
-
return if rows.empty?
|
604
737
|
table_begin(rows.first.size)
|
738
|
+
table_rows(sepidx, rows)
|
739
|
+
table_end
|
740
|
+
if caption.present?
|
741
|
+
unless caption_top?('table')
|
742
|
+
table_header(id, caption)
|
743
|
+
end
|
744
|
+
puts '\end{table}'
|
745
|
+
end
|
746
|
+
blank
|
747
|
+
end
|
748
|
+
|
749
|
+
def table_rows(sepidx, rows)
|
605
750
|
if sepidx
|
606
751
|
sepidx.times do
|
607
752
|
cno = -1
|
@@ -628,31 +773,18 @@ module ReVIEW
|
|
628
773
|
end)
|
629
774
|
end
|
630
775
|
end
|
631
|
-
table_end
|
632
776
|
end
|
633
777
|
|
634
778
|
def table_header(id, caption)
|
635
779
|
if id.nil?
|
636
780
|
if caption.present?
|
637
|
-
@table_caption = true
|
638
781
|
@doc_status[:caption] = true
|
639
|
-
if @book.config.check_version('2', exception: false)
|
640
|
-
puts "\\begin{table}[h]%%#{id}"
|
641
|
-
else
|
642
|
-
puts "\\begin{table}%%#{id}"
|
643
|
-
end
|
644
782
|
puts macro('reviewtablecaption*', compile_inline(caption))
|
645
783
|
@doc_status[:caption] = nil
|
646
784
|
end
|
647
785
|
else
|
648
786
|
if caption.present?
|
649
|
-
@table_caption = true
|
650
787
|
@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
788
|
puts macro('reviewtablecaption', compile_inline(caption))
|
657
789
|
@doc_status[:caption] = nil
|
658
790
|
end
|
@@ -755,12 +887,9 @@ module ReVIEW
|
|
755
887
|
|
756
888
|
def table_end
|
757
889
|
puts macro('end', 'reviewtable')
|
758
|
-
puts '\end{table}' if @table_caption
|
759
|
-
@table_caption = nil
|
760
890
|
@tsize = nil
|
761
891
|
@latex_tsize = nil
|
762
892
|
@cellwidth = nil
|
763
|
-
blank
|
764
893
|
end
|
765
894
|
|
766
895
|
def emtable(lines, caption = nil)
|
@@ -768,19 +897,22 @@ module ReVIEW
|
|
768
897
|
end
|
769
898
|
|
770
899
|
def imgtable(lines, id, caption = nil, metric = nil)
|
771
|
-
unless @chapter.
|
900
|
+
unless @chapter.image_bound?(id)
|
772
901
|
warn "image not bound: #{id}"
|
773
|
-
image_dummy
|
902
|
+
image_dummy(id, caption, lines)
|
774
903
|
return
|
775
904
|
end
|
776
905
|
|
906
|
+
captionstr = nil
|
777
907
|
begin
|
778
908
|
if caption.present?
|
779
|
-
@table_caption = true
|
780
|
-
@doc_status[:caption] = true
|
781
909
|
puts "\\begin{table}[h]%%#{id}"
|
782
|
-
|
910
|
+
@doc_status[:caption] = true
|
911
|
+
captionstr = macro('reviewimgtablecaption', compile_inline(caption))
|
783
912
|
@doc_status[:caption] = nil
|
913
|
+
if caption_top?('table')
|
914
|
+
puts captionstr
|
915
|
+
end
|
784
916
|
end
|
785
917
|
puts macro('label', table_label(id))
|
786
918
|
rescue ReVIEW::KeyError
|
@@ -788,8 +920,12 @@ module ReVIEW
|
|
788
920
|
end
|
789
921
|
imgtable_image(id, caption, metric)
|
790
922
|
|
791
|
-
|
792
|
-
|
923
|
+
if caption.present?
|
924
|
+
unless caption_top?('table')
|
925
|
+
puts captionstr
|
926
|
+
end
|
927
|
+
puts '\end{table}'
|
928
|
+
end
|
793
929
|
blank
|
794
930
|
end
|
795
931
|
|
@@ -797,46 +933,61 @@ module ReVIEW
|
|
797
933
|
metrics = parse_metric('latex', metric)
|
798
934
|
# image is always bound here
|
799
935
|
puts "\\begin{reviewimage}%%#{id}"
|
936
|
+
|
937
|
+
command = 'reviewincludegraphics'
|
938
|
+
if @book.config.check_version('2', exception: false)
|
939
|
+
command = 'includegraphics'
|
940
|
+
end
|
941
|
+
|
800
942
|
if metrics.present?
|
801
|
-
puts "
|
943
|
+
puts "\\#{command}[#{metrics}]{#{@chapter.image(id).path}}"
|
802
944
|
else
|
803
|
-
puts "
|
945
|
+
puts "\\#{command}[width=\\maxwidth]{#{@chapter.image(id).path}}"
|
804
946
|
end
|
805
947
|
puts '\end{reviewimage}'
|
806
948
|
end
|
807
949
|
|
808
950
|
def quote(lines)
|
809
|
-
latex_block
|
951
|
+
latex_block('quote', lines)
|
810
952
|
end
|
811
953
|
|
812
954
|
def center(lines)
|
813
|
-
latex_block
|
955
|
+
latex_block('center', lines)
|
814
956
|
end
|
815
957
|
|
816
958
|
alias_method :centering, :center
|
817
959
|
|
818
960
|
def flushright(lines)
|
819
|
-
latex_block
|
961
|
+
latex_block('flushright', lines)
|
820
962
|
end
|
821
963
|
|
822
964
|
def texequation(lines, id = nil, caption = '')
|
823
965
|
blank
|
966
|
+
captionstr = nil
|
824
967
|
|
825
968
|
if id
|
826
969
|
puts macro('begin', 'reviewequationblock')
|
827
970
|
if get_chap.nil?
|
828
|
-
|
971
|
+
captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
829
972
|
else
|
830
|
-
|
973
|
+
captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
|
831
974
|
end
|
832
975
|
end
|
833
976
|
|
977
|
+
if caption_top?('equation') && captionstr
|
978
|
+
puts captionstr
|
979
|
+
end
|
980
|
+
|
834
981
|
puts macro('begin', 'equation*')
|
835
982
|
lines.each do |line|
|
836
|
-
puts
|
983
|
+
puts line
|
837
984
|
end
|
838
985
|
puts macro('end', 'equation*')
|
839
986
|
|
987
|
+
if !caption_top?('equation') && captionstr
|
988
|
+
puts captionstr
|
989
|
+
end
|
990
|
+
|
840
991
|
if id
|
841
992
|
puts macro('end', 'reviewequationblock')
|
842
993
|
end
|
@@ -865,7 +1016,7 @@ module ReVIEW
|
|
865
1016
|
return true unless @book.config['draft']
|
866
1017
|
lines ||= []
|
867
1018
|
unless comment.blank?
|
868
|
-
lines.unshift
|
1019
|
+
lines.unshift(escape(comment))
|
869
1020
|
end
|
870
1021
|
str = lines.join('\par ')
|
871
1022
|
puts macro('pdfcomment', str)
|
@@ -977,6 +1128,9 @@ module ReVIEW
|
|
977
1128
|
|
978
1129
|
def footnote(id, content)
|
979
1130
|
if @book.config['footnotetext'] || @foottext[id]
|
1131
|
+
if @doc_status[:column]
|
1132
|
+
warn "//footnote[#{id}] is in the column block. It is recommended to move out of the column block."
|
1133
|
+
end
|
980
1134
|
puts macro("footnotetext[#{@chapter.footnote(id).number}]", compile_inline(content.strip))
|
981
1135
|
end
|
982
1136
|
end
|
@@ -984,7 +1138,7 @@ module ReVIEW
|
|
984
1138
|
def inline_fn(id)
|
985
1139
|
if @book.config['footnotetext']
|
986
1140
|
macro("footnotemark[#{@chapter.footnote(id).number}]", '')
|
987
|
-
elsif @doc_status[:caption] || @doc_status[:table] || @doc_status[:column]
|
1141
|
+
elsif @doc_status[:caption] || @doc_status[:table] || @doc_status[:column] || @doc_status[:dt]
|
988
1142
|
@foottext[id] = @chapter.footnote(id).number
|
989
1143
|
macro('protect\\footnotemark', '')
|
990
1144
|
else
|
@@ -997,7 +1151,7 @@ module ReVIEW
|
|
997
1151
|
BOUTEN = '・'.freeze
|
998
1152
|
|
999
1153
|
def inline_bou(str)
|
1000
|
-
|
1154
|
+
macro('reviewbou', escape(str))
|
1001
1155
|
end
|
1002
1156
|
|
1003
1157
|
def compile_ruby(base, ruby)
|
@@ -1103,7 +1257,7 @@ module ReVIEW
|
|
1103
1257
|
|
1104
1258
|
def inline_hd_chap(chap, id)
|
1105
1259
|
n = chap.headline_index.number(id)
|
1106
|
-
if
|
1260
|
+
if n.present? && chap.number && over_secnolevel?(n)
|
1107
1261
|
str = I18n.t('hd_quote', [chap.headline_index.number(id), compile_inline(chap.headline(id).caption)])
|
1108
1262
|
else
|
1109
1263
|
str = I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
|
@@ -1124,7 +1278,7 @@ module ReVIEW
|
|
1124
1278
|
error "unknown column: #{id}"
|
1125
1279
|
end
|
1126
1280
|
|
1127
|
-
def inline_raw(str)
|
1281
|
+
def inline_raw(str) # rubocop:disable Lint/UselessMethodDefinition
|
1128
1282
|
super(str)
|
1129
1283
|
end
|
1130
1284
|
|
@@ -1154,7 +1308,11 @@ module ReVIEW
|
|
1154
1308
|
|
1155
1309
|
def inline_icon(id)
|
1156
1310
|
if @chapter.image(id).path
|
1157
|
-
|
1311
|
+
command = 'reviewincludegraphics'
|
1312
|
+
if @book.config.check_version('2', exception: false)
|
1313
|
+
command = 'includegraphics'
|
1314
|
+
end
|
1315
|
+
macro(command, @chapter.image(id).path)
|
1158
1316
|
else
|
1159
1317
|
warn "image not bound: #{id}"
|
1160
1318
|
"\\verb|--[[path = #{id} (#{existence(id)})]]--|"
|
@@ -1193,7 +1351,12 @@ module ReVIEW
|
|
1193
1351
|
end
|
1194
1352
|
|
1195
1353
|
def bibpaper_bibpaper(_id, _caption, lines)
|
1196
|
-
|
1354
|
+
if @book.config['join_lines_by_lang']
|
1355
|
+
print split_paragraph(lines).join("\n\n")
|
1356
|
+
else
|
1357
|
+
print split_paragraph(lines).map(&:chomp).join("\n")
|
1358
|
+
end
|
1359
|
+
|
1197
1360
|
puts ''
|
1198
1361
|
end
|
1199
1362
|
|