tmtms-review 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +9 -0
- data/COPYING +515 -0
- data/ChangeLog +2083 -0
- data/README.rdoc +50 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/bin/review-check +178 -0
- data/bin/review-checkdep +63 -0
- data/bin/review-compile +205 -0
- data/bin/review-epubmaker +661 -0
- data/bin/review-epubmaker-ng +176 -0
- data/bin/review-index +118 -0
- data/bin/review-pdfmaker +208 -0
- data/bin/review-preproc +142 -0
- data/bin/review-validate +51 -0
- data/bin/review-vol +102 -0
- data/debian/README.Debian +12 -0
- data/debian/README.source +5 -0
- data/debian/changelog +5 -0
- data/debian/compat +1 -0
- data/debian/control +22 -0
- data/debian/copyright +62 -0
- data/debian/docs +6 -0
- data/debian/manpage.1.ex +59 -0
- data/debian/patches/path.diff +91 -0
- data/debian/patches/series +1 -0
- data/debian/review.install +13 -0
- data/debian/review.links +4 -0
- data/debian/rules +13 -0
- data/debian/source/format +1 -0
- data/doc/format.rdoc +582 -0
- data/doc/format_idg.rdoc +180 -0
- data/doc/libepubmaker/sample.yaml +90 -0
- data/doc/quickstart.rdoc +188 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +108 -0
- data/doc/sample.yaml +62 -0
- data/lib/epubmaker.rb +28 -0
- data/lib/epubmaker/content.rb +82 -0
- data/lib/epubmaker/epubv2.rb +418 -0
- data/lib/epubmaker/epubv3.rb +249 -0
- data/lib/epubmaker/producer.rb +204 -0
- data/lib/epubmaker/resource.rb +66 -0
- data/lib/lineinput.rb +155 -0
- data/lib/review.rb +3 -0
- data/lib/review/book.rb +46 -0
- data/lib/review/book/base.rb +235 -0
- data/lib/review/book/chapter.rb +81 -0
- data/lib/review/book/compilable.rb +159 -0
- data/lib/review/book/index.rb +339 -0
- data/lib/review/book/page_metric.rb +38 -0
- data/lib/review/book/parameters.rb +97 -0
- data/lib/review/book/part.rb +44 -0
- data/lib/review/book/volume.rb +65 -0
- data/lib/review/builder.rb +444 -0
- data/lib/review/compiler.rb +550 -0
- data/lib/review/configure.rb +38 -0
- data/lib/review/epubbuilder.rb +18 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/extentions.rb +3 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/extentions/string.rb +33 -0
- data/lib/review/htmlbuilder.rb +1097 -0
- data/lib/review/htmllayout.rb +19 -0
- data/lib/review/htmlutils.rb +36 -0
- data/lib/review/i18n.rb +30 -0
- data/lib/review/i18n.yaml +34 -0
- data/lib/review/idgxmlbuilder.rb +1145 -0
- data/lib/review/latexbuilder.rb +815 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +79 -0
- data/lib/review/preprocessor.rb +563 -0
- data/lib/review/review.tex.erb +232 -0
- data/lib/review/textbuilder.rb +17 -0
- data/lib/review/textutils.rb +66 -0
- data/lib/review/tocparser.rb +342 -0
- data/lib/review/tocprinter.rb +221 -0
- data/lib/review/topbuilder.rb +785 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/uuid.rb +312 -0
- data/review.gemspec +141 -0
- data/test/CHAPS +2 -0
- data/test/bib.re +13 -0
- data/test/book_test_helper.rb +35 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +598 -0
- data/test/test_book_chapter.rb +418 -0
- data/test/test_book_parameter.rb +42 -0
- data/test/test_book_part.rb +50 -0
- data/test/test_builder.rb +144 -0
- data/test/test_compiler.rb +44 -0
- data/test/test_epubmaker.rb +507 -0
- data/test/test_helper.rb +27 -0
- data/test/test_htmlbuilder.rb +554 -0
- data/test/test_htmlutils.rb +28 -0
- data/test/test_i18n.rb +64 -0
- data/test/test_idgxmlbuilder.rb +589 -0
- data/test/test_index.rb +31 -0
- data/test/test_latexbuilder.rb +656 -0
- data/test/test_lineinput.rb +198 -0
- data/test/test_preprocessor.rb +23 -0
- data/test/test_textutils.rb +68 -0
- data/test/test_topbuilder.rb +244 -0
- data/test/test_uuid.rb +156 -0
- metadata +161 -0
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2002-2007 Minero Aoki
|
|
4
|
+
# 2008-2009 Minero Aoki, Kenshi Muto
|
|
5
|
+
# 2010 Minero Aoki, Kenshi Muto, TAKAHASHI Masayoshi
|
|
6
|
+
#
|
|
7
|
+
# This program is free software.
|
|
8
|
+
# You can distribute or modify this program under the terms of
|
|
9
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
|
10
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
require 'review/builder'
|
|
14
|
+
require 'review/latexutils'
|
|
15
|
+
require 'review/textutils'
|
|
16
|
+
|
|
17
|
+
module ReVIEW
|
|
18
|
+
|
|
19
|
+
class LATEXBuilder < Builder
|
|
20
|
+
|
|
21
|
+
include LaTeXUtils
|
|
22
|
+
include TextUtils
|
|
23
|
+
|
|
24
|
+
[:dtp, :hd_chap].each {|e|
|
|
25
|
+
Compiler.definline(e)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Compiler.defblock(:memo, 0..1)
|
|
29
|
+
Compiler.defsingle(:latextsize, 1)
|
|
30
|
+
|
|
31
|
+
def extname
|
|
32
|
+
'.tex'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def builder_init_file
|
|
36
|
+
#@index = indexes[:latex_index]
|
|
37
|
+
@blank_needed = false
|
|
38
|
+
@latex_tsize = nil
|
|
39
|
+
@tsize = nil
|
|
40
|
+
@table_caption = nil
|
|
41
|
+
@ol_num = nil
|
|
42
|
+
end
|
|
43
|
+
private :builder_init_file
|
|
44
|
+
|
|
45
|
+
def blank
|
|
46
|
+
@blank_needed = true
|
|
47
|
+
end
|
|
48
|
+
private :blank
|
|
49
|
+
|
|
50
|
+
def print(*s)
|
|
51
|
+
if @blank_needed
|
|
52
|
+
@output.puts
|
|
53
|
+
@blank_needed = false
|
|
54
|
+
end
|
|
55
|
+
super
|
|
56
|
+
end
|
|
57
|
+
private :print
|
|
58
|
+
|
|
59
|
+
def puts(*s)
|
|
60
|
+
if @blank_needed
|
|
61
|
+
@output.puts
|
|
62
|
+
@blank_needed = false
|
|
63
|
+
end
|
|
64
|
+
super
|
|
65
|
+
end
|
|
66
|
+
private :puts
|
|
67
|
+
|
|
68
|
+
HEADLINE = {
|
|
69
|
+
1 => 'chapter',
|
|
70
|
+
2 => 'section',
|
|
71
|
+
3 => 'subsection',
|
|
72
|
+
4 => 'subsubsection',
|
|
73
|
+
5 => 'paragraph',
|
|
74
|
+
6 => 'subparagraph'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
def headline(level, label, caption)
|
|
78
|
+
prefix = ""
|
|
79
|
+
if level > ReVIEW.book.param["secnolevel"] || (@chapter.number.to_s.empty? && level > 1)
|
|
80
|
+
prefix = "*"
|
|
81
|
+
end
|
|
82
|
+
blank unless @output.pos == 0
|
|
83
|
+
puts macro(HEADLINE[level]+prefix, compile_inline(caption))
|
|
84
|
+
if prefix == "*" && level <= ReVIEW.book.param["toclevel"].to_i
|
|
85
|
+
puts "\\addcontentsline{toc}{#{HEADLINE[level]}}{#{compile_inline(caption)}}"
|
|
86
|
+
end
|
|
87
|
+
if level == 1
|
|
88
|
+
puts macro('label', chapter_label)
|
|
89
|
+
end
|
|
90
|
+
rescue
|
|
91
|
+
error "unknown level: #{level}"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def nonum_begin(level, label, caption)
|
|
95
|
+
blank unless @output.pos == 0
|
|
96
|
+
puts macro(HEADLINE[level]+"*", compile_inline(caption))
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def nonum_end(level)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def column_begin(level, label, caption)
|
|
103
|
+
blank
|
|
104
|
+
## puts '\vspace{2zw}'
|
|
105
|
+
## puts '\begin{center}'
|
|
106
|
+
## puts '\begin{minipage}{1.0\linewidth}'
|
|
107
|
+
## puts '\begin{framed}'
|
|
108
|
+
## puts '\setlength{\FrameSep}{1zw}'
|
|
109
|
+
|
|
110
|
+
## nonum_begin(3, label, caption) # FIXME
|
|
111
|
+
|
|
112
|
+
puts "\\begin{reviewcolumn}\n"
|
|
113
|
+
puts macro('reviewcolumnhead', nil, compile_inline(caption))
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def column_end(level)
|
|
118
|
+
## puts '\end{framed}'
|
|
119
|
+
## puts '\end{minipage}'
|
|
120
|
+
## puts '\end{center}'
|
|
121
|
+
## ## puts '\vspace{2zw}'
|
|
122
|
+
puts "\\end{reviewcolumn}\n"
|
|
123
|
+
blank
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def captionblock(type, lines, caption)
|
|
127
|
+
puts "\\begin{reviewminicolumn}\n"
|
|
128
|
+
unless caption.nil?
|
|
129
|
+
puts "\\reviewminicolumntitle{#{compile_inline(caption)}}\n"
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
|
133
|
+
blocked_lines = split_paragraph(lines)
|
|
134
|
+
puts blocked_lines.join("\n\n")
|
|
135
|
+
else
|
|
136
|
+
lines.each do |line|
|
|
137
|
+
puts line
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
puts "\\end{reviewminicolumn}\n"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def ul_begin
|
|
145
|
+
blank
|
|
146
|
+
puts '\begin{itemize}'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def ul_item(lines)
|
|
150
|
+
str = lines.join
|
|
151
|
+
str.sub!(/\A(\[)/){'\lbrack{}'}
|
|
152
|
+
puts '\item ' + str
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def ul_end
|
|
156
|
+
puts '\end{itemize}'
|
|
157
|
+
blank
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def ol_begin
|
|
161
|
+
blank
|
|
162
|
+
puts '\begin{enumerate}'
|
|
163
|
+
if @ol_num
|
|
164
|
+
puts "\\setcounter{enumi}{#{@ol_num - 1}}"
|
|
165
|
+
@ol_num = nil
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def ol_item(lines, num)
|
|
170
|
+
str = lines.join
|
|
171
|
+
str.sub!(/\A(\[)/){'\lbrack{}'}
|
|
172
|
+
puts '\item ' + str
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def ol_end
|
|
176
|
+
puts '\end{enumerate}'
|
|
177
|
+
blank
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def dl_begin
|
|
181
|
+
blank
|
|
182
|
+
puts '\begin{description}'
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def dt(str)
|
|
186
|
+
str.sub!(/\[/){'\lbrack{}'}
|
|
187
|
+
str.sub!(/\]/){'\rbrack{}'}
|
|
188
|
+
puts '\item[' + str + '] \mbox{} \\\\'
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def dd(lines)
|
|
192
|
+
puts lines.join
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def dl_end
|
|
196
|
+
puts '\end{description}'
|
|
197
|
+
blank
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def paragraph(lines)
|
|
201
|
+
blank
|
|
202
|
+
lines.each do |line|
|
|
203
|
+
puts line
|
|
204
|
+
end
|
|
205
|
+
blank
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def parasep()
|
|
209
|
+
puts '\\parasep'
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def read(lines)
|
|
213
|
+
latex_block 'quotation', lines
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
alias lead read
|
|
217
|
+
|
|
218
|
+
def emlist(lines, caption = nil)
|
|
219
|
+
blank
|
|
220
|
+
if caption
|
|
221
|
+
puts macro('reviewemlistcaption', "#{compile_inline(caption)}")
|
|
222
|
+
end
|
|
223
|
+
puts '\begin{reviewemlist}'
|
|
224
|
+
puts '\begin{alltt}'
|
|
225
|
+
lines.each do |line|
|
|
226
|
+
puts detab(line)
|
|
227
|
+
end
|
|
228
|
+
puts '\end{alltt}'
|
|
229
|
+
puts '\end{reviewemlist}'
|
|
230
|
+
blank
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def emlistnum(lines, caption = nil)
|
|
234
|
+
blank
|
|
235
|
+
if caption
|
|
236
|
+
puts macro('reviewemlistcaption', "#{compile_inline(caption)}")
|
|
237
|
+
end
|
|
238
|
+
puts '\begin{reviewemlist}'
|
|
239
|
+
puts '\begin{alltt}'
|
|
240
|
+
lines.each_with_index do |line, i|
|
|
241
|
+
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
|
242
|
+
end
|
|
243
|
+
puts '\end{alltt}'
|
|
244
|
+
puts '\end{reviewemlist}'
|
|
245
|
+
blank
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def listnum_body(lines)
|
|
249
|
+
puts '\begin{reviewlist}'
|
|
250
|
+
puts '\begin{alltt}'
|
|
251
|
+
lines.each_with_index do |line, i|
|
|
252
|
+
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
|
253
|
+
end
|
|
254
|
+
puts '\end{alltt}'
|
|
255
|
+
puts '\end{reviewlist}'
|
|
256
|
+
blank
|
|
257
|
+
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def cmd(lines, caption = nil)
|
|
261
|
+
blank
|
|
262
|
+
if caption
|
|
263
|
+
puts macro('reviewcmdcaption', "#{compile_inline(caption)}")
|
|
264
|
+
end
|
|
265
|
+
puts '\begin{reviewcmd}'
|
|
266
|
+
puts '\begin{alltt}'
|
|
267
|
+
lines.each do |line|
|
|
268
|
+
puts detab(line)
|
|
269
|
+
end
|
|
270
|
+
puts '\end{alltt}'
|
|
271
|
+
puts '\end{reviewcmd}'
|
|
272
|
+
blank
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def list_header(id, caption)
|
|
276
|
+
puts macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}")
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def list_body(lines)
|
|
280
|
+
puts '\begin{reviewlist}'
|
|
281
|
+
puts '\begin{alltt}'
|
|
282
|
+
lines.each do |line|
|
|
283
|
+
puts detab(line)
|
|
284
|
+
end
|
|
285
|
+
puts '\end{alltt}'
|
|
286
|
+
puts '\end{reviewlist}'
|
|
287
|
+
puts ""
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def source(lines, caption)
|
|
291
|
+
puts '\begin{reviewlist}'
|
|
292
|
+
source_header caption
|
|
293
|
+
source_body lines
|
|
294
|
+
puts '\end{reviewlist}'
|
|
295
|
+
puts ""
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def source_header(caption)
|
|
299
|
+
puts macro('reviewlistcaption', compile_inline(caption))
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def source_body(lines)
|
|
303
|
+
puts '\begin{alltt}'
|
|
304
|
+
lines.each do |line|
|
|
305
|
+
puts detab(line)
|
|
306
|
+
end
|
|
307
|
+
puts '\end{alltt}'
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def image_header(id, caption)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def result_metric(array)
|
|
315
|
+
"#{array.join(',')}"
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def image_image(id, caption, metric)
|
|
319
|
+
metrics = parse_metric("latex", metric)
|
|
320
|
+
# image is always bound here
|
|
321
|
+
puts '\begin{reviewimage}'
|
|
322
|
+
if metrics.present?
|
|
323
|
+
puts "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}"
|
|
324
|
+
else
|
|
325
|
+
puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}"
|
|
326
|
+
end
|
|
327
|
+
if caption.present?
|
|
328
|
+
puts macro('caption', compile_inline(caption))
|
|
329
|
+
end
|
|
330
|
+
puts macro('label', image_label(id))
|
|
331
|
+
puts '\end{reviewimage}'
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def image_dummy(id, caption, lines)
|
|
335
|
+
puts '\begin{reviewdummyimage}'
|
|
336
|
+
puts '\begin{alltt}'
|
|
337
|
+
path = @chapter.image(id).path
|
|
338
|
+
puts "--[[path = #{path} (#{existence(id)})]]--"
|
|
339
|
+
lines.each do |line|
|
|
340
|
+
puts detab(line.rstrip)
|
|
341
|
+
end
|
|
342
|
+
puts '\end{alltt}'
|
|
343
|
+
puts macro('label', image_label(id))
|
|
344
|
+
puts compile_inline(caption)
|
|
345
|
+
puts '\end{reviewdummyimage}'
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def existence(id)
|
|
349
|
+
@chapter.image(id).bound? ? 'exist' : 'not exist'
|
|
350
|
+
end
|
|
351
|
+
private :existence
|
|
352
|
+
|
|
353
|
+
def image_label(id)
|
|
354
|
+
"image:#{@chapter.id}:#{id}"
|
|
355
|
+
end
|
|
356
|
+
private :image_label
|
|
357
|
+
|
|
358
|
+
def chapter_label()
|
|
359
|
+
"chap:#{@chapter.id}"
|
|
360
|
+
end
|
|
361
|
+
private :chapter_label
|
|
362
|
+
|
|
363
|
+
def table_label(id)
|
|
364
|
+
"table:#{@chapter.id}:#{id}"
|
|
365
|
+
end
|
|
366
|
+
private :table_label
|
|
367
|
+
|
|
368
|
+
def indepimage(id, caption=nil, metric=nil)
|
|
369
|
+
metrics = parse_metric("latex", metric)
|
|
370
|
+
puts '\begin{reviewimage}'
|
|
371
|
+
if metrics.present?
|
|
372
|
+
puts "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}"
|
|
373
|
+
else
|
|
374
|
+
puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}"
|
|
375
|
+
end
|
|
376
|
+
if caption.present?
|
|
377
|
+
puts macro('reviewindepimagecaption',
|
|
378
|
+
%Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{compile_inline(caption)}])
|
|
379
|
+
end
|
|
380
|
+
puts '\end{reviewimage}'
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
alias :numberlessimage indepimage
|
|
384
|
+
|
|
385
|
+
def table(lines, id = nil, caption = nil)
|
|
386
|
+
rows = []
|
|
387
|
+
sepidx = nil
|
|
388
|
+
lines.each_with_index do |line, idx|
|
|
389
|
+
if /\A[\=\{\-\}]{12}/ =~ line
|
|
390
|
+
# just ignore
|
|
391
|
+
#error "too many table separator" if sepidx
|
|
392
|
+
sepidx ||= idx
|
|
393
|
+
next
|
|
394
|
+
end
|
|
395
|
+
rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
|
|
396
|
+
end
|
|
397
|
+
rows = adjust_n_cols(rows)
|
|
398
|
+
|
|
399
|
+
begin
|
|
400
|
+
table_header id, caption unless caption.nil?
|
|
401
|
+
rescue KeyError => err
|
|
402
|
+
error "no such table: #{id}"
|
|
403
|
+
end
|
|
404
|
+
return if rows.empty?
|
|
405
|
+
table_begin rows.first.size
|
|
406
|
+
if sepidx
|
|
407
|
+
sepidx.times do
|
|
408
|
+
tr rows.shift.map {|s| th(s) }
|
|
409
|
+
end
|
|
410
|
+
rows.each do |cols|
|
|
411
|
+
tr cols.map {|s| td(s) }
|
|
412
|
+
end
|
|
413
|
+
else
|
|
414
|
+
rows.each do |cols|
|
|
415
|
+
h, *cs = *cols
|
|
416
|
+
tr [th(h)] + cs.map {|s| td(s) }
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
table_end
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
def table_header(id, caption)
|
|
423
|
+
if caption.present?
|
|
424
|
+
@table_caption = true
|
|
425
|
+
puts '\begin{table}[h]'
|
|
426
|
+
## puts macro('reviewtablecaption', "表#{@chapter.number}.#{@chapter.table(id).number} #{compile_inline(caption)}")
|
|
427
|
+
puts macro('reviewtablecaption', compile_inline(caption))
|
|
428
|
+
end
|
|
429
|
+
puts macro('label', table_label(id))
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def table_begin(ncols)
|
|
433
|
+
if @latex_tsize
|
|
434
|
+
puts macro('begin', 'reviewtable', @latex_tsize)
|
|
435
|
+
elsif @tsize
|
|
436
|
+
cellwidth = @tsize.split(/\s*,\s*/)
|
|
437
|
+
puts macro('begin', 'reviewtable', '|'+(cellwidth.collect{|i| "p{#{i}mm}"}.join('|'))+'|')
|
|
438
|
+
else
|
|
439
|
+
puts macro('begin', 'reviewtable', (['|'] * (ncols + 1)).join('l'))
|
|
440
|
+
end
|
|
441
|
+
puts '\hline'
|
|
442
|
+
@tsize = nil
|
|
443
|
+
@latex_tsize = nil
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def table_separator
|
|
447
|
+
#puts '\hline'
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def th(s)
|
|
451
|
+
## use shortstack for @<br>
|
|
452
|
+
if /\\\\/i =~ s
|
|
453
|
+
macro('reviewth', macro('shortstack[l]', s))
|
|
454
|
+
else
|
|
455
|
+
macro('reviewth', s)
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
def td(s)
|
|
460
|
+
## use shortstack for @<br>
|
|
461
|
+
if /\\\\/ =~ s
|
|
462
|
+
macro('shortstack[l]', s)
|
|
463
|
+
else
|
|
464
|
+
s
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
def tr(rows)
|
|
469
|
+
print rows.join(' & ')
|
|
470
|
+
puts ' \\\\ \hline'
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
def table_end
|
|
474
|
+
puts macro('end', 'reviewtable')
|
|
475
|
+
if @table_caption
|
|
476
|
+
puts '\end{table}'
|
|
477
|
+
end
|
|
478
|
+
@table_caption = nil
|
|
479
|
+
blank
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
def quote(lines)
|
|
483
|
+
latex_block 'quote', lines
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
def center(lines)
|
|
487
|
+
latex_block 'center', lines
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
alias centering center
|
|
491
|
+
|
|
492
|
+
def flushright(lines)
|
|
493
|
+
latex_block 'flushright', lines
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
def texequation(lines)
|
|
497
|
+
blank
|
|
498
|
+
puts macro('begin','equation*')
|
|
499
|
+
lines.each do |line|
|
|
500
|
+
puts unescape_latex(line)
|
|
501
|
+
end
|
|
502
|
+
puts macro('end', 'equation*')
|
|
503
|
+
blank
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
def latex_block(type, lines)
|
|
507
|
+
blank
|
|
508
|
+
puts macro('begin', type)
|
|
509
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
|
510
|
+
blocked_lines = split_paragraph(lines)
|
|
511
|
+
puts blocked_lines.join("\n\n")
|
|
512
|
+
else
|
|
513
|
+
lines.each do |line|
|
|
514
|
+
puts line
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
puts macro('end', type)
|
|
518
|
+
blank
|
|
519
|
+
end
|
|
520
|
+
private :latex_block
|
|
521
|
+
|
|
522
|
+
def direct(lines, fmt)
|
|
523
|
+
return unless fmt == 'latex'
|
|
524
|
+
lines.each do |line|
|
|
525
|
+
puts line
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
def comment(str)
|
|
530
|
+
if ReVIEW.book.param["draft"]
|
|
531
|
+
puts macro('pdfcomment', escape(str))
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def hr
|
|
536
|
+
puts '\hrule'
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
def label(id)
|
|
540
|
+
puts macro('label', id)
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
def pagebreak
|
|
544
|
+
puts '\pagebreak'
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
def linebreak
|
|
548
|
+
puts '\\\\'
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
def noindent
|
|
552
|
+
print '\noindent'
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
def inline_chapref(id)
|
|
556
|
+
if ReVIEW.book.param["chapterlink"]
|
|
557
|
+
"\\hyperref[chap:#{id}]{#{@chapter.env.chapter_index.display_string(id)}}"
|
|
558
|
+
else
|
|
559
|
+
@chapter.env.chapter_index.display_string(id)
|
|
560
|
+
end
|
|
561
|
+
rescue KeyError
|
|
562
|
+
error "unknown chapter: #{id}"
|
|
563
|
+
nofunc_text("[UnknownChapter:#{id}]")
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
def inline_chap(id)
|
|
567
|
+
if ReVIEW.book.param["chapterlink"]
|
|
568
|
+
"\\hyperref[chap:#{id}]{#{@chapter.env.chapter_index.number(id)}}"
|
|
569
|
+
else
|
|
570
|
+
@chapter.env.chapter_index.number(id)
|
|
571
|
+
end
|
|
572
|
+
rescue KeyError
|
|
573
|
+
error "unknown chapter: #{id}"
|
|
574
|
+
nofunc_text("[UnknownChapter:#{id}]")
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
def inline_title(id)
|
|
578
|
+
if ReVIEW.book.param["chapterlink"]
|
|
579
|
+
"\\hyperref[chap:#{id}]{#{@chapter.env.chapter_index.title(id)}}"
|
|
580
|
+
else
|
|
581
|
+
@chapter.env.chapter_index.title(id)
|
|
582
|
+
end
|
|
583
|
+
rescue KeyError
|
|
584
|
+
error "unknown chapter: #{id}"
|
|
585
|
+
nofunc_text("[UnknownChapter:#{id}]")
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
# FIXME: use TeX native label/ref.
|
|
590
|
+
def inline_list(id)
|
|
591
|
+
chapter, id = extract_chapter_id(id)
|
|
592
|
+
macro('reviewlistref', "#{chapter.number}.#{chapter.list(id).number}")
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
def inline_table(id)
|
|
596
|
+
chapter, id = extract_chapter_id(id)
|
|
597
|
+
macro('reviewtableref', "#{chapter.number}.#{chapter.table(id).number}", table_label(id))
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
def inline_img(id)
|
|
601
|
+
chapter, id = extract_chapter_id(id)
|
|
602
|
+
macro('reviewimageref', "#{chapter.number}.#{chapter.image(id).number}", image_label(id))
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
def footnote(id, content)
|
|
606
|
+
if ReVIEW.book.param["footnotetext"]
|
|
607
|
+
puts macro("footnotetext[#{@chapter.footnote(id).number}]",
|
|
608
|
+
compile_inline(content.strip))
|
|
609
|
+
end
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
def inline_fn(id)
|
|
613
|
+
if ReVIEW.book.param["footnotetext"]
|
|
614
|
+
macro("footnotemark[#{@chapter.footnote(id).number}]", "")
|
|
615
|
+
else
|
|
616
|
+
macro('footnote', compile_inline(@chapter.footnote(id).content.strip))
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
BOUTEN = "・"
|
|
621
|
+
|
|
622
|
+
def inline_bou(str)
|
|
623
|
+
str.split(//).map {|c| macro('ruby', escape(c), macro('textgt', BOUTEN)) }.join('\allowbreak')
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
def inline_ruby(str)
|
|
627
|
+
base, ruby = *str.split(/,/)
|
|
628
|
+
macro('ruby', base, ruby)
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
# math
|
|
632
|
+
def inline_m(str)
|
|
633
|
+
" $#{str}$ "
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
# hidden index
|
|
637
|
+
def inline_hi(str)
|
|
638
|
+
index(str)
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
# index -> italic
|
|
642
|
+
def inline_i(str)
|
|
643
|
+
macro('textit', escape(str))
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
# index
|
|
647
|
+
def inline_idx(str)
|
|
648
|
+
text(str) + index(str)
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
# hidden index??
|
|
652
|
+
def inline_hidx(str)
|
|
653
|
+
index(str)
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
# bold
|
|
657
|
+
def inline_b(str)
|
|
658
|
+
macro('textbf', escape(str))
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
# line break
|
|
662
|
+
def inline_br(str)
|
|
663
|
+
"\\\\\n"
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
def inline_dtp(str)
|
|
667
|
+
# ignore
|
|
668
|
+
""
|
|
669
|
+
end
|
|
670
|
+
|
|
671
|
+
## @<code> is same as @<tt>
|
|
672
|
+
def inline_code(str)
|
|
673
|
+
macro('texttt', escape(str))
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
def nofunc_text(str)
|
|
677
|
+
escape(str)
|
|
678
|
+
end
|
|
679
|
+
|
|
680
|
+
def inline_tt(str)
|
|
681
|
+
macro('texttt', escape(str))
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
def inline_del(str)
|
|
685
|
+
escape(str) # TODO: use strike ?
|
|
686
|
+
end
|
|
687
|
+
|
|
688
|
+
def inline_tti(str)
|
|
689
|
+
macro('texttt', macro('textit', escape(str)))
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
def inline_ttb(str)
|
|
693
|
+
macro('texttt', macro('textbf', escape(str)))
|
|
694
|
+
end
|
|
695
|
+
|
|
696
|
+
def inline_bib(id)
|
|
697
|
+
"[#{@chapter.bibpaper(id).number}]"
|
|
698
|
+
end
|
|
699
|
+
|
|
700
|
+
def inline_hd_chap(chap, id)
|
|
701
|
+
"「#{chap.headline_index.number(id)} #{compile_inline(chap.headline(id).caption)}」"
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
def inline_raw(str)
|
|
705
|
+
super(str)
|
|
706
|
+
end
|
|
707
|
+
|
|
708
|
+
def inline_sub(str)
|
|
709
|
+
macro('textsubscript', escape(str))
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
def inline_sup(str)
|
|
713
|
+
macro('textsuperscript', escape(str))
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
def inline_em(str)
|
|
717
|
+
macro('reviewem', escape(str))
|
|
718
|
+
end
|
|
719
|
+
|
|
720
|
+
def inline_strong(str)
|
|
721
|
+
macro('reviewstrong', escape(str))
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
def inline_u(str)
|
|
725
|
+
macro('Underline', escape(str))
|
|
726
|
+
end
|
|
727
|
+
|
|
728
|
+
def inline_ami(str)
|
|
729
|
+
macro('reviewami', escape(str))
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
def inline_icon(id)
|
|
733
|
+
macro('includegraphics', @chapter.image(id).path)
|
|
734
|
+
end
|
|
735
|
+
|
|
736
|
+
def inline_uchar(str)
|
|
737
|
+
# with otf package
|
|
738
|
+
macro('UTF', escape(str))
|
|
739
|
+
end
|
|
740
|
+
|
|
741
|
+
def inline_comment(str)
|
|
742
|
+
if ReVIEW.book.param["draft"]
|
|
743
|
+
macro('pdfcomment', escape(str))
|
|
744
|
+
else
|
|
745
|
+
""
|
|
746
|
+
end
|
|
747
|
+
end
|
|
748
|
+
|
|
749
|
+
def bibpaper_header(id, caption)
|
|
750
|
+
puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}"
|
|
751
|
+
end
|
|
752
|
+
|
|
753
|
+
def bibpaper_bibpaper(id, caption, lines)
|
|
754
|
+
lines.each do |line|
|
|
755
|
+
puts detab(line)
|
|
756
|
+
end
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
def index(str)
|
|
760
|
+
str.sub!(/\(\)/, '')
|
|
761
|
+
decl = ''
|
|
762
|
+
if /@\z/ =~ str
|
|
763
|
+
str.chop!
|
|
764
|
+
decl = '|IndexDecl'
|
|
765
|
+
end
|
|
766
|
+
unless /[^ -~]/ =~ str
|
|
767
|
+
if /\^/ =~ str
|
|
768
|
+
macro('index', escape_index(str.gsub(/\^/, '')) + '@' + escape_index(text(str)) + decl)
|
|
769
|
+
else
|
|
770
|
+
'\index{' + escape_index(text(str)) + decl + '}'
|
|
771
|
+
end
|
|
772
|
+
else
|
|
773
|
+
'\index{' + escape_index(@index_db[str]) + '@' + escape_index(text(str)) + '}'
|
|
774
|
+
end
|
|
775
|
+
end
|
|
776
|
+
|
|
777
|
+
def compile_kw(word, alt)
|
|
778
|
+
if alt
|
|
779
|
+
macro('reviewkw', escape(word)) + "(#{escape(alt.strip)})"
|
|
780
|
+
else
|
|
781
|
+
macro('reviewkw', escape(word))
|
|
782
|
+
end
|
|
783
|
+
end
|
|
784
|
+
|
|
785
|
+
def compile_href(url, label)
|
|
786
|
+
if /\A[a-z]+:/ =~ url
|
|
787
|
+
if label
|
|
788
|
+
macro("href", escape_url(url), escape(label))
|
|
789
|
+
else
|
|
790
|
+
macro("url", escape_url(url))
|
|
791
|
+
end
|
|
792
|
+
else
|
|
793
|
+
macro("ref", url)
|
|
794
|
+
end
|
|
795
|
+
end
|
|
796
|
+
|
|
797
|
+
def tsize(str)
|
|
798
|
+
@tsize = str
|
|
799
|
+
end
|
|
800
|
+
|
|
801
|
+
def latextsize(str)
|
|
802
|
+
@latex_tsize = str
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
def image_ext
|
|
806
|
+
"svg"
|
|
807
|
+
end
|
|
808
|
+
|
|
809
|
+
def olnum(num)
|
|
810
|
+
@ol_num = num.to_i
|
|
811
|
+
end
|
|
812
|
+
|
|
813
|
+
end
|
|
814
|
+
|
|
815
|
+
end
|