review 3.2.0 → 5.1.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-tex.yml +31 -0
- data/.github/workflows/ruby-win.yml +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +167 -42
- data/.travis.yml +1 -1
- data/Dockerfile +21 -5
- data/NEWS.ja.md +428 -1
- data/NEWS.md +429 -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 +5 -5
- data/bin/review-check +13 -17
- data/bin/review-checkdep +3 -6
- data/bin/review-compile +13 -22
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +14 -0
- data/bin/review-index +5 -86
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +11 -13
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +7 -7
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +67 -16
- data/doc/config.yml.sample-simple +4 -3
- data/doc/format.ja.md +133 -21
- data/doc/format.md +135 -34
- 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 +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 +89 -90
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +51 -29
- data/lib/review/book/index.rb +42 -248
- 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 +5 -5
- data/lib/review/builder.rb +171 -54
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +15 -17
- data/lib/review/compiler.rb +240 -102
- data/lib/review/configure.rb +101 -12
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +120 -118
- 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 +147 -149
- data/lib/review/htmlutils.rb +10 -14
- data/lib/review/i18n.rb +4 -3
- data/lib/review/idgxmlbuilder.rb +229 -103
- data/lib/review/idgxmlmaker.rb +188 -0
- data/lib/review/img_math.rb +245 -0
- data/lib/review/index_builder.rb +654 -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 +124 -41
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +249 -97
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +113 -3
- data/lib/review/logger.rb +43 -8
- data/lib/review/makerhelper.rb +13 -186
- data/lib/review/markdownbuilder.rb +75 -39
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +88 -83
- data/lib/review/plaintextbuilder.rb +158 -83
- data/lib/review/preprocessor.rb +30 -24
- data/lib/review/rstbuilder.rb +58 -39
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +6 -0
- data/lib/review/textmaker.rb +29 -17
- data/lib/review/textutils.rb +68 -2
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +147 -61
- data/lib/review/update.rb +27 -28
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +36 -35
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +4 -0
- data/review.gemspec +8 -5
- 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-epub2.yml +1 -1
- 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 +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +45 -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 +3 -1
- data/samples/syntax-book/ch02.re +28 -21
- data/samples/syntax-book/ch03.re +4 -7
- 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/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/review.rake +30 -15
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -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 +45 -27
- 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 +124 -37
- data/templates/latex/review-jlreq/review-jlreq.cls +29 -22
- data/templates/latex/review-jlreq/review-style.sty +9 -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 +46 -5
- data/templates/latex/review-jsbook/review-base.sty +111 -30
- data/templates/latex/review-jsbook/review-jsbook.cls +16 -2
- data/templates/latex/review-jsbook/review-style.sty +10 -2
- 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 +20 -9
- data/test/assets/test_template_backmatter.tex +20 -9
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +123 -78
- 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 +19 -42
- 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 +16 -9
- data/test/test_helper.rb +23 -11
- data/test/test_htmlbuilder.rb +1083 -114
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +37 -37
- data/test/test_idgxmlbuilder.rb +627 -27
- 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 +1189 -59
- data/test/test_latexbuilder_v2.rb +74 -34
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +17 -4
- data/test/test_makerhelper.rb +2 -14
- data/test/test_markdownbuilder.rb +77 -4
- data/test/test_md2inaobuilder.rb +12 -2
- data/test/test_pdfmaker.rb +101 -12
- data/test/test_pdfmaker_cmd.rb +102 -8
- data/test/test_plaintextbuilder.rb +562 -31
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +58 -5
- 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_textutils.rb +109 -2
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +400 -17
- data/test/test_update.rb +53 -44
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_yamlloader.rb +13 -0
- 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 +136 -23
- 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 -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)
|
@@ -78,7 +78,7 @@ module ReVIEW
|
|
78
78
|
|
79
79
|
def dd(lines)
|
80
80
|
split_paragraph(lines).each do |paragraph|
|
81
|
-
puts "\t#{paragraph.
|
81
|
+
puts "\t#{paragraph.delete("\n")}"
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -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,44 @@ 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['math_format'] == '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
|
+
img_path = @img_math.defer_math_image(math_str, key)
|
237
|
+
puts "◆→math:#{File.basename(img_path)}←◆"
|
238
|
+
else
|
239
|
+
puts lines.join("\n")
|
240
|
+
end
|
241
|
+
|
242
|
+
texequation_header(id, caption) unless caption_top?('equation')
|
243
|
+
puts "◆→終了:#{@titles['texequation']}←◆"
|
244
|
+
blank
|
245
|
+
end
|
246
|
+
|
247
|
+
def texequation_header(id, caption)
|
176
248
|
if id
|
177
249
|
if get_chap
|
178
250
|
puts "#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
@@ -180,49 +252,14 @@ module ReVIEW
|
|
180
252
|
puts "#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
181
253
|
end
|
182
254
|
end
|
183
|
-
puts lines.join("\n")
|
184
|
-
puts "◆→終了:#{@titles['texequation']}←◆"
|
185
|
-
blank
|
186
255
|
end
|
187
256
|
|
188
257
|
def table(lines, id = nil, caption = nil)
|
189
|
-
rows = []
|
190
|
-
sepidx = nil
|
191
|
-
lines.each_with_index do |line, idx|
|
192
|
-
if /\A[\=\-]{12}/ =~ line
|
193
|
-
# just ignore
|
194
|
-
# error "too many table separator" if sepidx
|
195
|
-
sepidx ||= idx
|
196
|
-
next
|
197
|
-
end
|
198
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
199
|
-
end
|
200
|
-
rows = adjust_n_cols(rows)
|
201
|
-
error 'no rows in the table' if rows.empty?
|
202
|
-
|
203
258
|
blank
|
204
259
|
puts "◆→開始:#{@titles['table']}←◆"
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
rescue KeyError
|
209
|
-
error "no such table: #{id}"
|
210
|
-
end
|
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
|
260
|
+
super(lines, id, caption, true)
|
261
|
+
puts "◆→終了:#{@titles['table']}←◆"
|
262
|
+
blank
|
226
263
|
end
|
227
264
|
|
228
265
|
def th(str)
|
@@ -230,15 +267,14 @@ module ReVIEW
|
|
230
267
|
end
|
231
268
|
|
232
269
|
def table_end
|
233
|
-
puts "◆→終了:#{@titles['table']}←◆"
|
234
|
-
blank
|
235
270
|
end
|
236
271
|
|
237
272
|
def comment(lines, comment = nil)
|
238
273
|
return unless @book.config['draft']
|
274
|
+
|
239
275
|
lines ||= []
|
240
276
|
unless comment.blank?
|
241
|
-
lines.unshift
|
277
|
+
lines.unshift(comment)
|
242
278
|
end
|
243
279
|
str = lines.join("\n")
|
244
280
|
puts "◆→#{str}←◆"
|
@@ -329,6 +365,18 @@ module ReVIEW
|
|
329
365
|
"@#{str}@◆→@〜@部分に下線←◆"
|
330
366
|
end
|
331
367
|
|
368
|
+
def inline_ins(str)
|
369
|
+
"◆→開始:挿入表現←◆#{str}◆→終了:挿入表現←◆"
|
370
|
+
end
|
371
|
+
|
372
|
+
def inline_del(str)
|
373
|
+
"◆→開始:削除表現←◆#{str}◆→終了:削除表現←◆"
|
374
|
+
end
|
375
|
+
|
376
|
+
def inline_tcy(str)
|
377
|
+
"◆→開始:回転←◆#{str}◆→終了:縦回転←◆"
|
378
|
+
end
|
379
|
+
|
332
380
|
def inline_icon(id)
|
333
381
|
begin
|
334
382
|
"◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
|
@@ -359,7 +407,14 @@ module ReVIEW
|
|
359
407
|
end
|
360
408
|
|
361
409
|
def inline_m(str)
|
362
|
-
|
410
|
+
if @book.config['math_format'] == 'imgmath'
|
411
|
+
math_str = '$' + str + '$'
|
412
|
+
key = Digest::SHA256.hexdigest(str)
|
413
|
+
img_path = @img_math.defer_math_image(math_str, key)
|
414
|
+
%Q(◆→TeX式ここから←◆◆→math:#{File.basename(img_path)}←◆◆→TeX式ここまで←◆)
|
415
|
+
else
|
416
|
+
%Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
|
417
|
+
end
|
363
418
|
end
|
364
419
|
|
365
420
|
def bibpaper_header(id, caption)
|
@@ -396,17 +451,48 @@ module ReVIEW
|
|
396
451
|
blank
|
397
452
|
end
|
398
453
|
|
454
|
+
def common_block_begin(type, _level, _label, caption = nil)
|
455
|
+
blank
|
456
|
+
puts "◆→開始:#{@titles[type]}←◆"
|
457
|
+
puts '■' + compile_inline(caption) if caption.present?
|
458
|
+
end
|
459
|
+
|
460
|
+
def common_block_end(type, _level)
|
461
|
+
puts "◆→終了:#{@titles[type]}←◆"
|
462
|
+
blank
|
463
|
+
end
|
464
|
+
|
465
|
+
CAPTION_TITLES.each do |name|
|
466
|
+
class_eval %Q(
|
467
|
+
def #{name}_begin(caption = nil)
|
468
|
+
check_nested_minicolumn
|
469
|
+
@doc_status[:minicolumn] = '#{name}'
|
470
|
+
common_block_begin('#{name}', nil, nil, caption)
|
471
|
+
end
|
472
|
+
|
473
|
+
def #{name}_end
|
474
|
+
common_block_end('#{name}', nil)
|
475
|
+
@doc_status[:minicolumn] = nil
|
476
|
+
end
|
477
|
+
), __FILE__, __LINE__ - 11
|
478
|
+
end
|
479
|
+
|
399
480
|
def indepimage(_lines, id, caption = nil, metric = nil)
|
400
481
|
metrics = parse_metric('top', metric)
|
401
482
|
metrics = " #{metrics}" if metrics.present?
|
402
483
|
blank
|
484
|
+
if caption_top?('image') && caption.present?
|
485
|
+
puts "図 #{compile_inline(caption)}"
|
486
|
+
end
|
403
487
|
begin
|
404
488
|
puts "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}#{metrics}←◆"
|
405
489
|
rescue
|
406
490
|
warn "image not bound: #{id}"
|
407
491
|
puts "◆→画像 #{id}←◆"
|
408
492
|
end
|
409
|
-
|
493
|
+
if !caption_top?('image') && caption.present?
|
494
|
+
puts "図 #{compile_inline(caption)}"
|
495
|
+
end
|
410
496
|
blank
|
411
497
|
end
|
412
498
|
|
data/lib/review/update.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2018-
|
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
|
@@ -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
|
|
@@ -301,6 +301,7 @@ module ReVIEW
|
|
301
301
|
if !config['htmlversion'].present? || config['htmlversion'].to_f >= HTML_VERSION.to_f
|
302
302
|
next
|
303
303
|
end
|
304
|
+
|
304
305
|
if confirm("%s: Update '%s' to '%s' from '%s'?", [File.basename(yml), 'htmlversion', HTML_VERSION, config['htmlversion']])
|
305
306
|
rewrite_yml(yml, 'htmlversion', HTML_VERSION)
|
306
307
|
end
|
@@ -313,6 +314,7 @@ module ReVIEW
|
|
313
314
|
if !config['chapter_quote'].present? || config['chapter_quote'].scan('%s').size != 1
|
314
315
|
next
|
315
316
|
end
|
317
|
+
|
316
318
|
v = config['chapter_quote'].sub('%s', '%s %s')
|
317
319
|
if confirm("%s: 'chapter_quote' now takes 2 values. Update '%s' to '%s'?", [File.basename(yml), config['chapter_quote'], v])
|
318
320
|
rewrite_yml(yml, 'chapter_quote', v)
|
@@ -414,9 +416,7 @@ module ReVIEW
|
|
414
416
|
opts << "paper=#{v.sub('j', '').sub('paper', '')}"
|
415
417
|
when /[\d.]+ptj/ # not cared...
|
416
418
|
opts << "fontsize=#{v.sub('j', '')}"
|
417
|
-
when /[\d.]+pt/
|
418
|
-
opts << "fontsize=#{v}"
|
419
|
-
when /[\d.]+Q/
|
419
|
+
when /[\d.]+pt/, /[\d.]+Q/
|
420
420
|
opts << "fontsize=#{v}"
|
421
421
|
when 'landscape', 'oneside', 'twoside', 'vartwoside', 'onecolumn',
|
422
422
|
'twocolumn', 'titlepage', 'notitlepage', 'openright',
|
@@ -442,9 +442,7 @@ module ReVIEW
|
|
442
442
|
opts << "paper=#{v.sub('j', '').sub('paper', '')}"
|
443
443
|
when /[\d.]+ptj/ # not cared...
|
444
444
|
opts << "fontsize=#{v.sub('j', '')}"
|
445
|
-
when /[\d.]+pt/
|
446
|
-
opts << "fontsize=#{v}"
|
447
|
-
when /[\d.]+Q/
|
445
|
+
when /[\d.]+pt/, /[\d.]+Q/
|
448
446
|
opts << "fontsize=#{v}"
|
449
447
|
when 'landscape', 'oneside', 'twoside', 'onecolumn', 'twocolumn', 'titlepage', 'notitlepage', 'openright', 'openany', 'leqno', 'fleqn', 'draft', 'final', 'report'
|
450
448
|
# pass-through
|
@@ -469,7 +467,7 @@ module ReVIEW
|
|
469
467
|
def update_tex_stys(template, dir)
|
470
468
|
texmacrodir = File.join(dir, 'sty')
|
471
469
|
unless File.exist?(texmacrodir)
|
472
|
-
FileUtils.mkdir
|
470
|
+
FileUtils.mkdir(texmacrodir)
|
473
471
|
end
|
474
472
|
|
475
473
|
tdir = File.join(@review_dir, 'templates/latex', template)
|
@@ -479,7 +477,7 @@ module ReVIEW
|
|
479
477
|
unless File.exist?(target_styfile)
|
480
478
|
# just copy
|
481
479
|
@logger.info t('new file %s is created.', [target_styfile]) unless @force
|
482
|
-
FileUtils.cp
|
480
|
+
FileUtils.cp(master_styfile, target_styfile)
|
483
481
|
next
|
484
482
|
end
|
485
483
|
if File.basename(target_styfile) == 'review-custom.sty'
|
@@ -492,20 +490,20 @@ module ReVIEW
|
|
492
490
|
end
|
493
491
|
|
494
492
|
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
|
493
|
+
FileUtils.mv(target_styfile, "#{target_styfile}-old")
|
494
|
+
FileUtils.cp(master_styfile, target_styfile)
|
497
495
|
end
|
498
496
|
end
|
499
497
|
|
500
498
|
if template == 'review-jsbook'
|
501
499
|
unless File.exist?(File.join(texmacrodir, 'jsbook.cls'))
|
502
500
|
@logger.info t('new file %s is created.', [File.join(texmacrodir, 'jsbook.cls')]) unless @force
|
503
|
-
FileUtils.cp
|
501
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/jsclasses/jsbook.cls'), File.join(texmacrodir, 'jsbook.cls'))
|
504
502
|
end
|
505
503
|
|
506
504
|
unless File.exist?(File.join(texmacrodir, 'gentombow.sty'))
|
507
505
|
@logger.info t('new file %s is created.', [File.join(texmacrodir, 'gentombow.sty')]) unless @force
|
508
|
-
FileUtils.cp
|
506
|
+
FileUtils.cp(File.join(@review_dir, 'vendor/gentombow/gentombow.sty'), File.join(texmacrodir, 'gentombow.sty'))
|
509
507
|
end
|
510
508
|
end
|
511
509
|
end
|
@@ -513,11 +511,12 @@ module ReVIEW
|
|
513
511
|
def update_tex_command
|
514
512
|
@tex_ymls.each do |yml|
|
515
513
|
config = YAML.load_file(yml)
|
516
|
-
if !config['texcommand'] || config['texcommand'] !~ /\s
|
514
|
+
if !config['texcommand'] || config['texcommand'] !~ /\s+-/
|
517
515
|
next
|
518
516
|
end
|
517
|
+
|
519
518
|
# option should be moved to texoptions
|
520
|
-
cmd, opts = config['texcommand'].split(/\s
|
519
|
+
cmd, opts = config['texcommand'].split(/\s+-/, 2)
|
521
520
|
opts = "-#{opts}"
|
522
521
|
|
523
522
|
unless confirm("%s: 'texcommand' has options ('%s'). Move it to 'texoptions'?", [File.basename(yml), opts])
|
@@ -537,12 +536,12 @@ module ReVIEW
|
|
537
536
|
def update_dvi_command
|
538
537
|
@tex_ymls.each do |yml|
|
539
538
|
config = YAML.load_file(yml)
|
540
|
-
if !config['dvicommand'] || config['dvicommand'] !~ /\s
|
539
|
+
if !config['dvicommand'] || config['dvicommand'] !~ /\s+-/
|
541
540
|
next
|
542
541
|
end
|
543
542
|
|
544
543
|
# option should be moved to dvioptions
|
545
|
-
cmd, opts = config['dvicommand'].split(/\s
|
544
|
+
cmd, opts = config['dvicommand'].split(/\s+-/, 2)
|
546
545
|
opts = "-#{opts}"
|
547
546
|
|
548
547
|
unless confirm("%s: 'dvicommand' has options ('%s'). Move it to 'dvioptions'?", [File.basename(yml), opts])
|