review 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +90 -66
- data/.travis.yml +1 -1
- data/Gemfile +0 -1
- data/NEWS.ja.md +82 -0
- data/NEWS.md +83 -0
- data/README.md +5 -3
- data/Rakefile +8 -8
- data/bin/review +1 -5
- data/bin/review-catalog-converter +22 -27
- data/bin/review-check +36 -43
- data/bin/review-checkdep +10 -15
- data/bin/review-compile +37 -55
- data/bin/review-epubmaker +4 -5
- data/bin/review-index +21 -29
- data/bin/review-init +26 -37
- data/bin/review-pdfmaker +0 -2
- data/bin/review-preproc +25 -45
- data/bin/review-validate +19 -18
- data/bin/review-vol +15 -27
- data/doc/config.yml.sample +5 -2
- data/doc/format.ja.md +20 -1
- data/doc/format.md +21 -5
- data/doc/images/review-generate.png +0 -0
- data/lib/epubmaker.rb +1 -3
- data/lib/epubmaker/content.rb +24 -27
- data/lib/epubmaker/epubcommon.rb +135 -148
- data/lib/epubmaker/epubv2.rb +39 -46
- data/lib/epubmaker/epubv3.rb +93 -103
- data/lib/epubmaker/producer.rb +138 -151
- data/lib/epubmaker/zip_exporter.rb +21 -26
- data/lib/review/book.rb +3 -6
- data/lib/review/book/base.rb +78 -103
- data/lib/review/book/chapter.rb +36 -40
- data/lib/review/book/compilable.rb +28 -31
- data/lib/review/book/image_finder.rb +6 -13
- data/lib/review/book/index.rb +100 -121
- data/lib/review/book/page_metric.rb +2 -7
- data/lib/review/book/part.rb +18 -20
- data/lib/review/book/volume.rb +9 -13
- data/lib/review/builder.rb +81 -116
- data/lib/review/catalog.rb +15 -19
- data/lib/review/compiler.rb +64 -83
- data/lib/review/configure.rb +87 -97
- data/lib/review/converter.rb +2 -7
- data/lib/review/epubbuilder.rb +1 -3
- data/lib/review/epubmaker.rb +213 -205
- data/lib/review/exception.rb +2 -4
- data/lib/review/extentions.rb +0 -1
- data/lib/review/extentions/hash.rb +2 -2
- data/lib/review/extentions/string.rb +5 -30
- data/lib/review/htmlbuilder.rb +320 -375
- data/lib/review/htmltoc.rb +4 -7
- data/lib/review/htmlutils.rb +29 -32
- data/lib/review/i18n.rb +33 -44
- data/lib/review/i18n.yml +3 -3
- data/lib/review/idgxmlbuilder.rb +309 -345
- data/lib/review/latexbuilder.rb +175 -212
- data/lib/review/latexindex.rb +2 -8
- data/lib/review/latexutils.rb +33 -43
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +21 -0
- data/lib/review/makerhelper.rb +1 -4
- data/lib/review/markdownbuilder.rb +44 -53
- data/lib/review/md2inaobuilder.rb +6 -12
- data/lib/review/pdfmaker.rb +143 -173
- data/lib/review/preprocessor.rb +64 -101
- data/lib/review/rstbuilder.rb +126 -158
- data/lib/review/sec_counter.rb +18 -34
- data/lib/review/template.rb +4 -5
- data/lib/review/textbuilder.rb +2 -3
- data/lib/review/textutils.rb +7 -13
- data/lib/review/tocparser.rb +31 -56
- data/lib/review/tocprinter.rb +26 -52
- data/lib/review/topbuilder.rb +219 -247
- data/lib/review/unfold.rb +15 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +75 -99
- data/lib/review/webtocprinter.rb +15 -20
- data/lib/review/yamlloader.rb +13 -15
- data/review.gemspec +20 -22
- data/templates/latex/layout.tex.erb +2 -2
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/black.eps +280 -0
- data/test/assets/fit.png +0 -0
- data/test/assets/large.gif +0 -0
- data/test/assets/large.jpg +0 -0
- data/test/assets/large.png +0 -0
- data/test/assets/large.svg +65 -0
- data/test/assets/test_template.tex +1 -1
- data/test/book_test_helper.rb +2 -2
- data/test/run_test.rb +4 -4
- data/test/sample-book/src/Rakefile +21 -22
- data/test/syntax-book/Gemfile +4 -0
- data/test/syntax-book/Rakefile +72 -0
- data/test/syntax-book/appA.re +22 -0
- data/test/syntax-book/bib.re +6 -0
- data/test/syntax-book/catalog.yml +15 -0
- data/test/syntax-book/ch01.re +136 -0
- data/test/syntax-book/ch02.re +351 -0
- data/test/syntax-book/ch03.re +82 -0
- data/test/syntax-book/config.yml +35 -0
- data/test/syntax-book/images/ball.png +0 -0
- data/test/syntax-book/images/cover.jpg +0 -0
- data/test/syntax-book/images/fractal.png +0 -0
- data/test/syntax-book/images/img3-1.png +0 -0
- data/test/syntax-book/images/inlineicon.jpg +0 -0
- data/test/syntax-book/images/logic.png +0 -0
- data/test/syntax-book/images/logic2.png +0 -0
- data/test/syntax-book/images/puzzle.jpg +0 -0
- data/test/syntax-book/images/table.jpg +0 -0
- data/test/syntax-book/part2.re +6 -0
- data/test/syntax-book/pre01.re +26 -0
- data/test/syntax-book/review-ext.rb +14 -0
- data/test/syntax-book/sty/jumoline.sty +310 -0
- data/test/syntax-book/sty/reviewmacro.sty +39 -0
- data/test/syntax-book/style.css +494 -0
- data/test/syntax-book/syntax.dic +2 -0
- data/test/test_book.rb +106 -111
- data/test/test_book_chapter.rb +21 -22
- data/test/test_book_part.rb +3 -5
- data/test/test_builder.rb +11 -22
- data/test/test_catalog.rb +17 -18
- data/test/test_catalog_converter_cmd.rb +5 -5
- data/test/test_compiler.rb +18 -16
- data/test/test_configure.rb +35 -38
- data/test/test_converter.rb +3 -4
- data/test/test_epub3maker.rb +136 -117
- data/test/test_epubmaker.rb +107 -114
- data/test/test_epubmaker_cmd.rb +2 -4
- data/test/test_extentions_hash.rb +32 -33
- data/test/test_helper.rb +9 -11
- data/test/test_htmlbuilder.rb +454 -420
- data/test/test_htmltoc.rb +8 -12
- data/test/test_htmlutils.rb +0 -2
- data/test/test_i18n.rb +159 -150
- data/test/test_idgxmlbuilder.rb +190 -197
- data/test/test_image_finder.rb +21 -22
- data/test/test_index.rb +24 -29
- data/test/test_latexbuilder.rb +274 -264
- data/test/test_lineinput.rb +7 -10
- data/test/test_location.rb +7 -7
- data/test/test_makerhelper.rb +13 -25
- data/test/test_markdownbuilder.rb +23 -26
- data/test/test_md2inaobuilder.rb +8 -11
- data/test/test_pdfmaker.rb +114 -123
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +3 -5
- data/test/test_rstbuilder.rb +92 -97
- data/test/test_template.rb +3 -7
- data/test/test_textutils.rb +27 -27
- data/test/test_tocparser.rb +2 -2
- data/test/test_topbuilder.rb +98 -103
- data/test/test_webtocprinter.rb +5 -6
- data/test/test_yamlloader.rb +42 -42
- data/test/test_zip_exporter.rb +12 -18
- metadata +86 -9
- data/lib/review/ewbbuilder.rb +0 -382
data/lib/review/topbuilder.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Copyright (c) 2002-2006 Minero Aoki
|
4
|
-
# 2008-2017 Minero Aoki, Kenshi Muto
|
1
|
+
# Copyright (c) 2008-2017 Minero Aoki, Kenshi Muto
|
2
|
+
# 2002-2006 Minero Aoki
|
5
3
|
#
|
6
4
|
# This program is free software.
|
7
5
|
# You can distribute or modify this program under the terms of
|
@@ -12,14 +10,10 @@ require 'review/builder'
|
|
12
10
|
require 'review/textutils'
|
13
11
|
|
14
12
|
module ReVIEW
|
15
|
-
|
16
13
|
class TOPBuilder < Builder
|
17
|
-
|
18
14
|
include TextUtils
|
19
15
|
|
20
|
-
[
|
21
|
-
Compiler.definline(e)
|
22
|
-
}
|
16
|
+
%i[ttbold hint maru keytop labelref ref balloon strong].each { |e| Compiler.definline(e) }
|
23
17
|
Compiler.defsingle(:dtp, 1)
|
24
18
|
|
25
19
|
Compiler.defblock(:insn, 1)
|
@@ -55,47 +49,47 @@ module ReVIEW
|
|
55
49
|
@sec_counter = SecCounter.new(5, @chapter)
|
56
50
|
|
57
51
|
@titles = {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
52
|
+
'emlist' => 'インラインリスト',
|
53
|
+
'cmd' => 'コマンド',
|
54
|
+
'quote' => '引用',
|
55
|
+
'centering' => '中央揃え',
|
56
|
+
'flushright' => '右寄せ',
|
57
|
+
'note' => 'ノート',
|
58
|
+
'memo' => 'メモ',
|
59
|
+
'important' => '重要',
|
60
|
+
'info' => '情報',
|
61
|
+
'planning' => 'プランニング',
|
62
|
+
'shoot' => 'トラブルシュート',
|
63
|
+
'term' => '用語解説',
|
64
|
+
'notice' => '注意',
|
65
|
+
'caution' => '警告',
|
66
|
+
'warning' => '危険',
|
67
|
+
'point' => 'ここがポイント',
|
68
|
+
'reference' => '参考',
|
69
|
+
'link' => 'リンク',
|
70
|
+
'best' => 'ベストプラクティス',
|
71
|
+
'practice' => '練習問題',
|
72
|
+
'security' => 'セキュリティ',
|
73
|
+
'expert' => 'エキスパートに訊け',
|
74
|
+
'tip' => 'TIP',
|
75
|
+
'box' => '書式',
|
76
|
+
'insn' => '書式',
|
77
|
+
'column' => 'コラム',
|
78
|
+
'xcolumn' => 'コラムパターン2',
|
79
|
+
'world' => 'Worldコラム',
|
80
|
+
'hood' => 'Under The Hoodコラム',
|
81
|
+
'edition' => 'Editionコラム',
|
82
|
+
'insideout' => 'InSideOutコラム',
|
83
|
+
'ref' => '参照',
|
84
|
+
'sup' => '補足',
|
85
|
+
'read' => 'リード',
|
86
|
+
'lead' => 'リード',
|
87
|
+
'list' => 'リスト',
|
88
|
+
'image' => '図',
|
89
|
+
'texequation' => 'TeX式',
|
90
|
+
'table' => '表',
|
91
|
+
'bpo' => 'bpo',
|
92
|
+
'source' => 'ソースコードリスト'
|
99
93
|
}
|
100
94
|
end
|
101
95
|
private :builder_init_file
|
@@ -122,17 +116,9 @@ module ReVIEW
|
|
122
116
|
@output.string
|
123
117
|
end
|
124
118
|
|
125
|
-
def
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
def error(msg)
|
130
|
-
$stderr.puts "#{@location.filename}:#{@location.lineno}: error: #{msg}"
|
131
|
-
end
|
132
|
-
|
133
|
-
def headline(level, label, caption)
|
134
|
-
prefix, anchor = headline_prefix(level)
|
135
|
-
puts %Q[■H#{level}■#{prefix}#{compile_inline(caption)}]
|
119
|
+
def headline(level, _label, caption)
|
120
|
+
prefix, _anchor = headline_prefix(level)
|
121
|
+
puts %Q(■H#{level}■#{prefix}#{compile_inline(caption)})
|
136
122
|
end
|
137
123
|
|
138
124
|
def ul_begin
|
@@ -170,9 +156,7 @@ module ReVIEW
|
|
170
156
|
end
|
171
157
|
|
172
158
|
def dd(lines)
|
173
|
-
split_paragraph(lines).each
|
174
|
-
puts "\t#{paragraph.gsub(/\n/, '')}"
|
175
|
-
end
|
159
|
+
split_paragraph(lines).each { |paragraph| puts "\t#{paragraph.gsub(/\n/, '')}" }
|
176
160
|
end
|
177
161
|
|
178
162
|
def dl_end
|
@@ -184,9 +168,9 @@ module ReVIEW
|
|
184
168
|
end
|
185
169
|
|
186
170
|
def read(lines)
|
187
|
-
puts "◆→開始:#{@titles[
|
171
|
+
puts "◆→開始:#{@titles['lead']}←◆"
|
188
172
|
puts split_paragraph(lines).join("\n")
|
189
|
-
puts "◆→終了:#{@titles[
|
173
|
+
puts "◆→終了:#{@titles['lead']}←◆"
|
190
174
|
blank
|
191
175
|
end
|
192
176
|
|
@@ -194,36 +178,34 @@ module ReVIEW
|
|
194
178
|
|
195
179
|
def inline_list(id)
|
196
180
|
chapter, id = extract_chapter_id(id)
|
197
|
-
if get_chap(chapter)
|
198
|
-
%Q
|
181
|
+
if get_chap(chapter)
|
182
|
+
%Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap(chapter), chapter.list(id).number])})
|
199
183
|
else
|
200
|
-
%Q
|
184
|
+
%Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [chapter.list(id).number])})
|
201
185
|
end
|
202
186
|
end
|
203
187
|
|
204
|
-
def list_header(id, caption,
|
188
|
+
def list_header(id, caption, _lang)
|
205
189
|
blank
|
206
|
-
puts "◆→開始:#{@titles[
|
207
|
-
if get_chap
|
208
|
-
puts %Q
|
190
|
+
puts "◆→開始:#{@titles['list']}←◆"
|
191
|
+
if get_chap
|
192
|
+
puts %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
209
193
|
else
|
210
|
-
puts %Q
|
194
|
+
puts %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
|
211
195
|
end
|
212
196
|
blank
|
213
197
|
end
|
214
198
|
|
215
|
-
def list_body(
|
216
|
-
lines.each
|
217
|
-
|
218
|
-
end
|
219
|
-
puts "◆→終了:#{@titles["list"]}←◆"
|
199
|
+
def list_body(_id, lines, _lang)
|
200
|
+
lines.each { |line| puts detab(line) }
|
201
|
+
puts "◆→終了:#{@titles['list']}←◆"
|
220
202
|
blank
|
221
203
|
end
|
222
204
|
|
223
205
|
def base_block(type, lines, caption = nil)
|
224
206
|
blank
|
225
207
|
puts "◆→開始:#{@titles[type]}←◆"
|
226
|
-
puts "■#{compile_inline(caption)}"
|
208
|
+
puts "■#{compile_inline(caption)}" if caption.present?
|
227
209
|
puts lines.join("\n")
|
228
210
|
puts "◆→終了:#{@titles[type]}←◆"
|
229
211
|
blank
|
@@ -232,124 +214,124 @@ module ReVIEW
|
|
232
214
|
def base_parablock(type, lines, caption = nil)
|
233
215
|
blank
|
234
216
|
puts "◆→開始:#{@titles[type]}←◆"
|
235
|
-
puts "■#{compile_inline(caption)}"
|
217
|
+
puts "■#{compile_inline(caption)}" if caption.present?
|
236
218
|
puts split_paragraph(lines).join("\n")
|
237
219
|
puts "◆→終了:#{@titles[type]}←◆"
|
238
220
|
blank
|
239
221
|
end
|
240
222
|
|
241
|
-
def emlist(lines, caption = nil,
|
242
|
-
base_block
|
223
|
+
def emlist(lines, caption = nil, _lang = nil)
|
224
|
+
base_block 'emlist', lines, caption
|
243
225
|
end
|
244
226
|
|
245
|
-
def emlistnum(lines, caption = nil,
|
227
|
+
def emlistnum(lines, caption = nil, _lang = nil)
|
246
228
|
blank
|
247
|
-
puts "◆→開始:#{@titles[
|
248
|
-
puts "■#{compile_inline(caption)}"
|
249
|
-
|
250
|
-
|
251
|
-
puts (i + 1).to_s.rjust(2) + ": #{line}"
|
252
|
-
end
|
253
|
-
puts "◆→終了:#{@titles["emlist"]}←◆"
|
229
|
+
puts "◆→開始:#{@titles['emlist']}←◆"
|
230
|
+
puts "■#{compile_inline(caption)}" if caption.present?
|
231
|
+
lines.each_with_index { |line, i| puts((i + 1).to_s.rjust(2) + ": #{line}") }
|
232
|
+
puts "◆→終了:#{@titles['emlist']}←◆"
|
254
233
|
blank
|
255
234
|
end
|
256
235
|
|
257
|
-
def listnum_body(lines,
|
258
|
-
lines.each_with_index
|
259
|
-
|
260
|
-
end
|
261
|
-
puts "◆→終了:#{@titles["list"]}←◆"
|
236
|
+
def listnum_body(lines, _lang)
|
237
|
+
lines.each_with_index { |line, i| puts((i + 1).to_s.rjust(2) + ": #{line}") }
|
238
|
+
puts "◆→終了:#{@titles['list']}←◆"
|
262
239
|
blank
|
263
240
|
end
|
264
241
|
|
265
242
|
def cmd(lines, caption = nil)
|
266
|
-
base_block
|
243
|
+
base_block 'cmd', lines, caption
|
267
244
|
end
|
268
245
|
|
269
246
|
def quote(lines)
|
270
|
-
base_parablock
|
247
|
+
base_parablock 'quote', lines, nil
|
271
248
|
end
|
272
249
|
|
273
250
|
def inline_table(id)
|
274
251
|
chapter, id = extract_chapter_id(id)
|
275
|
-
if get_chap(chapter)
|
276
|
-
"#{I18n.t(
|
252
|
+
if get_chap(chapter)
|
253
|
+
"#{I18n.t('table')}#{I18n.t('format_number', [get_chap(chapter), chapter.table(id).number])}"
|
277
254
|
else
|
278
|
-
"#{I18n.t(
|
255
|
+
"#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [chapter.table(id).number])}"
|
279
256
|
end
|
280
257
|
end
|
281
258
|
|
282
259
|
def inline_img(id)
|
283
260
|
chapter, id = extract_chapter_id(id)
|
284
|
-
if get_chap(chapter)
|
285
|
-
"#{I18n.t(
|
261
|
+
if get_chap(chapter)
|
262
|
+
"#{I18n.t('image')}#{I18n.t('format_number', [get_chap(chapter), chapter.image(id).number])}"
|
286
263
|
else
|
287
|
-
"#{I18n.t(
|
264
|
+
"#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [chapter.image(id).number])}"
|
288
265
|
end
|
289
266
|
end
|
290
267
|
|
291
|
-
def
|
268
|
+
def handle_metric(str)
|
269
|
+
str
|
270
|
+
end
|
271
|
+
|
272
|
+
def result_metric(array)
|
273
|
+
array.join(',')
|
274
|
+
end
|
275
|
+
|
276
|
+
def image(lines, id, caption, metric = nil)
|
277
|
+
metrics = parse_metric('top', metric)
|
278
|
+
metrics = " #{metrics}" if metrics.present?
|
292
279
|
blank
|
293
|
-
puts "◆→開始:#{@titles[
|
294
|
-
if get_chap
|
295
|
-
puts "#{I18n.t(
|
280
|
+
puts "◆→開始:#{@titles['image']}←◆"
|
281
|
+
if get_chap
|
282
|
+
puts "#{I18n.t('image')}#{I18n.t('format_number', [get_chap, @chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
296
283
|
else
|
297
|
-
puts "#{I18n.t(
|
284
|
+
puts "#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [@chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
298
285
|
end
|
299
286
|
blank
|
300
287
|
if @chapter.image(id).bound?
|
301
|
-
puts "◆→#{@chapter.image(id).path}←◆"
|
288
|
+
puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
|
302
289
|
else
|
303
|
-
|
304
|
-
|
305
|
-
end
|
290
|
+
warn "image not bound: #{id}"
|
291
|
+
lines.each { |line| puts line }
|
306
292
|
end
|
307
|
-
puts "◆→終了:#{@titles[
|
293
|
+
puts "◆→終了:#{@titles['image']}←◆"
|
308
294
|
blank
|
309
295
|
end
|
310
296
|
|
311
297
|
def texequation(lines)
|
312
|
-
puts "◆→開始:#{@titles[
|
313
|
-
puts
|
314
|
-
puts "◆→終了:#{@titles[
|
298
|
+
puts "◆→開始:#{@titles['texequation']}←◆"
|
299
|
+
puts lines.join("\n")
|
300
|
+
puts "◆→終了:#{@titles['texequation']}←◆"
|
315
301
|
blank
|
316
302
|
end
|
317
303
|
|
318
304
|
def table(lines, id = nil, caption = nil)
|
319
305
|
blank
|
320
|
-
puts "◆→開始:#{@titles[
|
306
|
+
puts "◆→開始:#{@titles['table']}←◆"
|
321
307
|
|
322
308
|
rows = []
|
323
309
|
sepidx = nil
|
324
310
|
lines.each_with_index do |line, idx|
|
325
311
|
if /\A[\=\-]{12}/ =~ line
|
326
312
|
# just ignore
|
327
|
-
#error "too many table separator" if sepidx
|
313
|
+
# error "too many table separator" if sepidx
|
328
314
|
sepidx ||= idx
|
329
315
|
next
|
330
316
|
end
|
331
|
-
rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
|
317
|
+
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
332
318
|
end
|
333
319
|
rows = adjust_n_cols(rows)
|
334
320
|
|
335
321
|
begin
|
336
|
-
table_header id, caption
|
322
|
+
table_header id, caption if caption.present?
|
337
323
|
rescue KeyError
|
338
324
|
error "no such table: #{id}"
|
339
325
|
end
|
340
326
|
return if rows.empty?
|
341
327
|
table_begin rows.first.size
|
342
328
|
if sepidx
|
343
|
-
sepidx.times
|
344
|
-
|
345
|
-
end
|
346
|
-
rows.each do |cols|
|
347
|
-
tr(cols.map {|s| td(s) })
|
348
|
-
end
|
329
|
+
sepidx.times { tr(rows.shift.map { |s| th(s) }) }
|
330
|
+
rows.each { |cols| tr(cols.map { |s| td(s) }) }
|
349
331
|
else
|
350
332
|
rows.each do |cols|
|
351
333
|
h, *cs = *cols
|
352
|
-
tr([th(h)] + cs.map {|s| td(s) })
|
334
|
+
tr([th(h)] + cs.map { |s| td(s) })
|
353
335
|
end
|
354
336
|
end
|
355
337
|
table_end
|
@@ -358,12 +340,10 @@ module ReVIEW
|
|
358
340
|
def table_header(id, caption)
|
359
341
|
if id.nil?
|
360
342
|
puts compile_inline(caption)
|
343
|
+
elsif get_chap
|
344
|
+
puts "#{I18n.t('table')}#{I18n.t('format_number', [get_chap, @chapter.table(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
361
345
|
else
|
362
|
-
|
363
|
-
puts "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
|
364
|
-
else
|
365
|
-
puts "#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
|
366
|
-
end
|
346
|
+
puts "#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [@chapter.table(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
|
367
347
|
end
|
368
348
|
blank
|
369
349
|
end
|
@@ -384,17 +364,16 @@ module ReVIEW
|
|
384
364
|
end
|
385
365
|
|
386
366
|
def table_end
|
387
|
-
puts "◆→終了:#{@titles[
|
367
|
+
puts "◆→終了:#{@titles['table']}←◆"
|
388
368
|
blank
|
389
369
|
end
|
390
370
|
|
391
371
|
def comment(lines, comment = nil)
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
end
|
372
|
+
return unless @book.config['draft']
|
373
|
+
lines ||= []
|
374
|
+
lines.unshift comment unless comment.blank?
|
375
|
+
str = lines.join
|
376
|
+
puts "◆→#{str}←◆"
|
398
377
|
end
|
399
378
|
|
400
379
|
def footnote(id, str)
|
@@ -417,10 +396,10 @@ module ReVIEW
|
|
417
396
|
end
|
418
397
|
|
419
398
|
def compile_href(url, label)
|
420
|
-
if label
|
421
|
-
|
399
|
+
if label
|
400
|
+
"#{label}(△#{url}☆)"
|
422
401
|
else
|
423
|
-
|
402
|
+
"△#{url}☆"
|
424
403
|
end
|
425
404
|
end
|
426
405
|
|
@@ -433,7 +412,7 @@ module ReVIEW
|
|
433
412
|
end
|
434
413
|
|
435
414
|
def inline_raw(str)
|
436
|
-
|
415
|
+
super(str).gsub('\\n', "\n")
|
437
416
|
end
|
438
417
|
|
439
418
|
def inline_hint(str)
|
@@ -486,10 +465,10 @@ module ReVIEW
|
|
486
465
|
|
487
466
|
def inline_icon(id)
|
488
467
|
begin
|
489
|
-
|
468
|
+
"◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
|
490
469
|
rescue
|
491
|
-
warn "
|
492
|
-
|
470
|
+
warn "image not bound: #{id}"
|
471
|
+
"◆→画像 #{id}←◆"
|
493
472
|
end
|
494
473
|
end
|
495
474
|
|
@@ -506,26 +485,24 @@ module ReVIEW
|
|
506
485
|
end
|
507
486
|
|
508
487
|
def inline_uchar(str)
|
509
|
-
[str.to_i(16)].pack(
|
488
|
+
[str.to_i(16)].pack('U')
|
510
489
|
end
|
511
490
|
|
512
491
|
def inline_comment(str)
|
513
|
-
if @book.config[
|
492
|
+
if @book.config['draft']
|
514
493
|
"◆→#{str}←◆"
|
515
494
|
else
|
516
|
-
|
495
|
+
''
|
517
496
|
end
|
518
497
|
end
|
519
498
|
|
520
499
|
def inline_m(str)
|
521
|
-
%Q
|
500
|
+
%Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
|
522
501
|
end
|
523
502
|
|
524
503
|
def bibpaper(lines, id, caption)
|
525
504
|
bibpaper_header id, caption
|
526
|
-
unless lines.empty?
|
527
|
-
bibpaper_bibpaper id, caption, lines
|
528
|
-
end
|
505
|
+
bibpaper_bibpaper id, caption, lines unless lines.empty?
|
529
506
|
end
|
530
507
|
|
531
508
|
def bibpaper_header(id, caption)
|
@@ -533,8 +510,8 @@ module ReVIEW
|
|
533
510
|
puts " #{compile_inline(caption)}"
|
534
511
|
end
|
535
512
|
|
536
|
-
def bibpaper_bibpaper(
|
537
|
-
print split_paragraph(lines).join
|
513
|
+
def bibpaper_bibpaper(_id, _caption, lines)
|
514
|
+
print split_paragraph(lines).join
|
538
515
|
end
|
539
516
|
|
540
517
|
def inline_bib(id)
|
@@ -544,25 +521,23 @@ module ReVIEW
|
|
544
521
|
def inline_hd_chap(chap, id)
|
545
522
|
if chap.number
|
546
523
|
n = chap.headline_index.number(id)
|
547
|
-
if @book.config[
|
548
|
-
return I18n.t("chapter_quote", "#{n} #{compile_inline(chap.headline(id).caption)}")
|
549
|
-
end
|
524
|
+
return I18n.t('chapter_quote', "#{n} #{compile_inline(chap.headline(id).caption)}") if @book.config['secnolevel'] >= n.split('.').size
|
550
525
|
end
|
551
|
-
I18n.t(
|
526
|
+
I18n.t('chapter_quote', compile_inline(chap.headline(id).caption))
|
552
527
|
end
|
553
528
|
|
554
529
|
def noindent
|
555
|
-
puts
|
530
|
+
puts '◆→DTP連絡:次の1行インデントなし←◆'
|
556
531
|
end
|
557
532
|
|
558
|
-
def nonum_begin(level,
|
533
|
+
def nonum_begin(level, _label, caption)
|
559
534
|
puts "■H#{level}■#{compile_inline(caption)}"
|
560
535
|
end
|
561
536
|
|
562
537
|
def nonum_end(level)
|
563
538
|
end
|
564
539
|
|
565
|
-
def notoc_begin(level,
|
540
|
+
def notoc_begin(level, _label, caption)
|
566
541
|
puts "■H#{level}■#{compile_inline(caption)}◆→DTP連絡:目次に掲載しない←◆"
|
567
542
|
end
|
568
543
|
|
@@ -579,170 +554,172 @@ module ReVIEW
|
|
579
554
|
def common_column_begin(type, caption)
|
580
555
|
blank
|
581
556
|
puts "◆→開始:#{@titles[type]}←◆"
|
582
|
-
puts
|
557
|
+
puts "■#{compile_inline(caption)}"
|
583
558
|
end
|
584
559
|
|
585
560
|
def common_column_end(type)
|
586
|
-
puts
|
561
|
+
puts "◆→終了:#{@titles[type]}←◆"
|
587
562
|
blank
|
588
563
|
end
|
589
564
|
|
590
|
-
def column_begin(
|
591
|
-
common_column_begin(
|
565
|
+
def column_begin(_level, _label, caption)
|
566
|
+
common_column_begin('column', caption)
|
592
567
|
end
|
593
568
|
|
594
|
-
def column_end(
|
595
|
-
common_column_end(
|
569
|
+
def column_end(_level)
|
570
|
+
common_column_end('column')
|
596
571
|
end
|
597
572
|
|
598
|
-
def xcolumn_begin(
|
599
|
-
common_column_begin(
|
573
|
+
def xcolumn_begin(_level, _label, caption)
|
574
|
+
common_column_begin('xcolumn', caption)
|
600
575
|
end
|
601
576
|
|
602
|
-
def xcolumn_end(
|
603
|
-
common_column_end(
|
577
|
+
def xcolumn_end(_level)
|
578
|
+
common_column_end('xcolumn')
|
604
579
|
end
|
605
580
|
|
606
|
-
def world_begin(
|
607
|
-
common_column_begin(
|
581
|
+
def world_begin(_level, _label, caption)
|
582
|
+
common_column_begin('world', caption)
|
608
583
|
end
|
609
584
|
|
610
|
-
def world_end(
|
611
|
-
common_column_end(
|
585
|
+
def world_end(_level)
|
586
|
+
common_column_end('world')
|
612
587
|
end
|
613
588
|
|
614
|
-
def hood_begin(
|
615
|
-
common_column_begin(
|
589
|
+
def hood_begin(_level, _label, caption)
|
590
|
+
common_column_begin('hood', caption)
|
616
591
|
end
|
617
592
|
|
618
|
-
def hood_end(
|
619
|
-
common_column_end(
|
593
|
+
def hood_end(_level)
|
594
|
+
common_column_end('hood')
|
620
595
|
end
|
621
596
|
|
622
|
-
def edition_begin(
|
623
|
-
common_column_begin(
|
597
|
+
def edition_begin(_level, _label, caption)
|
598
|
+
common_column_begin('edition', caption)
|
624
599
|
end
|
625
600
|
|
626
|
-
def edition_end(
|
627
|
-
common_column_end(
|
601
|
+
def edition_end(_level)
|
602
|
+
common_column_end('edition')
|
628
603
|
end
|
629
604
|
|
630
|
-
def insideout_begin(
|
631
|
-
common_column_begin(
|
605
|
+
def insideout_begin(_level, _label, caption)
|
606
|
+
common_column_begin('insideout', caption)
|
632
607
|
end
|
633
608
|
|
634
|
-
def insideout_end(
|
635
|
-
common_column_end(
|
609
|
+
def insideout_end(_level)
|
610
|
+
common_column_end('insideout')
|
636
611
|
end
|
637
612
|
|
638
|
-
def ref_begin(
|
639
|
-
common_column_begin(
|
613
|
+
def ref_begin(_level, _label, caption)
|
614
|
+
common_column_begin('ref', caption)
|
640
615
|
end
|
641
616
|
|
642
|
-
def ref_end(
|
643
|
-
common_column_end(
|
617
|
+
def ref_end(_level)
|
618
|
+
common_column_end('ref')
|
644
619
|
end
|
645
620
|
|
646
|
-
def sup_begin(
|
647
|
-
common_column_begin(
|
621
|
+
def sup_begin(_level, _label, caption)
|
622
|
+
common_column_begin('sup', caption)
|
648
623
|
end
|
649
624
|
|
650
|
-
def sup_end(
|
651
|
-
common_column_end(
|
625
|
+
def sup_end(_level)
|
626
|
+
common_column_end('sup')
|
652
627
|
end
|
653
628
|
|
654
629
|
def flushright(lines)
|
655
|
-
base_parablock
|
630
|
+
base_parablock 'flushright', lines, nil
|
656
631
|
end
|
657
632
|
|
658
633
|
def centering(lines)
|
659
|
-
base_parablock
|
634
|
+
base_parablock 'centering', lines, nil
|
660
635
|
end
|
661
636
|
|
662
637
|
def note(lines, caption = nil)
|
663
|
-
base_parablock
|
638
|
+
base_parablock 'note', lines, caption
|
664
639
|
end
|
665
640
|
|
666
641
|
def memo(lines, caption = nil)
|
667
|
-
base_parablock
|
642
|
+
base_parablock 'memo', lines, caption
|
668
643
|
end
|
669
644
|
|
670
645
|
def tip(lines, caption = nil)
|
671
|
-
base_parablock
|
646
|
+
base_parablock 'tip', lines, caption
|
672
647
|
end
|
673
648
|
|
674
649
|
def info(lines, caption = nil)
|
675
|
-
base_parablock
|
650
|
+
base_parablock 'info', lines, caption
|
676
651
|
end
|
677
652
|
|
678
653
|
def planning(lines, caption = nil)
|
679
|
-
base_parablock
|
654
|
+
base_parablock 'planning', lines, caption
|
680
655
|
end
|
681
656
|
|
682
657
|
def best(lines, caption = nil)
|
683
|
-
base_parablock
|
658
|
+
base_parablock 'best', lines, caption
|
684
659
|
end
|
685
660
|
|
686
661
|
def important(lines, caption = nil)
|
687
|
-
base_parablock
|
662
|
+
base_parablock 'important', lines, caption
|
688
663
|
end
|
689
664
|
|
690
665
|
def security(lines, caption = nil)
|
691
|
-
base_parablock
|
666
|
+
base_parablock 'security', lines, caption
|
692
667
|
end
|
693
668
|
|
694
669
|
def caution(lines, caption = nil)
|
695
|
-
base_parablock
|
670
|
+
base_parablock 'caution', lines, caption
|
696
671
|
end
|
697
672
|
|
698
673
|
def term(lines)
|
699
|
-
base_parablock
|
674
|
+
base_parablock 'term', lines, nil
|
700
675
|
end
|
701
676
|
|
702
677
|
def link(lines, caption = nil)
|
703
|
-
base_parablock
|
678
|
+
base_parablock 'link', lines, caption
|
704
679
|
end
|
705
680
|
|
706
681
|
def notice(lines, caption = nil)
|
707
|
-
base_parablock
|
682
|
+
base_parablock 'notice', lines, caption
|
708
683
|
end
|
709
684
|
|
710
685
|
def point(lines, caption = nil)
|
711
|
-
base_parablock
|
686
|
+
base_parablock 'point', lines, caption
|
712
687
|
end
|
713
688
|
|
714
689
|
def shoot(lines, caption = nil)
|
715
|
-
base_parablock
|
690
|
+
base_parablock 'shoot', lines, caption
|
716
691
|
end
|
717
692
|
|
718
693
|
def reference(lines)
|
719
|
-
base_parablock
|
694
|
+
base_parablock 'reference', lines, nil
|
720
695
|
end
|
721
696
|
|
722
697
|
def practice(lines)
|
723
|
-
base_parablock
|
698
|
+
base_parablock 'practice', lines, nil
|
724
699
|
end
|
725
700
|
|
726
701
|
def expert(lines)
|
727
|
-
base_parablock
|
702
|
+
base_parablock 'expert', lines, nil
|
728
703
|
end
|
729
704
|
|
730
705
|
def insn(lines, caption = nil)
|
731
|
-
base_block
|
706
|
+
base_block 'insn', lines, caption
|
732
707
|
end
|
733
708
|
|
734
709
|
def warning(lines, caption = nil)
|
735
|
-
base_parablock
|
710
|
+
base_parablock 'warning', lines, caption
|
736
711
|
end
|
737
712
|
|
738
713
|
alias_method :box, :insn
|
739
714
|
|
740
|
-
def indepimage(id, caption=nil, metric=nil)
|
715
|
+
def indepimage(_lines, id, caption = nil, metric = nil)
|
716
|
+
metrics = parse_metric('top', metric)
|
717
|
+
metrics = " #{metrics}" if metrics.present?
|
741
718
|
blank
|
742
719
|
begin
|
743
|
-
puts "◆→画像 #{@chapter.image(id).path.sub(
|
720
|
+
puts "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}#{metrics}←◆"
|
744
721
|
rescue
|
745
|
-
warn "
|
722
|
+
warn "image not bound: #{id}"
|
746
723
|
puts "◆→画像 #{id}←◆"
|
747
724
|
end
|
748
725
|
puts "図 #{compile_inline(caption)}" if caption.present?
|
@@ -751,9 +728,9 @@ module ReVIEW
|
|
751
728
|
|
752
729
|
alias_method :numberlessimage, :indepimage
|
753
730
|
|
754
|
-
def label(
|
731
|
+
def label(_id)
|
755
732
|
# FIXME
|
756
|
-
|
733
|
+
''
|
757
734
|
end
|
758
735
|
|
759
736
|
def dtp(str)
|
@@ -761,25 +738,25 @@ module ReVIEW
|
|
761
738
|
end
|
762
739
|
|
763
740
|
def bpo(lines)
|
764
|
-
base_block
|
741
|
+
base_block 'bpo', lines, nil
|
765
742
|
end
|
766
743
|
|
767
|
-
def inline_dtp(
|
744
|
+
def inline_dtp(_str)
|
768
745
|
# FIXME
|
769
|
-
|
746
|
+
''
|
770
747
|
end
|
771
748
|
|
772
|
-
def inline_del(
|
749
|
+
def inline_del(_str)
|
773
750
|
# FIXME
|
774
|
-
|
751
|
+
''
|
775
752
|
end
|
776
753
|
|
777
754
|
def inline_code(str)
|
778
|
-
|
755
|
+
"△#{str}☆"
|
779
756
|
end
|
780
757
|
|
781
|
-
def inline_br(
|
782
|
-
|
758
|
+
def inline_br(_str)
|
759
|
+
"\n"
|
783
760
|
end
|
784
761
|
|
785
762
|
def text(str)
|
@@ -787,20 +764,17 @@ module ReVIEW
|
|
787
764
|
end
|
788
765
|
|
789
766
|
def inline_chap(id)
|
790
|
-
#"「第#{super}章 #{inline_title(id)}」"
|
767
|
+
# "「第#{super}章 #{inline_title(id)}」"
|
791
768
|
# "第#{super}章"
|
792
769
|
super
|
793
770
|
end
|
794
771
|
|
795
772
|
def inline_chapref(id)
|
796
|
-
chs = [
|
797
|
-
if @book.config[
|
798
|
-
|
799
|
-
if
|
800
|
-
|
801
|
-
else
|
802
|
-
chs = _chs
|
803
|
-
end
|
773
|
+
chs = ['', '「', '」']
|
774
|
+
if @book.config['chapref']
|
775
|
+
chs2 = @book.config['chapref'].split(',')
|
776
|
+
error '--chapsplitter must have exactly 3 parameters with comma.' if chs2.size != 3
|
777
|
+
chs = chs2
|
804
778
|
end
|
805
779
|
"#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
|
806
780
|
rescue KeyError
|
@@ -808,8 +782,8 @@ module ReVIEW
|
|
808
782
|
nofunc_text("[UnknownChapter:#{id}]")
|
809
783
|
end
|
810
784
|
|
811
|
-
def source(lines, caption = nil,
|
812
|
-
base_block
|
785
|
+
def source(lines, caption = nil, _lang = nil)
|
786
|
+
base_block 'source', lines, caption
|
813
787
|
end
|
814
788
|
|
815
789
|
def inline_ttibold(str)
|
@@ -817,16 +791,16 @@ module ReVIEW
|
|
817
791
|
end
|
818
792
|
|
819
793
|
def inline_labelref(idref)
|
820
|
-
|
794
|
+
"「◆→#{idref}←◆」" # 節、項を参照
|
821
795
|
end
|
822
796
|
|
823
797
|
alias_method :inline_ref, :inline_labelref
|
824
798
|
|
825
799
|
def inline_pageref(idref)
|
826
|
-
|
800
|
+
"●ページ◆→#{idref}←◆" # ページ番号を参照
|
827
801
|
end
|
828
802
|
|
829
|
-
def circle_begin(
|
803
|
+
def circle_begin(_level, _label, caption)
|
830
804
|
puts "・\t#{caption}"
|
831
805
|
end
|
832
806
|
|
@@ -836,7 +810,5 @@ module ReVIEW
|
|
836
810
|
def nofunc_text(str)
|
837
811
|
str
|
838
812
|
end
|
839
|
-
|
840
813
|
end
|
841
|
-
|
842
814
|
end # module ReVIEW
|