review 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +515 -0
- data/ChangeLog +1278 -0
- data/README.rdoc +21 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/bin/review-check +190 -0
- data/bin/review-checkdep +63 -0
- data/bin/review-compile +165 -0
- data/bin/review-epubmaker +525 -0
- data/bin/review-index +108 -0
- data/bin/review-preproc +140 -0
- data/bin/review-validate +51 -0
- data/bin/review-vol +106 -0
- data/doc/format.re +486 -0
- data/doc/format.txt +434 -0
- data/doc/format_idg.txt +194 -0
- data/doc/format_sjis.txt +313 -0
- data/doc/sample.css +91 -0
- data/doc/sample.yaml +46 -0
- data/lib/lineinput.rb +155 -0
- data/lib/review/book.rb +580 -0
- data/lib/review/builder.rb +274 -0
- data/lib/review/compat.rb +22 -0
- data/lib/review/compiler.rb +483 -0
- data/lib/review/epubbuilder.rb +692 -0
- data/lib/review/ewbbuilder.rb +382 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/htmlbuilder.rb +370 -0
- data/lib/review/htmllayout.rb +19 -0
- data/lib/review/htmlutils.rb +27 -0
- data/lib/review/idgxmlbuilder.rb +1078 -0
- data/lib/review/index.rb +224 -0
- data/lib/review/latexbuilder.rb +420 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +52 -0
- data/lib/review/preprocessor.rb +520 -0
- data/lib/review/textutils.rb +19 -0
- data/lib/review/tocparser.rb +333 -0
- data/lib/review/tocprinter.rb +220 -0
- data/lib/review/topbuilder.rb +572 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/review/volume.rb +66 -0
- data/lib/review.rb +4 -0
- data/review.gemspec +93 -0
- data/setup.rb +1587 -0
- data/test/test_epubbuilder.rb +73 -0
- data/test/test_helper.rb +2 -0
- data/test/test_htmlbuilder.rb +42 -0
- data/test/test_latexbuilder.rb +74 -0
- metadata +122 -0
@@ -0,0 +1,692 @@
|
|
1
|
+
# epubbuilder.rb
|
2
|
+
# derived from htmlbuider.rb
|
3
|
+
#
|
4
|
+
# Copyright (c) 2010 Kenshi Muto
|
5
|
+
#
|
6
|
+
# This program is free software.
|
7
|
+
# You can distribute or modify this program under the terms of
|
8
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'review/builder'
|
12
|
+
require 'review/htmlutils'
|
13
|
+
require 'review/htmllayout'
|
14
|
+
require 'review/textutils'
|
15
|
+
require 'review/htmlbuilder'
|
16
|
+
|
17
|
+
module ReVIEW
|
18
|
+
|
19
|
+
class EPUBBuilder < HTMLBuilder
|
20
|
+
|
21
|
+
[:u, :tti, :idx, :hidx].each {|e|
|
22
|
+
Compiler.definline(e)
|
23
|
+
}
|
24
|
+
|
25
|
+
Compiler.defsingle(:indepimage, 1)
|
26
|
+
Compiler.defblock(:memo, 0..1)
|
27
|
+
Compiler.defblock(:tip, 0..1)
|
28
|
+
Compiler.defblock(:info, 0..1)
|
29
|
+
Compiler.defblock(:planning, 0..1)
|
30
|
+
Compiler.defblock(:best, 0..1)
|
31
|
+
Compiler.defblock(:important, 0..1)
|
32
|
+
Compiler.defblock(:security, 0..1)
|
33
|
+
Compiler.defblock(:caution, 0..1)
|
34
|
+
Compiler.defblock(:notice, 0..1)
|
35
|
+
Compiler.defblock(:point, 0..1)
|
36
|
+
Compiler.defblock(:shoot, 0..1)
|
37
|
+
|
38
|
+
def builder_init(no_error = false)
|
39
|
+
@no_error = no_error
|
40
|
+
@section = 0
|
41
|
+
@subsection = 0
|
42
|
+
@subsubsection = 0
|
43
|
+
@subsubsubsection = 0
|
44
|
+
end
|
45
|
+
private :builder_init
|
46
|
+
|
47
|
+
def extname
|
48
|
+
'.html'
|
49
|
+
end
|
50
|
+
|
51
|
+
def raw_result
|
52
|
+
@output.string
|
53
|
+
end
|
54
|
+
|
55
|
+
def result
|
56
|
+
layout_file = File.join(@book.basedir, "layouts", "layout.erb")
|
57
|
+
if File.exists?(layout_file)
|
58
|
+
messages() +
|
59
|
+
HTMLLayout.new(@output.string, @chapter.title, layout_file).result
|
60
|
+
else
|
61
|
+
# FIXME
|
62
|
+
header = <<EOT
|
63
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
64
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
65
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="ja">
|
66
|
+
<head>
|
67
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
68
|
+
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
69
|
+
EOT
|
70
|
+
unless @param["stylesheet"].nil?
|
71
|
+
header += <<EOT
|
72
|
+
<link rel="stylesheet" type="text/css" href="#{@param["stylesheet"]}"/>
|
73
|
+
EOT
|
74
|
+
end
|
75
|
+
header += <<EOT
|
76
|
+
<meta name="generator" content="ReVIEW EPUB Maker"/>
|
77
|
+
<title>#{@chapter.title}</title>
|
78
|
+
</head>
|
79
|
+
<body>
|
80
|
+
EOT
|
81
|
+
footer = <<EOT
|
82
|
+
</body>
|
83
|
+
</html>
|
84
|
+
EOT
|
85
|
+
header + messages() + @output.string + footer
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def headline_prefix(level)
|
90
|
+
anchor = ""
|
91
|
+
case level
|
92
|
+
when 1
|
93
|
+
@section = 0
|
94
|
+
@subsection = 0
|
95
|
+
@subsubsection = 0
|
96
|
+
@subsubsubsection = 0
|
97
|
+
anchor = "#{@chapter.number}"
|
98
|
+
if @param["secnolevel"] >= 1
|
99
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
100
|
+
prefix = "第#{@chapter.number}章 "
|
101
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
102
|
+
prefix = "#{@chapter.number} "
|
103
|
+
end
|
104
|
+
end
|
105
|
+
when 2
|
106
|
+
@section += 1
|
107
|
+
@subsection = 0
|
108
|
+
@subsubsection = 0
|
109
|
+
@subsubsubsection = 0
|
110
|
+
anchor = "#{@chapter.number}-#{@section}"
|
111
|
+
if @param["secnolevel"] >= 2
|
112
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
113
|
+
prefix = "#{@chapter.number}.#{@section} "
|
114
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
115
|
+
prefix = "#{@chapter.number}.#{@section} "
|
116
|
+
end
|
117
|
+
end
|
118
|
+
when 3
|
119
|
+
@subsection += 1
|
120
|
+
@subsubsection = 0
|
121
|
+
@subsubsubsection = 0
|
122
|
+
anchor = "#{@chapter.number}-#{@section}-#{@subsection}"
|
123
|
+
if @param["secnolevel"] >= 3
|
124
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
125
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection} "
|
126
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
127
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection} "
|
128
|
+
end
|
129
|
+
end
|
130
|
+
when 4
|
131
|
+
@subsubsection += 1
|
132
|
+
@subsubsubsection = 0
|
133
|
+
anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}"
|
134
|
+
if @param["secnolevel"] >= 4
|
135
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
136
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection} "
|
137
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
138
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection} "
|
139
|
+
end
|
140
|
+
end
|
141
|
+
when 5
|
142
|
+
@subsubsubsection += 1
|
143
|
+
anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}-#{@subsubsubsection}"
|
144
|
+
if @param["secnolevel"] >= 5
|
145
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
146
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection} "
|
147
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
148
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection} "
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
[prefix, anchor]
|
153
|
+
end
|
154
|
+
private :headline_prefix
|
155
|
+
|
156
|
+
def headline(level, label, caption)
|
157
|
+
prefix, anchor = headline_prefix(level)
|
158
|
+
puts '' if level > 1
|
159
|
+
a_id = ""
|
160
|
+
unless anchor.empty?
|
161
|
+
a_id = "<a id=\"h#{anchor}\" />"
|
162
|
+
end
|
163
|
+
if caption.empty?
|
164
|
+
puts a_id unless label.nil?
|
165
|
+
else
|
166
|
+
if label.nil?
|
167
|
+
puts "<h#{level}>#{a_id}#{prefix}#{escape_html(caption)}</h#{level}>"
|
168
|
+
else
|
169
|
+
puts "<h#{level} id='#{label}'>#{a_id}#{prefix}#{escape_html(caption)}</h#{level}>"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def column_begin(level, label, caption)
|
175
|
+
puts "<div class='column'>"
|
176
|
+
headline(level, label, caption) # FIXME
|
177
|
+
end
|
178
|
+
|
179
|
+
def column_end(level)
|
180
|
+
puts '</div>'
|
181
|
+
end
|
182
|
+
|
183
|
+
def xcolumn_begin(level, label, caption)
|
184
|
+
puts "<div class='xcolumn'>"
|
185
|
+
headline(level, label, caption) # FIXME
|
186
|
+
end
|
187
|
+
|
188
|
+
def xcolumn_end(level)
|
189
|
+
puts '</div>'
|
190
|
+
end
|
191
|
+
|
192
|
+
def ref_begin(level, label, caption)
|
193
|
+
print "<div class='reference'>"
|
194
|
+
headline(level, label, caption)
|
195
|
+
end
|
196
|
+
|
197
|
+
def ref_end(level)
|
198
|
+
puts '</div>'
|
199
|
+
end
|
200
|
+
|
201
|
+
def sup_begin(level, label, caption)
|
202
|
+
print "<div class='supplement'>"
|
203
|
+
headline(level, label, caption)
|
204
|
+
end
|
205
|
+
|
206
|
+
def sup_end(level)
|
207
|
+
puts '</div>'
|
208
|
+
end
|
209
|
+
|
210
|
+
def tsize(str)
|
211
|
+
# null
|
212
|
+
end
|
213
|
+
|
214
|
+
def captionblock(type, lines, caption)
|
215
|
+
puts "<div class=\"#{type}\">"
|
216
|
+
unless caption.nil?
|
217
|
+
puts "<p class=\"#{type}-title\">#{escape_html(caption)}</p>"
|
218
|
+
end
|
219
|
+
lines.each {|l|
|
220
|
+
puts "<p>#{l}</p>"
|
221
|
+
}
|
222
|
+
puts '</div>'
|
223
|
+
end
|
224
|
+
|
225
|
+
def memo(lines, caption = nil)
|
226
|
+
captionblock("memo", lines, caption)
|
227
|
+
end
|
228
|
+
|
229
|
+
def tip(lines, caption = nil)
|
230
|
+
captionblock("tip", lines, caption)
|
231
|
+
end
|
232
|
+
|
233
|
+
def info(lines, caption = nil)
|
234
|
+
captionblock("info", lines, caption)
|
235
|
+
end
|
236
|
+
|
237
|
+
def planning(lines, caption = nil)
|
238
|
+
captionblock("planning", lines, caption)
|
239
|
+
end
|
240
|
+
|
241
|
+
def best(lines, caption = nil)
|
242
|
+
captionblock("best", lines, caption)
|
243
|
+
end
|
244
|
+
|
245
|
+
def important(lines, caption = nil)
|
246
|
+
captionblock("important", lines, caption)
|
247
|
+
end
|
248
|
+
|
249
|
+
def security(lines, caption = nil)
|
250
|
+
captionblock("security", lines, caption)
|
251
|
+
end
|
252
|
+
|
253
|
+
def caution(lines, caption = nil)
|
254
|
+
captionblock("caution", lines, caption)
|
255
|
+
end
|
256
|
+
|
257
|
+
def notice(lines, caption = nil)
|
258
|
+
captionblock("notice", lines, caption)
|
259
|
+
end
|
260
|
+
|
261
|
+
def point(lines, caption = nil)
|
262
|
+
captionblock("point", lines, caption)
|
263
|
+
end
|
264
|
+
|
265
|
+
def shot(lines, caption = nil)
|
266
|
+
captionblock("shoot", lines, caption)
|
267
|
+
end
|
268
|
+
|
269
|
+
def list(lines, id, caption)
|
270
|
+
puts '<div class="caption-code">'
|
271
|
+
begin
|
272
|
+
list_header id, caption
|
273
|
+
rescue KeyError
|
274
|
+
error "no such list: #{id}"
|
275
|
+
end
|
276
|
+
list_body lines
|
277
|
+
puts '</div>'
|
278
|
+
end
|
279
|
+
|
280
|
+
def list_header(id, caption)
|
281
|
+
puts %Q[<p class="listcaption">リスト#{getChap}#{@chapter.list(id).number}: #{escape_html(caption)}</p>]
|
282
|
+
end
|
283
|
+
|
284
|
+
def list_body(lines)
|
285
|
+
puts '<pre class="list">'
|
286
|
+
lines.each do |line|
|
287
|
+
puts detab(line)
|
288
|
+
end
|
289
|
+
puts '</pre>'
|
290
|
+
end
|
291
|
+
|
292
|
+
def source(lines, caption)
|
293
|
+
puts '<div class="caption-code">'
|
294
|
+
source_header caption
|
295
|
+
source_body lines
|
296
|
+
puts '</div>'
|
297
|
+
end
|
298
|
+
|
299
|
+
def source_header(caption)
|
300
|
+
puts %Q[<p class="sourcecaption">#{escape_html(caption)}</p>]
|
301
|
+
end
|
302
|
+
|
303
|
+
def source_body(lines)
|
304
|
+
puts '<pre class="source">'
|
305
|
+
lines.each do |line|
|
306
|
+
puts detab(line)
|
307
|
+
end
|
308
|
+
puts '</pre>'
|
309
|
+
end
|
310
|
+
|
311
|
+
def listnum(lines, id, caption)
|
312
|
+
puts '<div class="code">'
|
313
|
+
begin
|
314
|
+
list_header id, caption
|
315
|
+
rescue KeyError
|
316
|
+
error "no such list: #{id}"
|
317
|
+
end
|
318
|
+
listnum_body lines
|
319
|
+
puts '</div>'
|
320
|
+
end
|
321
|
+
|
322
|
+
def listnum_body(lines)
|
323
|
+
puts '<pre class="list">'
|
324
|
+
lines.each_with_index do |line, i|
|
325
|
+
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
326
|
+
end
|
327
|
+
puts '</pre>'
|
328
|
+
end
|
329
|
+
|
330
|
+
def emlist(lines, caption = nil)
|
331
|
+
puts '<div class="code">'
|
332
|
+
puts %Q(<p class="emlistcaption">#{caption}</p>) unless caption.nil?
|
333
|
+
puts '<pre class="emlist">'
|
334
|
+
lines.each do |line|
|
335
|
+
puts detab(line)
|
336
|
+
end
|
337
|
+
puts '</pre>'
|
338
|
+
puts '</div>'
|
339
|
+
end
|
340
|
+
|
341
|
+
def emlistnum(lines)
|
342
|
+
puts '<div class="code">'
|
343
|
+
puts '<pre class="emlist">'
|
344
|
+
lines.each_with_index do |line, i|
|
345
|
+
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
346
|
+
end
|
347
|
+
puts '</pre>'
|
348
|
+
puts '</div>'
|
349
|
+
end
|
350
|
+
|
351
|
+
def cmd(lines)
|
352
|
+
puts '<div class="code">'
|
353
|
+
puts '<pre class="cmd">'
|
354
|
+
lines.each do |line|
|
355
|
+
puts detab(line)
|
356
|
+
end
|
357
|
+
puts '</pre>'
|
358
|
+
puts '</div>'
|
359
|
+
end
|
360
|
+
|
361
|
+
def quotedlist(lines, css_class)
|
362
|
+
puts %Q[<blockquote><pre class="#{css_class}">]
|
363
|
+
lines.each do |line|
|
364
|
+
puts detab(line)
|
365
|
+
end
|
366
|
+
puts '</pre></blockquote>'
|
367
|
+
end
|
368
|
+
private :quotedlist
|
369
|
+
|
370
|
+
def quote(lines)
|
371
|
+
puts "<blockquote>#{lines.join("\n")}</blockquote>"
|
372
|
+
end
|
373
|
+
|
374
|
+
def image_image(id, metric, caption)
|
375
|
+
puts %Q[<div class="image">]
|
376
|
+
puts %Q[<img src="#{@chapter.image(id).path.sub(/^\.\//, "")}" alt="(#{escape_html(caption)})" />]
|
377
|
+
image_header id, caption
|
378
|
+
puts %Q[</div>]
|
379
|
+
end
|
380
|
+
|
381
|
+
def image_dummy(id, caption, lines)
|
382
|
+
puts %Q[<div class="image">]
|
383
|
+
puts %Q[<pre class="dummyimage">]
|
384
|
+
lines.each do |line|
|
385
|
+
puts detab(line)
|
386
|
+
end
|
387
|
+
puts %Q[</pre>]
|
388
|
+
image_header id, caption
|
389
|
+
puts %Q[</div>]
|
390
|
+
end
|
391
|
+
|
392
|
+
def image_header(id, caption)
|
393
|
+
puts %Q[<p class="imagecaption">]
|
394
|
+
puts %Q[図#{getChap}#{@chapter.image(id).number}: #{escape_html(caption)}]
|
395
|
+
puts %Q[</p>]
|
396
|
+
end
|
397
|
+
|
398
|
+
def table(lines, id = nil, caption = nil)
|
399
|
+
rows = []
|
400
|
+
sepidx = nil
|
401
|
+
lines.each_with_index do |line, idx|
|
402
|
+
if /\A[\=\-]{12}/ =~ line
|
403
|
+
# just ignore
|
404
|
+
#error "too many table separator" if sepidx
|
405
|
+
sepidx ||= idx
|
406
|
+
next
|
407
|
+
end
|
408
|
+
rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
|
409
|
+
end
|
410
|
+
rows = adjust_n_cols(rows)
|
411
|
+
|
412
|
+
begin
|
413
|
+
table_header id, caption unless caption.nil?
|
414
|
+
rescue KeyError => err
|
415
|
+
error "no such table: #{id}"
|
416
|
+
end
|
417
|
+
table_begin rows.first.size
|
418
|
+
return if rows.empty?
|
419
|
+
if sepidx
|
420
|
+
sepidx.times do
|
421
|
+
tr rows.shift.map {|s| th(compile_inline(s)) }
|
422
|
+
end
|
423
|
+
rows.each do |cols|
|
424
|
+
tr cols.map {|s| td(compile_inline(s)) }
|
425
|
+
end
|
426
|
+
else
|
427
|
+
rows.each do |cols|
|
428
|
+
h, *cs = *cols
|
429
|
+
tr [th(compile_inline(h))] + cs.map {|s| td(compile_inline(s)) }
|
430
|
+
end
|
431
|
+
end
|
432
|
+
table_end
|
433
|
+
end
|
434
|
+
|
435
|
+
def table_header(id, caption)
|
436
|
+
puts %Q[<p class="tablecaption">表#{getChap}#{@chapter.table(id).number}: #{escape_html(caption)}</p>]
|
437
|
+
end
|
438
|
+
|
439
|
+
def table_begin(ncols)
|
440
|
+
puts '<table>'
|
441
|
+
end
|
442
|
+
|
443
|
+
def tr(rows)
|
444
|
+
puts "<tr>#{rows.join('')}</tr>"
|
445
|
+
end
|
446
|
+
|
447
|
+
def th(str)
|
448
|
+
"<th>#{str}</th>"
|
449
|
+
end
|
450
|
+
|
451
|
+
def td(str)
|
452
|
+
"<td>#{str}</td>"
|
453
|
+
end
|
454
|
+
|
455
|
+
def table_end
|
456
|
+
puts '</table>'
|
457
|
+
end
|
458
|
+
|
459
|
+
def comment(str)
|
460
|
+
puts %Q(<!-- #{escape_html(str)} -->)
|
461
|
+
end
|
462
|
+
|
463
|
+
def footnote(id, str)
|
464
|
+
puts %Q(<div class="footnote"><p class="footnote"><a id="fn-#{id}">[*#{@chapter.footnote(id).number}] #{escape_html(str)}</a></p></div>)
|
465
|
+
end
|
466
|
+
|
467
|
+
def hr
|
468
|
+
puts "<hr/>"
|
469
|
+
end
|
470
|
+
|
471
|
+
def label(id)
|
472
|
+
puts %Q(<a id="#{id}" />)
|
473
|
+
end
|
474
|
+
|
475
|
+
def linebreak
|
476
|
+
puts "<br />"
|
477
|
+
end
|
478
|
+
|
479
|
+
def pagebreak
|
480
|
+
puts %Q(<br class="pagebreak" />)
|
481
|
+
end
|
482
|
+
|
483
|
+
def bpo(lines)
|
484
|
+
puts "<bpo>"
|
485
|
+
lines.each do |line|
|
486
|
+
puts detab(line)
|
487
|
+
end
|
488
|
+
puts "</bpo>"
|
489
|
+
end
|
490
|
+
|
491
|
+
def flushright(lines)
|
492
|
+
puts "<p align='right'>#{lines.join("\n")}</p>"
|
493
|
+
end
|
494
|
+
|
495
|
+
def note(lines, caption = nil)
|
496
|
+
puts '<div class="note">'
|
497
|
+
puts "<p class='notecaption'>#{escape_html(caption)}</p>" unless caption.nil?
|
498
|
+
puts "#{lines.join("\n")}</div>"
|
499
|
+
end
|
500
|
+
|
501
|
+
def inline_fn(id)
|
502
|
+
%Q(<a href="\#fn-#{id}">*#{@chapter.footnote(id).number}</a>)
|
503
|
+
end
|
504
|
+
|
505
|
+
def compile_ruby(base, ruby)
|
506
|
+
%Q[<ruby><rb>{escape_html(base)}</rb><rp>(</rp><rt>#{ruby}</rt><rp>)</rp></ruby>]
|
507
|
+
end
|
508
|
+
|
509
|
+
def compile_kw(word, alt)
|
510
|
+
'<span class="kw">' +
|
511
|
+
if alt
|
512
|
+
#then escape_html(word + sprintf(@locale[:parens], alt.strip))
|
513
|
+
then escape_html(word + " (#{alt.strip})")
|
514
|
+
else escape_html(word)
|
515
|
+
end +
|
516
|
+
"</span><!-- IDX:#{escape_html(word)} -->"
|
517
|
+
end
|
518
|
+
|
519
|
+
def compile_href(url, label)
|
520
|
+
%Q(<a href="#{escape_html(url)}" class="link">#{label.nil? ? escape_html(url) : escape_html(label)}</a>)
|
521
|
+
end
|
522
|
+
|
523
|
+
def inline_i(str)
|
524
|
+
%Q(<i>#{escape_html(str)}</i>)
|
525
|
+
end
|
526
|
+
|
527
|
+
def inline_b(str)
|
528
|
+
%Q(<b>#{escape_html(str)}</b>)
|
529
|
+
end
|
530
|
+
|
531
|
+
def inline_ami(str)
|
532
|
+
%Q(<span class="ami">#{escape_html(str)}</span>)
|
533
|
+
end
|
534
|
+
|
535
|
+
def inline_tti(str)
|
536
|
+
%Q(<tt><i>#{escape_html(str)}</i></tt>)
|
537
|
+
end
|
538
|
+
|
539
|
+
def inline_dtp(arg)
|
540
|
+
# ignore all
|
541
|
+
''
|
542
|
+
end
|
543
|
+
|
544
|
+
def inline_code(str)
|
545
|
+
%Q(<span class="inline-code">#{str}</span>)
|
546
|
+
end
|
547
|
+
|
548
|
+
def inline_idx(str)
|
549
|
+
%Q(#{escape_html(str)}<!-- IDX:#{escape_html(str)} -->)
|
550
|
+
end
|
551
|
+
|
552
|
+
def inline_hidx(str)
|
553
|
+
%Q(<!-- IDX:#{escape_html(str)} -->)
|
554
|
+
end
|
555
|
+
|
556
|
+
def text(str)
|
557
|
+
str
|
558
|
+
end
|
559
|
+
|
560
|
+
def bibpaper_header(id, caption)
|
561
|
+
puts %Q(<a id="bib-#{id}">)
|
562
|
+
puts "[#{@chapter.bibpaper(id).number}] #{caption}"
|
563
|
+
puts %Q(</a>)
|
564
|
+
end
|
565
|
+
|
566
|
+
def bibpaper_bibpaper(id, caption, lines)
|
567
|
+
puts %Q(<p>)
|
568
|
+
lines.each do |line|
|
569
|
+
puts detab(line)
|
570
|
+
end
|
571
|
+
puts %Q(</p>)
|
572
|
+
end
|
573
|
+
|
574
|
+
def noindent
|
575
|
+
# dummy
|
576
|
+
end
|
577
|
+
|
578
|
+
def inline_bib(id)
|
579
|
+
%Q(<a href=".#{@book.bib_file.gsub(/re$/, "html")}\#bib-#{id}">[#{@chapter.bibpaper(id).number}]</a>)
|
580
|
+
end
|
581
|
+
|
582
|
+
def nofunc_text(str)
|
583
|
+
escape_html(str)
|
584
|
+
end
|
585
|
+
|
586
|
+
def inline_list(id)
|
587
|
+
"リスト#{getChap}#{@chapter.list(id).number}"
|
588
|
+
rescue KeyError
|
589
|
+
error "unknown list: #{id}"
|
590
|
+
nofunc_text("[UnknownList:#{id}]")
|
591
|
+
end
|
592
|
+
|
593
|
+
def inline_img(id)
|
594
|
+
"図#{getChap}#{@chapter.image(id).number}"
|
595
|
+
rescue KeyError
|
596
|
+
error "unknown image: #{id}"
|
597
|
+
nofunc_text("[UnknownImage:#{id}]")
|
598
|
+
end
|
599
|
+
|
600
|
+
def inline_table(id)
|
601
|
+
"表#{getChap}#{@chapter.table(id).number}"
|
602
|
+
rescue KeyError
|
603
|
+
error "unknown table: #{id}"
|
604
|
+
nofunc_text("[UnknownTable:#{id}]")
|
605
|
+
end
|
606
|
+
|
607
|
+
def inline_asis(str, tag)
|
608
|
+
%Q(<#{tag}>#{escape_html(str)}</#{tag}>)
|
609
|
+
end
|
610
|
+
|
611
|
+
def inline_abbr(str)
|
612
|
+
inline_asis(str, "abbr")
|
613
|
+
end
|
614
|
+
|
615
|
+
def inline_acronym(str)
|
616
|
+
inline_asis(str, "acronym")
|
617
|
+
end
|
618
|
+
|
619
|
+
def inline_cite(str)
|
620
|
+
inline_asis(str, "cite")
|
621
|
+
end
|
622
|
+
|
623
|
+
def inline_dfn(str)
|
624
|
+
inline_asis(str, "dfn")
|
625
|
+
end
|
626
|
+
|
627
|
+
def inline_em(str)
|
628
|
+
inline_asis(str, "em")
|
629
|
+
end
|
630
|
+
|
631
|
+
def inline_kbd(str)
|
632
|
+
inline_asis(str, "kbd")
|
633
|
+
end
|
634
|
+
|
635
|
+
def inline_samp(str)
|
636
|
+
inline_asis(str, "samp")
|
637
|
+
end
|
638
|
+
|
639
|
+
def inline_strong(str)
|
640
|
+
inline_asis(str, "strong")
|
641
|
+
end
|
642
|
+
|
643
|
+
def inline_var(str)
|
644
|
+
inline_asis(str, "var")
|
645
|
+
end
|
646
|
+
|
647
|
+
def inline_big(str)
|
648
|
+
inline_asis(str, "big")
|
649
|
+
end
|
650
|
+
|
651
|
+
def inline_small(str)
|
652
|
+
inline_asis(str, "small")
|
653
|
+
end
|
654
|
+
|
655
|
+
def inline_sub(str)
|
656
|
+
inline_asis(str, "sub")
|
657
|
+
end
|
658
|
+
|
659
|
+
def inline_sup(str)
|
660
|
+
inline_asis(str, "sup")
|
661
|
+
end
|
662
|
+
|
663
|
+
def inline_tt(str)
|
664
|
+
inline_asis(str, "tt")
|
665
|
+
end
|
666
|
+
|
667
|
+
def inline_del(str)
|
668
|
+
inline_asis(str, "del")
|
669
|
+
end
|
670
|
+
|
671
|
+
def inline_ins(str)
|
672
|
+
inline_asis(str, "ins")
|
673
|
+
end
|
674
|
+
|
675
|
+
def inline_u(str)
|
676
|
+
%Q(<span class="u">#{escape_html(str)}</span>)
|
677
|
+
end
|
678
|
+
|
679
|
+
def inline_recipe(str)
|
680
|
+
# FIXME
|
681
|
+
%Q(<span class="recipe">「#{escape_html(str)}」</span>)
|
682
|
+
end
|
683
|
+
|
684
|
+
def getChap
|
685
|
+
if @param["secnolevel"] > 0 && !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
686
|
+
return "#{@chapter.number}."
|
687
|
+
end
|
688
|
+
return ""
|
689
|
+
end
|
690
|
+
end
|
691
|
+
|
692
|
+
end # module ReVIEW
|