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/topbuilder.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2008-
|
1
|
+
# Copyright (c) 2008-2020 Minero Aoki, Kenshi Muto
|
2
2
|
# 2002-2006 Minero Aoki
|
3
3
|
#
|
4
4
|
# This program is free software.
|
@@ -65,11 +65,11 @@ module ReVIEW
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def ul_item(lines)
|
68
|
-
puts "●\t#{lines
|
68
|
+
puts "●\t#{join_lines_to_paragraph(lines)}"
|
69
69
|
end
|
70
70
|
|
71
71
|
def ol_item(lines, num)
|
72
|
-
puts "#{num}\t#{lines
|
72
|
+
puts "#{num}\t#{join_lines_to_paragraph(lines)}"
|
73
73
|
end
|
74
74
|
|
75
75
|
def dt(line)
|
@@ -91,30 +91,50 @@ module ReVIEW
|
|
91
91
|
|
92
92
|
alias_method :lead, :read
|
93
93
|
|
94
|
-
def
|
94
|
+
def list(lines, id, caption, lang = nil)
|
95
95
|
blank
|
96
96
|
puts "◆→開始:#{@titles['list']}←◆"
|
97
|
+
begin
|
98
|
+
if caption_top?('list')
|
99
|
+
list_header(id, caption, lang)
|
100
|
+
blank
|
101
|
+
end
|
102
|
+
list_body(id, lines, lang)
|
103
|
+
unless caption_top?('list')
|
104
|
+
blank
|
105
|
+
list_header(id, caption, lang)
|
106
|
+
end
|
107
|
+
rescue KeyError
|
108
|
+
error "no such list: #{id}"
|
109
|
+
end
|
110
|
+
puts "◆→終了:#{@titles['list']}←◆"
|
111
|
+
blank
|
112
|
+
end
|
113
|
+
|
114
|
+
def list_header(id, caption, _lang)
|
97
115
|
if get_chap
|
98
116
|
puts %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
99
117
|
else
|
100
118
|
puts %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
101
119
|
end
|
102
|
-
blank
|
103
120
|
end
|
104
121
|
|
105
122
|
def list_body(_id, lines, _lang)
|
106
123
|
lines.each do |line|
|
107
124
|
puts detab(line)
|
108
125
|
end
|
109
|
-
puts "◆→終了:#{@titles['list']}←◆"
|
110
|
-
blank
|
111
126
|
end
|
112
127
|
|
113
128
|
def base_block(type, lines, caption = nil)
|
114
129
|
blank
|
115
130
|
puts "◆→開始:#{@titles[type]}←◆"
|
116
|
-
|
131
|
+
if caption_top?('list') && caption.present?
|
132
|
+
puts "■#{compile_inline(caption)}"
|
133
|
+
end
|
117
134
|
puts lines.join("\n")
|
135
|
+
if !caption_top?('list') && caption.present?
|
136
|
+
puts "■#{compile_inline(caption)}"
|
137
|
+
end
|
118
138
|
puts "◆→終了:#{@titles[type]}←◆"
|
119
139
|
blank
|
120
140
|
end
|
@@ -131,20 +151,43 @@ module ReVIEW
|
|
131
151
|
def emlistnum(lines, caption = nil, _lang = nil)
|
132
152
|
blank
|
133
153
|
puts "◆→開始:#{@titles['emlist']}←◆"
|
134
|
-
|
154
|
+
if caption_top?('list') && caption.present?
|
155
|
+
puts "■#{compile_inline(caption)}"
|
156
|
+
end
|
135
157
|
lines.each_with_index do |line, i|
|
136
158
|
puts((i + 1).to_s.rjust(2) + ": #{line}")
|
137
159
|
end
|
160
|
+
if !caption_top?('list') && caption.present?
|
161
|
+
puts "■#{compile_inline(caption)}"
|
162
|
+
end
|
138
163
|
puts "◆→終了:#{@titles['emlist']}←◆"
|
139
164
|
blank
|
140
165
|
end
|
141
166
|
|
167
|
+
def listnum(lines, id, caption, lang = nil)
|
168
|
+
blank
|
169
|
+
puts "◆→開始:#{@titles['list']}←◆"
|
170
|
+
begin
|
171
|
+
if caption_top?('list') && caption.present?
|
172
|
+
list_header(id, caption, lang)
|
173
|
+
blank
|
174
|
+
end
|
175
|
+
listnum_body(lines, lang)
|
176
|
+
if !caption_top?('list') && caption.present?
|
177
|
+
blank
|
178
|
+
list_header(id, caption, lang)
|
179
|
+
end
|
180
|
+
rescue KeyError
|
181
|
+
error "no such list: #{id}"
|
182
|
+
end
|
183
|
+
puts "◆→終了:#{@titles['list']}←◆"
|
184
|
+
blank
|
185
|
+
end
|
186
|
+
|
142
187
|
def listnum_body(lines, _lang)
|
143
188
|
lines.each_with_index do |line, i|
|
144
189
|
puts((i + 1).to_s.rjust(2) + ": #{line}")
|
145
190
|
end
|
146
|
-
puts "◆→終了:#{@titles['list']}←◆"
|
147
|
-
blank
|
148
191
|
end
|
149
192
|
|
150
193
|
def image(lines, id, caption, metric = nil)
|
@@ -152,13 +195,11 @@ module ReVIEW
|
|
152
195
|
metrics = " #{metrics}" if metrics.present?
|
153
196
|
blank
|
154
197
|
puts "◆→開始:#{@titles['image']}←◆"
|
155
|
-
if
|
156
|
-
|
157
|
-
|
158
|
-
puts "#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [@chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
198
|
+
if caption_top?('image')
|
199
|
+
image_header(id, caption)
|
200
|
+
blank
|
159
201
|
end
|
160
|
-
|
161
|
-
if @chapter.image(id).bound?
|
202
|
+
if @chapter.image_bound?(id)
|
162
203
|
puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
|
163
204
|
else
|
164
205
|
warn "image not bound: #{id}"
|
@@ -166,13 +207,47 @@ module ReVIEW
|
|
166
207
|
puts line
|
167
208
|
end
|
168
209
|
end
|
210
|
+
unless caption_top?('image')
|
211
|
+
blank
|
212
|
+
image_header(id, caption)
|
213
|
+
end
|
169
214
|
puts "◆→終了:#{@titles['image']}←◆"
|
170
215
|
blank
|
171
216
|
end
|
172
217
|
|
218
|
+
def image_header(id, caption)
|
219
|
+
if get_chap
|
220
|
+
puts "#{I18n.t('image')}#{I18n.t('format_number', [get_chap, @chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
221
|
+
else
|
222
|
+
puts "#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [@chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
173
226
|
def texequation(lines, id = nil, caption = '')
|
174
227
|
blank
|
175
228
|
puts "◆→開始:#{@titles['texequation']}←◆"
|
229
|
+
texequation_header(id, caption) if caption_top?('equation')
|
230
|
+
|
231
|
+
if @book.config['imgmath']
|
232
|
+
fontsize = @book.config['imgmath_options']['fontsize'].to_f
|
233
|
+
lineheight = @book.config['imgmath_options']['lineheight'].to_f
|
234
|
+
math_str = "\\begin{equation*}\n\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont\n#{lines.join("\n")}\n\\end{equation*}\n"
|
235
|
+
key = Digest::SHA256.hexdigest(math_str)
|
236
|
+
math_dir = File.join(@book.config['imagedir'], '_review_math_text')
|
237
|
+
Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
|
238
|
+
img_path = File.join(math_dir, "_gen_#{key}.#{@book.config['imgmath_options']['format']}")
|
239
|
+
defer_math_image(math_str, img_path, key)
|
240
|
+
puts "◆→math:#{File.basename(img_path)}←◆"
|
241
|
+
else
|
242
|
+
puts lines.join("\n")
|
243
|
+
end
|
244
|
+
|
245
|
+
texequation_header(id, caption) unless caption_top?('equation')
|
246
|
+
puts "◆→終了:#{@titles['texequation']}←◆"
|
247
|
+
blank
|
248
|
+
end
|
249
|
+
|
250
|
+
def texequation_header(id, caption)
|
176
251
|
if id
|
177
252
|
if get_chap
|
178
253
|
puts "#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
@@ -180,49 +255,14 @@ module ReVIEW
|
|
180
255
|
puts "#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
181
256
|
end
|
182
257
|
end
|
183
|
-
puts lines.join("\n")
|
184
|
-
puts "◆→終了:#{@titles['texequation']}←◆"
|
185
|
-
blank
|
186
258
|
end
|
187
259
|
|
188
260
|
def table(lines, id = nil, caption = nil)
|
189
261
|
blank
|
190
262
|
puts "◆→開始:#{@titles['table']}←◆"
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
lines.each_with_index do |line, idx|
|
195
|
-
if /\A[\=\-]{12}/ =~ line
|
196
|
-
# just ignore
|
197
|
-
# error "too many table separator" if sepidx
|
198
|
-
sepidx ||= idx
|
199
|
-
next
|
200
|
-
end
|
201
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
202
|
-
end
|
203
|
-
rows = adjust_n_cols(rows)
|
204
|
-
|
205
|
-
begin
|
206
|
-
table_header id, caption if caption.present?
|
207
|
-
rescue KeyError
|
208
|
-
error "no such table: #{id}"
|
209
|
-
end
|
210
|
-
return if rows.empty?
|
211
|
-
table_begin rows.first.size
|
212
|
-
if sepidx
|
213
|
-
sepidx.times do
|
214
|
-
tr(rows.shift.map { |s| th(s) })
|
215
|
-
end
|
216
|
-
rows.each do |cols|
|
217
|
-
tr(cols.map { |s| td(s) })
|
218
|
-
end
|
219
|
-
else
|
220
|
-
rows.each do |cols|
|
221
|
-
h, *cs = *cols
|
222
|
-
tr([th(h)] + cs.map { |s| td(s) })
|
223
|
-
end
|
224
|
-
end
|
225
|
-
table_end
|
263
|
+
super(lines, id, caption, true)
|
264
|
+
puts "◆→終了:#{@titles['table']}←◆"
|
265
|
+
blank
|
226
266
|
end
|
227
267
|
|
228
268
|
def th(str)
|
@@ -230,15 +270,13 @@ module ReVIEW
|
|
230
270
|
end
|
231
271
|
|
232
272
|
def table_end
|
233
|
-
puts "◆→終了:#{@titles['table']}←◆"
|
234
|
-
blank
|
235
273
|
end
|
236
274
|
|
237
275
|
def comment(lines, comment = nil)
|
238
276
|
return unless @book.config['draft']
|
239
277
|
lines ||= []
|
240
278
|
unless comment.blank?
|
241
|
-
lines.unshift
|
279
|
+
lines.unshift(comment)
|
242
280
|
end
|
243
281
|
str = lines.join("\n")
|
244
282
|
puts "◆→#{str}←◆"
|
@@ -359,7 +397,17 @@ module ReVIEW
|
|
359
397
|
end
|
360
398
|
|
361
399
|
def inline_m(str)
|
362
|
-
|
400
|
+
if @book.config['imgmath']
|
401
|
+
math_str = '$' + str + '$'
|
402
|
+
key = Digest::SHA256.hexdigest(str)
|
403
|
+
math_dir = File.join(@book.config['imagedir'], '_review_math_text')
|
404
|
+
Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
|
405
|
+
img_path = File.join(math_dir, "_gen_#{key}.#{@book.config['imgmath_options']['format']}")
|
406
|
+
defer_math_image(math_str, img_path, key)
|
407
|
+
%Q(◆→TeX式ここから←◆◆→math:#{File.basename(img_path)}←◆◆→TeX式ここまで←◆)
|
408
|
+
else
|
409
|
+
%Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
|
410
|
+
end
|
363
411
|
end
|
364
412
|
|
365
413
|
def bibpaper_header(id, caption)
|
@@ -396,17 +444,48 @@ module ReVIEW
|
|
396
444
|
blank
|
397
445
|
end
|
398
446
|
|
447
|
+
def common_block_begin(type, _level, _label, caption = nil)
|
448
|
+
blank
|
449
|
+
puts "◆→開始:#{@titles[type]}←◆"
|
450
|
+
puts '■' + compile_inline(caption) if caption.present?
|
451
|
+
end
|
452
|
+
|
453
|
+
def common_block_end(type, _level)
|
454
|
+
puts "◆→終了:#{@titles[type]}←◆"
|
455
|
+
blank
|
456
|
+
end
|
457
|
+
|
458
|
+
CAPTION_TITLES.each do |name|
|
459
|
+
class_eval %Q(
|
460
|
+
def #{name}_begin(caption = nil)
|
461
|
+
check_nested_minicolumn
|
462
|
+
@doc_status[:minicolumn] = '#{name}'
|
463
|
+
common_block_begin('#{name}', nil, nil, caption)
|
464
|
+
end
|
465
|
+
|
466
|
+
def #{name}_end
|
467
|
+
common_block_end('#{name}', nil)
|
468
|
+
@doc_status[:minicolumn] = nil
|
469
|
+
end
|
470
|
+
), __FILE__, __LINE__ - 11
|
471
|
+
end
|
472
|
+
|
399
473
|
def indepimage(_lines, id, caption = nil, metric = nil)
|
400
474
|
metrics = parse_metric('top', metric)
|
401
475
|
metrics = " #{metrics}" if metrics.present?
|
402
476
|
blank
|
477
|
+
if caption_top?('image') && caption.present?
|
478
|
+
puts "図 #{compile_inline(caption)}"
|
479
|
+
end
|
403
480
|
begin
|
404
481
|
puts "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}#{metrics}←◆"
|
405
482
|
rescue
|
406
483
|
warn "image not bound: #{id}"
|
407
484
|
puts "◆→画像 #{id}←◆"
|
408
485
|
end
|
409
|
-
|
486
|
+
if !caption_top?('image') && caption.present?
|
487
|
+
puts "図 #{compile_inline(caption)}"
|
488
|
+
end
|
410
489
|
blank
|
411
490
|
end
|
412
491
|
|
data/lib/review/update.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2018 Kenshi Muto
|
2
|
+
# Copyright (c) 2018-2020 Kenshi Muto
|
3
3
|
#
|
4
4
|
# This program is free software.
|
5
5
|
# You can distribute or modify this program under the terms of
|
@@ -20,14 +20,14 @@ module ReVIEW
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# should be
|
23
|
-
TARGET_VERSION = '
|
23
|
+
TARGET_VERSION = '5.0'
|
24
24
|
EPUB_VERSION = '3'
|
25
25
|
HTML_VERSION = '5'
|
26
26
|
TEX_DOCUMENTCLASS = ['review-jsbook', 'review-jlreq']
|
27
27
|
TEX_DOCUMENTCLASS_BAD = ['jsbook', nil]
|
28
28
|
TEX_DOCUMENTCLASS_OPTS = 'media=print,paper=a5'
|
29
29
|
TEX_COMMAND = 'uplatex'
|
30
|
-
TEX_OPTIONS = '-interaction=nonstopmode -file-line-error'
|
30
|
+
TEX_OPTIONS = '-interaction=nonstopmode -file-line-error -halt-on-error'
|
31
31
|
DVI_COMMAND = 'dvipdfmx'
|
32
32
|
DVI_OPTIONS = '-d 5 -z 9'
|
33
33
|
|
@@ -126,7 +126,7 @@ module ReVIEW
|
|
126
126
|
content = File.read(yml)
|
127
127
|
content.gsub!(/^(\s*)#{key}:.*$/, '\1' + "#{key}: #{val}")
|
128
128
|
if @backup
|
129
|
-
FileUtils.mv
|
129
|
+
FileUtils.mv(yml, "#{yml}-old")
|
130
130
|
end
|
131
131
|
File.write(yml, content)
|
132
132
|
end
|
@@ -145,8 +145,8 @@ module ReVIEW
|
|
145
145
|
|
146
146
|
begin
|
147
147
|
opts.parse!(args)
|
148
|
-
rescue OptionParser::ParseError =>
|
149
|
-
@logger.error
|
148
|
+
rescue OptionParser::ParseError => e
|
149
|
+
@logger.error e.message
|
150
150
|
$stderr.puts opts.help
|
151
151
|
raise ApplicationError
|
152
152
|
end
|
@@ -239,7 +239,7 @@ module ReVIEW
|
|
239
239
|
def update_version
|
240
240
|
@config_ymls.each do |yml|
|
241
241
|
config = YAML.load_file(yml)
|
242
|
-
if config['review_version'].to_f == TARGET_VERSION.to_f
|
242
|
+
if config['review_version'].to_f.round(1) == TARGET_VERSION.to_f.round(1)
|
243
243
|
next
|
244
244
|
end
|
245
245
|
|
@@ -257,7 +257,7 @@ module ReVIEW
|
|
257
257
|
def update_rakefile(dir)
|
258
258
|
taskdir = File.join(dir, 'lib/tasks')
|
259
259
|
unless File.exist?(taskdir)
|
260
|
-
FileUtils.mkdir_p
|
260
|
+
FileUtils.mkdir_p(taskdir)
|
261
261
|
end
|
262
262
|
|
263
263
|
master_rakefile = File.join(@review_dir, 'samples/sample-book/src/Rakefile')
|
@@ -266,13 +266,13 @@ module ReVIEW
|
|
266
266
|
if File.exist?(target_rakefile)
|
267
267
|
if Digest::SHA256.hexdigest(File.read(target_rakefile)) != Digest::SHA256.hexdigest(File.read(master_rakefile))
|
268
268
|
if confirm('%s will be overridden with Re:VIEW version (%s). Do you really proceed?', ['Rakefile', master_rakefile])
|
269
|
-
FileUtils.mv
|
270
|
-
FileUtils.cp
|
269
|
+
FileUtils.mv(target_rakefile, "#{target_rakefile}-old")
|
270
|
+
FileUtils.cp(master_rakefile, target_rakefile)
|
271
271
|
end
|
272
272
|
end
|
273
273
|
else
|
274
274
|
@logger.info t('new file %s is created.', [target_rakefile]) unless @force
|
275
|
-
FileUtils.cp
|
275
|
+
FileUtils.cp(master_rakefile, target_rakefile)
|
276
276
|
end
|
277
277
|
|
278
278
|
master_rakefile = File.join(@review_dir, 'samples/sample-book/src/lib/tasks/review.rake')
|
@@ -280,13 +280,13 @@ module ReVIEW
|
|
280
280
|
if File.exist?(target_rakefile)
|
281
281
|
if Digest::SHA256.hexdigest(File.read(target_rakefile)) != Digest::SHA256.hexdigest(File.read(master_rakefile))
|
282
282
|
if confirm('%s will be overridden with Re:VIEW version (%s). Do you really proceed?', ['lib/tasks/review.rake', master_rakefile])
|
283
|
-
FileUtils.mv
|
284
|
-
FileUtils.cp
|
283
|
+
FileUtils.mv(target_rakefile, "#{target_rakefile}-old")
|
284
|
+
FileUtils.cp(master_rakefile, target_rakefile)
|
285
285
|
end
|
286
286
|
end
|
287
287
|
else
|
288
288
|
@logger.info t('new file %s is created.', [target_rakefile]) unless @force
|
289
|
-
FileUtils.cp
|
289
|
+
FileUtils.cp(master_rakefile, target_rakefile)
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
@@ -469,7 +469,7 @@ module ReVIEW
|
|
469
469
|
def update_tex_stys(template, dir)
|
470
470
|
texmacrodir = File.join(dir, 'sty')
|
471
471
|
unless File.exist?(texmacrodir)
|
472
|
-
FileUtils.mkdir
|
472
|
+
FileUtils.mkdir(texmacrodir)
|
473
473
|
end
|
474
474
|
|
475
475
|
tdir = File.join(@review_dir, 'templates/latex', template)
|
@@ -479,7 +479,7 @@ module ReVIEW
|
|
479
479
|
unless File.exist?(target_styfile)
|
480
480
|
# just copy
|
481
481
|
@logger.info t('new file %s is created.', [target_styfile]) unless @force
|
482
|
-
FileUtils.cp
|
482
|
+
FileUtils.cp(master_styfile, target_styfile)
|
483
483
|
next
|
484
484
|
end
|
485
485
|
if File.basename(target_styfile) == 'review-custom.sty'
|
@@ -492,20 +492,20 @@ module ReVIEW
|
|
492
492
|
end
|
493
493
|
|
494
494
|
if confirm('%s will be overridden with Re:VIEW version (%s). Do you really proceed?', [target_styfile, master_styfile])
|
495
|
-
FileUtils.mv
|
496
|
-
FileUtils.cp
|
495
|
+
FileUtils.mv(target_styfile, "#{target_styfile}-old")
|
496
|
+
FileUtils.cp(master_styfile, target_styfile)
|
497
497
|
end
|
498
498
|
end
|
499
499
|
|
500
500
|
if template == 'review-jsbook'
|
501
501
|
unless File.exist?(File.join(texmacrodir, 'jsbook.cls'))
|
502
502
|
@logger.info t('new file %s is created.', [File.join(texmacrodir, 'jsbook.cls')]) unless @force
|
503
|
-
FileUtils.cp
|
503
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/jsclasses/jsbook.cls'), File.join(texmacrodir, 'jsbook.cls'))
|
504
504
|
end
|
505
505
|
|
506
506
|
unless File.exist?(File.join(texmacrodir, 'gentombow.sty'))
|
507
507
|
@logger.info t('new file %s is created.', [File.join(texmacrodir, 'gentombow.sty')]) unless @force
|
508
|
-
FileUtils.cp
|
508
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/gentombow/gentombow.sty'), File.join(texmacrodir, 'gentombow.sty'))
|
509
509
|
end
|
510
510
|
end
|
511
511
|
end
|
@@ -513,11 +513,11 @@ module ReVIEW
|
|
513
513
|
def update_tex_command
|
514
514
|
@tex_ymls.each do |yml|
|
515
515
|
config = YAML.load_file(yml)
|
516
|
-
if !config['texcommand'] || config['texcommand'] !~ /\s
|
516
|
+
if !config['texcommand'] || config['texcommand'] !~ /\s+-/
|
517
517
|
next
|
518
518
|
end
|
519
519
|
# option should be moved to texoptions
|
520
|
-
cmd, opts = config['texcommand'].split(/\s
|
520
|
+
cmd, opts = config['texcommand'].split(/\s+-/, 2)
|
521
521
|
opts = "-#{opts}"
|
522
522
|
|
523
523
|
unless confirm("%s: 'texcommand' has options ('%s'). Move it to 'texoptions'?", [File.basename(yml), opts])
|
@@ -537,12 +537,12 @@ module ReVIEW
|
|
537
537
|
def update_dvi_command
|
538
538
|
@tex_ymls.each do |yml|
|
539
539
|
config = YAML.load_file(yml)
|
540
|
-
if !config['dvicommand'] || config['dvicommand'] !~ /\s
|
540
|
+
if !config['dvicommand'] || config['dvicommand'] !~ /\s+-/
|
541
541
|
next
|
542
542
|
end
|
543
543
|
|
544
544
|
# option should be moved to dvioptions
|
545
|
-
cmd, opts = config['dvicommand'].split(/\s
|
545
|
+
cmd, opts = config['dvicommand'].split(/\s+-/, 2)
|
546
546
|
opts = "-#{opts}"
|
547
547
|
|
548
548
|
unless confirm("%s: 'dvicommand' has options ('%s'). Move it to 'dvioptions'?", [File.basename(yml), opts])
|