review 0.6.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +441 -0
- data/README.rdoc +25 -0
- data/Rakefile +13 -1
- data/VERSION +1 -1
- data/bin/review-check +1 -1
- data/bin/review-compile +19 -10
- data/bin/review-epubmaker +114 -17
- data/bin/review-index +8 -1
- data/bin/review-pdfmaker +378 -0
- data/bin/review-preproc +2 -3
- data/bin/review-vol +1 -2
- 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 +60 -0
- data/debian/docs +5 -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 +477 -0
- data/doc/format.re +19 -0
- data/doc/format_idg.rdoc +180 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +17 -0
- data/doc/sample.yaml +8 -4
- data/lib/lineinput.rb +1 -1
- data/lib/review/book.rb +43 -36
- data/lib/review/builder.rb +78 -33
- data/lib/review/compiler.rb +45 -48
- data/lib/review/epubbuilder.rb +1 -675
- data/lib/review/exception.rb +1 -1
- data/lib/review/htmlbuilder.rb +627 -49
- data/lib/review/htmlutils.rb +5 -0
- data/lib/review/idgxmlbuilder.rb +239 -250
- data/lib/review/index.rb +84 -7
- data/lib/review/latexbuilder.rb +261 -42
- data/lib/review/latexutils.rb +15 -6
- data/lib/review/preprocessor.rb +40 -6
- data/lib/review/textutils.rb +22 -0
- data/lib/review/topbuilder.rb +4 -1
- data/lib/uuid.rb +312 -0
- data/review.gemspec +44 -12
- data/test/CHAPS +2 -0
- data/test/bib.re +13 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +1191 -0
- data/test/test_builder.rb +147 -0
- data/test/test_htmlbuilder.rb +191 -10
- data/test/test_htmlutils.rb +24 -0
- data/test/test_idgxmlbuilder.rb +310 -0
- data/test/test_index.rb +15 -0
- data/test/test_latexbuilder.rb +217 -6
- data/test/test_lineinput.rb +198 -0
- data/test/test_textutils.rb +68 -0
- data/test/test_uuid.rb +156 -0
- metadata +43 -10
- data/doc/format.txt +0 -434
- data/doc/format_idg.txt +0 -194
- data/doc/format_sjis.txt +0 -313
- data/setup.rb +0 -1587
- data/test/test_epubbuilder.rb +0 -73
data/lib/review/exception.rb
CHANGED
data/lib/review/htmlbuilder.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
# $Id: htmlbuilder.rb 4268 2009-05-27 04:17:08Z kmuto $
|
2
3
|
#
|
3
4
|
# Copyright (c) 2002-2007 Minero Aoki
|
4
|
-
# 2008-
|
5
|
+
# 2008-2010 Minero Aoki, Kenshi Muto
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
8
|
# You can distribute or modify this program under the terms of
|
@@ -20,12 +21,40 @@ module ReVIEW
|
|
20
21
|
include TextUtils
|
21
22
|
include HTMLUtils
|
22
23
|
|
24
|
+
[:icon].each {|e|
|
25
|
+
Compiler.definline(e)
|
26
|
+
}
|
27
|
+
|
28
|
+
Compiler.defblock(:memo, 0..1)
|
29
|
+
Compiler.defblock(:tip, 0..1)
|
30
|
+
Compiler.defblock(:info, 0..1)
|
31
|
+
Compiler.defblock(:planning, 0..1)
|
32
|
+
Compiler.defblock(:best, 0..1)
|
33
|
+
Compiler.defblock(:important, 0..1)
|
34
|
+
Compiler.defblock(:security, 0..1)
|
35
|
+
Compiler.defblock(:caution, 0..1)
|
36
|
+
Compiler.defblock(:notice, 0..1)
|
37
|
+
Compiler.defblock(:point, 0..1)
|
38
|
+
Compiler.defblock(:shoot, 0..1)
|
39
|
+
|
40
|
+
def pre_paragraph
|
41
|
+
'<p>'
|
42
|
+
end
|
43
|
+
def post_paragraph
|
44
|
+
'</p>'
|
45
|
+
end
|
46
|
+
|
23
47
|
def extname
|
24
48
|
'.html'
|
25
49
|
end
|
26
50
|
|
27
51
|
def builder_init(no_error = false)
|
28
52
|
@no_error = no_error
|
53
|
+
@section = 0
|
54
|
+
@subsection = 0
|
55
|
+
@subsubsection = 0
|
56
|
+
@subsubsubsection = 0
|
57
|
+
@noindent = nil
|
29
58
|
end
|
30
59
|
private :builder_init
|
31
60
|
|
@@ -41,7 +70,31 @@ module ReVIEW
|
|
41
70
|
messages() +
|
42
71
|
HTMLLayout.new(@output.string, @chapter.title, layout_file).result
|
43
72
|
else
|
44
|
-
|
73
|
+
# default XHTML header/footer
|
74
|
+
header = <<EOT
|
75
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
76
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
77
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="ja">
|
78
|
+
<head>
|
79
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
80
|
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
81
|
+
EOT
|
82
|
+
unless ReVIEW.book.param["stylesheet"].nil?
|
83
|
+
header += <<EOT
|
84
|
+
<link rel="stylesheet" type="text/css" href="#{ReVIEW.book.param["stylesheet"]}" />
|
85
|
+
EOT
|
86
|
+
end
|
87
|
+
header += <<EOT
|
88
|
+
<meta name="generator" content="ReVIEW" />
|
89
|
+
<title>#{convert_outencoding(@chapter.title)}</title>
|
90
|
+
</head>
|
91
|
+
<body>
|
92
|
+
EOT
|
93
|
+
footer = <<EOT
|
94
|
+
</body>
|
95
|
+
</html>
|
96
|
+
EOT
|
97
|
+
header + messages() + @output.string + footer
|
45
98
|
end
|
46
99
|
end
|
47
100
|
|
@@ -87,24 +140,222 @@ module ReVIEW
|
|
87
140
|
"</ul>\n"
|
88
141
|
end
|
89
142
|
|
143
|
+
def headline_prefix(level)
|
144
|
+
anchor = ""
|
145
|
+
case level
|
146
|
+
when 1
|
147
|
+
@section = 0
|
148
|
+
@subsection = 0
|
149
|
+
@subsubsection = 0
|
150
|
+
@subsubsubsection = 0
|
151
|
+
anchor = "#{@chapter.number}"
|
152
|
+
if ReVIEW.book.param["secnolevel"] >= 1
|
153
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
154
|
+
prefix = "第#{@chapter.number}章 "
|
155
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
156
|
+
prefix = "#{@chapter.number} "
|
157
|
+
end
|
158
|
+
end
|
159
|
+
when 2
|
160
|
+
@section += 1
|
161
|
+
@subsection = 0
|
162
|
+
@subsubsection = 0
|
163
|
+
@subsubsubsection = 0
|
164
|
+
anchor = "#{@chapter.number}-#{@section}"
|
165
|
+
if ReVIEW.book.param["secnolevel"] >= 2
|
166
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
167
|
+
prefix = "#{@chapter.number}.#{@section} "
|
168
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
169
|
+
prefix = "#{@chapter.number}.#{@section} "
|
170
|
+
end
|
171
|
+
end
|
172
|
+
when 3
|
173
|
+
@subsection += 1
|
174
|
+
@subsubsection = 0
|
175
|
+
@subsubsubsection = 0
|
176
|
+
anchor = "#{@chapter.number}-#{@section}-#{@subsection}"
|
177
|
+
if ReVIEW.book.param["secnolevel"] >= 3
|
178
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
179
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection} "
|
180
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
181
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection} "
|
182
|
+
end
|
183
|
+
end
|
184
|
+
when 4
|
185
|
+
@subsubsection += 1
|
186
|
+
@subsubsubsection = 0
|
187
|
+
anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}"
|
188
|
+
if ReVIEW.book.param["secnolevel"] >= 4
|
189
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
190
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection} "
|
191
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
192
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection} "
|
193
|
+
end
|
194
|
+
end
|
195
|
+
when 5
|
196
|
+
@subsubsubsection += 1
|
197
|
+
anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}-#{@subsubsubsection}"
|
198
|
+
if ReVIEW.book.param["secnolevel"] >= 5
|
199
|
+
if @chapter.number.to_s =~ /\A\d+$/
|
200
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection} "
|
201
|
+
elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
|
202
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection} "
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
[prefix, anchor]
|
207
|
+
end
|
208
|
+
private :headline_prefix
|
209
|
+
|
90
210
|
def headline(level, label, caption)
|
211
|
+
prefix, anchor = headline_prefix(level)
|
91
212
|
puts '' if level > 1
|
92
|
-
|
93
|
-
|
213
|
+
a_id = ""
|
214
|
+
unless anchor.nil?
|
215
|
+
a_id = %Q[<a id="h#{anchor}" />]
|
216
|
+
end
|
217
|
+
if caption.empty?
|
218
|
+
puts a_id unless label.nil?
|
94
219
|
else
|
95
|
-
|
220
|
+
if label.nil?
|
221
|
+
puts %Q[<h#{level}>#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
|
222
|
+
else
|
223
|
+
puts %Q[<h#{level} id="#{label}">#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def nonum_begin(level, label, caption)
|
229
|
+
puts '' if level > 1
|
230
|
+
unless caption.empty?
|
231
|
+
if label.nil?
|
232
|
+
puts %Q[<h#{level}>#{compile_inline(caption)}</h#{level}>]
|
233
|
+
else
|
234
|
+
puts %Q[<h#{level} id="#{label}">#{compile_inline(caption)}</h#{level}>]
|
235
|
+
end
|
96
236
|
end
|
97
237
|
end
|
98
238
|
|
239
|
+
def nonum_end(level)
|
240
|
+
end
|
241
|
+
|
99
242
|
def column_begin(level, label, caption)
|
100
|
-
puts
|
101
|
-
headline(level, label, caption)
|
243
|
+
puts %Q[<div class="column">]
|
244
|
+
headline(level, label, caption)
|
102
245
|
end
|
103
246
|
|
104
247
|
def column_end(level)
|
105
248
|
puts '</div>'
|
106
249
|
end
|
107
250
|
|
251
|
+
def xcolumn_begin(level, label, caption)
|
252
|
+
puts %Q[<div class="xcolumn">]
|
253
|
+
headline(level, label, caption)
|
254
|
+
end
|
255
|
+
|
256
|
+
def xcolumn_end(level)
|
257
|
+
puts '</div>'
|
258
|
+
end
|
259
|
+
|
260
|
+
def ref_begin(level, label, caption)
|
261
|
+
print %Q[<div class="reference">]
|
262
|
+
headline(level, label, caption)
|
263
|
+
end
|
264
|
+
|
265
|
+
def ref_end(level)
|
266
|
+
puts '</div>'
|
267
|
+
end
|
268
|
+
|
269
|
+
def sup_begin(level, label, caption)
|
270
|
+
print %Q[<div class="supplement">]
|
271
|
+
headline(level, label, caption)
|
272
|
+
end
|
273
|
+
|
274
|
+
def sup_end(level)
|
275
|
+
puts '</div>'
|
276
|
+
end
|
277
|
+
|
278
|
+
def tsize(str)
|
279
|
+
# null
|
280
|
+
end
|
281
|
+
|
282
|
+
def captionblock(type, lines, caption)
|
283
|
+
puts %Q[<div class="#{type}">]
|
284
|
+
unless caption.nil?
|
285
|
+
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
|
286
|
+
end
|
287
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
288
|
+
blocked_lines = split_paragraph(lines)
|
289
|
+
puts blocked_lines.join("\n")
|
290
|
+
else
|
291
|
+
lines.each {|l|
|
292
|
+
puts "<p>#{l}</p>"
|
293
|
+
}
|
294
|
+
end
|
295
|
+
puts '</div>'
|
296
|
+
end
|
297
|
+
|
298
|
+
def memo(lines, caption = nil)
|
299
|
+
captionblock("memo", lines, caption)
|
300
|
+
end
|
301
|
+
|
302
|
+
def tip(lines, caption = nil)
|
303
|
+
captionblock("tip", lines, caption)
|
304
|
+
end
|
305
|
+
|
306
|
+
def info(lines, caption = nil)
|
307
|
+
captionblock("info", lines, caption)
|
308
|
+
end
|
309
|
+
|
310
|
+
def planning(lines, caption = nil)
|
311
|
+
captionblock("planning", lines, caption)
|
312
|
+
end
|
313
|
+
|
314
|
+
def best(lines, caption = nil)
|
315
|
+
captionblock("best", lines, caption)
|
316
|
+
end
|
317
|
+
|
318
|
+
def important(lines, caption = nil)
|
319
|
+
captionblock("important", lines, caption)
|
320
|
+
end
|
321
|
+
|
322
|
+
def security(lines, caption = nil)
|
323
|
+
captionblock("security", lines, caption)
|
324
|
+
end
|
325
|
+
|
326
|
+
def caution(lines, caption = nil)
|
327
|
+
captionblock("caution", lines, caption)
|
328
|
+
end
|
329
|
+
|
330
|
+
def notice(lines, caption = nil)
|
331
|
+
captionblock("notice", lines, caption)
|
332
|
+
end
|
333
|
+
|
334
|
+
def point(lines, caption = nil)
|
335
|
+
captionblock("point", lines, caption)
|
336
|
+
end
|
337
|
+
|
338
|
+
def shoot(lines, caption = nil)
|
339
|
+
captionblock("shoot", lines, caption)
|
340
|
+
end
|
341
|
+
|
342
|
+
def box(lines, caption = nil)
|
343
|
+
puts %Q[<div class="syntax">]
|
344
|
+
puts %Q[<p class="caption">#{compile_inline(caption)}</p>] unless caption.nil?
|
345
|
+
puts %Q[<pre class="syntax">]
|
346
|
+
lines.each do |line|
|
347
|
+
puts detab(line)
|
348
|
+
end
|
349
|
+
puts '</pre>'
|
350
|
+
puts '</div>'
|
351
|
+
end
|
352
|
+
|
353
|
+
def note(lines, caption = nil)
|
354
|
+
puts %Q[<div class="note">]
|
355
|
+
puts %Q[<p class="caption">#{compile_inline(caption)}</p>] unless caption.nil?
|
356
|
+
puts "#{lines.join("\n")}</div>"
|
357
|
+
end
|
358
|
+
|
108
359
|
def ul_begin
|
109
360
|
puts '<ul>'
|
110
361
|
end
|
@@ -146,7 +397,12 @@ module ReVIEW
|
|
146
397
|
end
|
147
398
|
|
148
399
|
def paragraph(lines)
|
149
|
-
|
400
|
+
if @noindent.nil?
|
401
|
+
puts "<p>#{lines.join}</p>"
|
402
|
+
else
|
403
|
+
puts %Q[<p class="noindent">#{lines.join}</p>]
|
404
|
+
@noindent = nil
|
405
|
+
end
|
150
406
|
end
|
151
407
|
|
152
408
|
def parasep()
|
@@ -154,54 +410,81 @@ module ReVIEW
|
|
154
410
|
end
|
155
411
|
|
156
412
|
def read(lines)
|
157
|
-
|
413
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
414
|
+
blocked_lines = split_paragraph(lines)
|
415
|
+
puts %Q[<div class="lead">\n#{blocked_lines.join("\n")}\n</div>]
|
416
|
+
else
|
417
|
+
puts %Q[<p class="lead">\n#{lines.join("\n")}\n</p>]
|
418
|
+
end
|
158
419
|
end
|
159
420
|
|
160
|
-
|
161
|
-
|
421
|
+
alias :lead read
|
422
|
+
|
423
|
+
def list(lines, id, caption)
|
424
|
+
puts %Q[<div class="caption-code">]
|
425
|
+
begin
|
426
|
+
list_header id, caption
|
427
|
+
rescue KeyError
|
428
|
+
error "no such list: #{id}"
|
429
|
+
end
|
430
|
+
list_body lines
|
431
|
+
puts '</div>'
|
162
432
|
end
|
163
433
|
|
164
434
|
def list_header(id, caption)
|
165
|
-
puts %Q[<p class="
|
435
|
+
puts %Q[<p class="caption">リスト#{getChap}#{@chapter.list(id).number}: #{compile_inline(caption)}</p>]
|
166
436
|
end
|
167
437
|
|
168
438
|
def list_body(lines)
|
169
|
-
puts
|
170
|
-
puts '<pre class="list">'
|
439
|
+
puts %Q[<pre class="list">]
|
171
440
|
lines.each do |line|
|
172
441
|
puts detab(line)
|
173
442
|
end
|
174
443
|
puts '</pre>'
|
444
|
+
end
|
445
|
+
|
446
|
+
def source(lines, caption)
|
447
|
+
puts %Q[<div class="source-code">]
|
448
|
+
source_header caption
|
449
|
+
source_body lines
|
175
450
|
puts '</div>'
|
176
451
|
end
|
177
452
|
|
178
453
|
def source_header(caption)
|
179
|
-
puts %Q[<p class="
|
454
|
+
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
|
180
455
|
end
|
181
456
|
|
182
457
|
def source_body(lines)
|
183
|
-
puts
|
184
|
-
puts '<pre class="source">'
|
458
|
+
puts %Q[<pre class="source">]
|
185
459
|
lines.each do |line|
|
186
460
|
puts detab(line)
|
187
461
|
end
|
188
462
|
puts '</pre>'
|
463
|
+
end
|
464
|
+
|
465
|
+
def listnum(lines, id, caption)
|
466
|
+
puts %Q[<div class="code">]
|
467
|
+
begin
|
468
|
+
list_header id, caption
|
469
|
+
rescue KeyError
|
470
|
+
error "no such list: #{id}"
|
471
|
+
end
|
472
|
+
listnum_body lines
|
189
473
|
puts '</div>'
|
190
474
|
end
|
191
475
|
|
192
476
|
def listnum_body(lines)
|
193
|
-
puts
|
194
|
-
puts '<pre class="list">'
|
477
|
+
puts %Q[<pre class="list">]
|
195
478
|
lines.each_with_index do |line, i|
|
196
479
|
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
197
480
|
end
|
198
481
|
puts '</pre>'
|
199
|
-
puts '</div>'
|
200
482
|
end
|
201
483
|
|
202
|
-
def emlist(lines)
|
203
|
-
puts
|
204
|
-
puts
|
484
|
+
def emlist(lines, caption = nil)
|
485
|
+
puts %Q[<div class="emlist-code">]
|
486
|
+
puts %Q(<p class="caption">#{caption}</p>) unless caption.nil?
|
487
|
+
puts %Q[<pre class="emlist">]
|
205
488
|
lines.each do |line|
|
206
489
|
puts detab(line)
|
207
490
|
end
|
@@ -210,8 +493,8 @@ module ReVIEW
|
|
210
493
|
end
|
211
494
|
|
212
495
|
def emlistnum(lines)
|
213
|
-
puts
|
214
|
-
puts
|
496
|
+
puts %Q[<div class="emlistnum-code">]
|
497
|
+
puts %Q[<pre class="emlist">]
|
215
498
|
lines.each_with_index do |line, i|
|
216
499
|
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
217
500
|
end
|
@@ -220,8 +503,8 @@ module ReVIEW
|
|
220
503
|
end
|
221
504
|
|
222
505
|
def cmd(lines)
|
223
|
-
puts
|
224
|
-
puts
|
506
|
+
puts %Q[<div class="cmd-code">]
|
507
|
+
puts %Q[<pre class="cmd">]
|
225
508
|
lines.each do |line|
|
226
509
|
puts detab(line)
|
227
510
|
end
|
@@ -239,33 +522,125 @@ module ReVIEW
|
|
239
522
|
private :quotedlist
|
240
523
|
|
241
524
|
def quote(lines)
|
242
|
-
|
525
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
526
|
+
blocked_lines = split_paragraph(lines)
|
527
|
+
puts "<blockquote>#{blocked_lines.join("\n")}</blockquote>"
|
528
|
+
else
|
529
|
+
puts "<blockquote><pre>#{lines.join("\n")}</pre></blockquote>"
|
530
|
+
end
|
243
531
|
end
|
244
532
|
|
245
|
-
def
|
246
|
-
|
247
|
-
|
248
|
-
|
533
|
+
def doorquote(lines, ref)
|
534
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
535
|
+
blocked_lines = split_paragraph(lines)
|
536
|
+
puts %Q[<blockquote style="text-align:right;">]
|
537
|
+
puts "#{blocked_lines.join("\n")}"
|
538
|
+
puts %Q[<p>#{ref}より</p>]
|
539
|
+
puts %Q[</blockquote>]
|
540
|
+
else
|
541
|
+
puts <<-QUOTE
|
542
|
+
<blockquote style="text-align:right;">
|
543
|
+
<pre>
|
544
|
+
#{lines.join("\n")}
|
545
|
+
|
546
|
+
#{ref}より</pre>
|
547
|
+
</blockquote>
|
548
|
+
QUOTE
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
def talk(lines)
|
553
|
+
puts %Q[<div class="talk">]
|
554
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
555
|
+
blocked_lines = split_paragraph(lines)
|
556
|
+
puts "#{blocked_lines.join("\n")}"
|
557
|
+
else
|
558
|
+
puts '<pre>'
|
559
|
+
puts "#{lines.join("\n")}"
|
560
|
+
puts '</pre>'
|
561
|
+
end
|
562
|
+
puts '</div>'
|
563
|
+
end
|
564
|
+
|
565
|
+
def texequation(lines)
|
566
|
+
puts %Q[<div class="equation">]
|
567
|
+
if ReVIEW.book.param["mathml"]
|
568
|
+
p = MathML::LaTeX::Parser.new
|
569
|
+
puts p.parse(unescape_html(lines.join("\n")), true)
|
570
|
+
else
|
571
|
+
puts '<pre>'
|
572
|
+
puts "#{lines.join("\n")}"
|
573
|
+
puts '</pre>'
|
574
|
+
end
|
575
|
+
puts '</div>'
|
576
|
+
end
|
577
|
+
|
578
|
+
def image_image(id, caption, metric)
|
579
|
+
# FIXME: should respect metric?
|
580
|
+
puts %Q[<div class="image">]
|
581
|
+
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}" />]
|
249
582
|
image_header id, caption
|
583
|
+
puts %Q[</div>]
|
250
584
|
end
|
251
585
|
|
252
586
|
def image_dummy(id, caption, lines)
|
587
|
+
puts %Q[<div class="image">]
|
253
588
|
puts %Q[<pre class="dummyimage">]
|
254
589
|
lines.each do |line|
|
255
590
|
puts detab(line)
|
256
591
|
end
|
257
592
|
puts %Q[</pre>]
|
258
593
|
image_header id, caption
|
594
|
+
puts %Q[</div>]
|
259
595
|
end
|
260
596
|
|
261
597
|
def image_header(id, caption)
|
262
|
-
puts %Q[<p class="
|
263
|
-
puts %Q[図#{@chapter.image(id).number}: #{
|
598
|
+
puts %Q[<p class="caption">]
|
599
|
+
puts %Q[図#{getChap}#{@chapter.image(id).number}: #{compile_inline(caption)}]
|
264
600
|
puts %Q[</p>]
|
265
601
|
end
|
266
602
|
|
603
|
+
def table(lines, id = nil, caption = nil)
|
604
|
+
rows = []
|
605
|
+
sepidx = nil
|
606
|
+
lines.each_with_index do |line, idx|
|
607
|
+
if /\A[\=\-]{12}/ =~ line
|
608
|
+
# just ignore
|
609
|
+
#error "too many table separator" if sepidx
|
610
|
+
sepidx ||= idx
|
611
|
+
next
|
612
|
+
end
|
613
|
+
rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
|
614
|
+
end
|
615
|
+
rows = adjust_n_cols(rows)
|
616
|
+
|
617
|
+
puts %Q[<div class="table">]
|
618
|
+
begin
|
619
|
+
table_header id, caption unless caption.nil?
|
620
|
+
rescue KeyError => err
|
621
|
+
error "no such table: #{id}"
|
622
|
+
end
|
623
|
+
table_begin rows.first.size
|
624
|
+
return if rows.empty?
|
625
|
+
if sepidx
|
626
|
+
sepidx.times do
|
627
|
+
tr rows.shift.map {|s| th(s) }
|
628
|
+
end
|
629
|
+
rows.each do |cols|
|
630
|
+
tr cols.map {|s| td(s) }
|
631
|
+
end
|
632
|
+
else
|
633
|
+
rows.each do |cols|
|
634
|
+
h, *cs = *cols
|
635
|
+
tr [th(h)] + cs.map {|s| td(s) }
|
636
|
+
end
|
637
|
+
end
|
638
|
+
table_end
|
639
|
+
puts %Q[</div>]
|
640
|
+
end
|
641
|
+
|
267
642
|
def table_header(id, caption)
|
268
|
-
puts %Q[<p class="
|
643
|
+
puts %Q[<p class="caption">表#{getChap}#{@chapter.table(id).number}: #{compile_inline(caption)}</p>]
|
269
644
|
end
|
270
645
|
|
271
646
|
def table_begin(ncols)
|
@@ -273,7 +648,7 @@ module ReVIEW
|
|
273
648
|
end
|
274
649
|
|
275
650
|
def tr(rows)
|
276
|
-
puts "<tr>#{rows.join
|
651
|
+
puts "<tr>#{rows.join}</tr>"
|
277
652
|
end
|
278
653
|
|
279
654
|
def th(str)
|
@@ -289,29 +664,75 @@ module ReVIEW
|
|
289
664
|
end
|
290
665
|
|
291
666
|
def comment(str)
|
292
|
-
puts %Q(
|
667
|
+
puts %Q(<!-- #{escape_html(str)} -->)
|
293
668
|
end
|
294
669
|
|
295
670
|
def footnote(id, str)
|
296
|
-
puts %Q(<p class="
|
671
|
+
puts %Q(<div class="footnote"><p class="footnote"><a id="fn-#{id}">[*#{@chapter.footnote(id).number}] #{compile_inline(str)}</a></p></div>)
|
672
|
+
end
|
673
|
+
|
674
|
+
def indepimage(id, caption="", metric=nil)
|
675
|
+
caption = "" if caption.nil?
|
676
|
+
puts %Q[<div class="image">]
|
677
|
+
begin
|
678
|
+
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{caption}" />]
|
679
|
+
rescue
|
680
|
+
puts %Q[<pre>missing image: #{id}</pre>]
|
681
|
+
end
|
682
|
+
|
683
|
+
unless caption.empty?
|
684
|
+
puts %Q[<p class="caption">]
|
685
|
+
puts %Q[図: #{compile_inline(caption)}]
|
686
|
+
puts %Q[</p>]
|
687
|
+
puts %Q[</div>]
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
alias :numberlessimage indepimage
|
692
|
+
|
693
|
+
def hr
|
694
|
+
puts "<hr />"
|
695
|
+
end
|
696
|
+
|
697
|
+
def label(id)
|
698
|
+
puts %Q(<a id="#{id}" />)
|
699
|
+
end
|
700
|
+
|
701
|
+
def linebreak
|
702
|
+
puts "<br />"
|
703
|
+
end
|
704
|
+
|
705
|
+
def pagebreak
|
706
|
+
puts %Q(<br class="pagebreak" />)
|
707
|
+
end
|
708
|
+
|
709
|
+
def bpo(lines)
|
710
|
+
puts "<bpo>"
|
711
|
+
lines.each do |line|
|
712
|
+
puts detab(line)
|
713
|
+
end
|
714
|
+
puts "</bpo>"
|
715
|
+
end
|
716
|
+
|
717
|
+
def noindent
|
718
|
+
@noindent = true
|
297
719
|
end
|
298
720
|
|
299
721
|
def inline_fn(id)
|
300
|
-
%Q(<a href="
|
722
|
+
%Q(<a href="#fn-#{id}">*#{@chapter.footnote(id).number}</a>)
|
301
723
|
end
|
302
724
|
|
303
725
|
def compile_ruby(base, ruby)
|
304
|
-
escape_html(base)
|
726
|
+
%Q[<ruby><rb>{escape_html(base)}</rb><rp>(</rp><rt>#{ruby}</rt><rp>)</rp></ruby>]
|
305
727
|
end
|
306
728
|
|
307
729
|
def compile_kw(word, alt)
|
308
|
-
|
730
|
+
%Q[<b class="kw">] +
|
309
731
|
if alt
|
310
|
-
#then escape_html(word + sprintf(@locale[:parens], alt.strip))
|
311
732
|
then escape_html(word + " (#{alt.strip})")
|
312
733
|
else escape_html(word)
|
313
734
|
end +
|
314
|
-
|
735
|
+
"</b><!-- IDX:#{escape_html(word)} -->"
|
315
736
|
end
|
316
737
|
|
317
738
|
def inline_i(str)
|
@@ -323,16 +744,44 @@ module ReVIEW
|
|
323
744
|
end
|
324
745
|
|
325
746
|
def inline_ami(str)
|
326
|
-
escape_html(str)
|
747
|
+
%Q(<span class="ami">#{escape_html(str)}</span>)
|
748
|
+
end
|
749
|
+
|
750
|
+
def inline_tti(str)
|
751
|
+
%Q(<tt><i>#{escape_html(str)}</i></tt>)
|
327
752
|
end
|
328
753
|
|
329
|
-
def
|
330
|
-
|
331
|
-
|
754
|
+
def inline_ttb(str)
|
755
|
+
%Q(<tt><b>#{escape_html(str)}</b></tt>)
|
756
|
+
end
|
757
|
+
|
758
|
+
def inline_dtp(str)
|
759
|
+
"<?dtp #{str} ?>"
|
332
760
|
end
|
333
761
|
|
334
762
|
def inline_code(str)
|
335
|
-
%Q(<
|
763
|
+
%Q(<tt class="inline-code">#{str}</tt>)
|
764
|
+
end
|
765
|
+
|
766
|
+
def inline_idx(str)
|
767
|
+
%Q(#{escape_html(str)}<!-- IDX:#{escape_html(str)} -->)
|
768
|
+
end
|
769
|
+
|
770
|
+
def inline_hidx(str)
|
771
|
+
%Q(<!-- IDX:#{escape_html(str)} -->)
|
772
|
+
end
|
773
|
+
|
774
|
+
def inline_br(str)
|
775
|
+
%Q(<br />)
|
776
|
+
end
|
777
|
+
|
778
|
+
def inline_m(str)
|
779
|
+
if ReVIEW.book.param["mathml"]
|
780
|
+
p = MathML::LaTeX::Parser.new
|
781
|
+
%Q[<span class="equation">#{p.parse(str, nil)}</span>]
|
782
|
+
else
|
783
|
+
%Q[<span class="equation">#{escape_html(str)}</span>]
|
784
|
+
end
|
336
785
|
end
|
337
786
|
|
338
787
|
def text(str)
|
@@ -354,7 +803,119 @@ module ReVIEW
|
|
354
803
|
end
|
355
804
|
|
356
805
|
def inline_bib(id)
|
357
|
-
%Q(<a href=".#{@book.bib_file.gsub(/re$/, "html")}
|
806
|
+
%Q(<a href=".#{@book.bib_file.gsub(/re$/, "html")}#bib-#{id}">[#{@chapter.bibpaper(id).number}]</a>)
|
807
|
+
end
|
808
|
+
|
809
|
+
def inline_hd_chap(chap, id)
|
810
|
+
"「#{chap.headline_index.number(id)} #{chap.headline(id).caption}」"
|
811
|
+
end
|
812
|
+
|
813
|
+
def inline_list(id)
|
814
|
+
chapter, id = extract_chapter_id(id)
|
815
|
+
"リスト#{getChap(chapter)}#{chapter.list(id).number}"
|
816
|
+
rescue KeyError
|
817
|
+
error "unknown list: #{id}"
|
818
|
+
nofunc_text("[UnknownList:#{id}]")
|
819
|
+
end
|
820
|
+
|
821
|
+
def inline_table(id)
|
822
|
+
chapter, id = extract_chapter_id(id)
|
823
|
+
"表#{getChap(chapter)}#{chapter.table(id).number}"
|
824
|
+
rescue KeyError
|
825
|
+
error "unknown table: #{id}"
|
826
|
+
nofunc_text("[UnknownTable:#{id}]")
|
827
|
+
end
|
828
|
+
|
829
|
+
def inline_img(id)
|
830
|
+
chapter, id = extract_chapter_id(id)
|
831
|
+
"図#{getChap(chapter)}#{chapter.image(id).number}"
|
832
|
+
rescue KeyError
|
833
|
+
error "unknown image: #{id}"
|
834
|
+
nofunc_text("[UnknownImage:#{id}]")
|
835
|
+
end
|
836
|
+
|
837
|
+
def inline_asis(str, tag)
|
838
|
+
%Q(<#{tag}>#{escape_html(str)}</#{tag}>)
|
839
|
+
end
|
840
|
+
|
841
|
+
def inline_abbr(str)
|
842
|
+
inline_asis(str, "abbr")
|
843
|
+
end
|
844
|
+
|
845
|
+
def inline_acronym(str)
|
846
|
+
inline_asis(str, "acronym")
|
847
|
+
end
|
848
|
+
|
849
|
+
def inline_cite(str)
|
850
|
+
inline_asis(str, "cite")
|
851
|
+
end
|
852
|
+
|
853
|
+
def inline_dfn(str)
|
854
|
+
inline_asis(str, "dfn")
|
855
|
+
end
|
856
|
+
|
857
|
+
def inline_em(str)
|
858
|
+
inline_asis(str, "em")
|
859
|
+
end
|
860
|
+
|
861
|
+
def inline_kbd(str)
|
862
|
+
inline_asis(str, "kbd")
|
863
|
+
end
|
864
|
+
|
865
|
+
def inline_samp(str)
|
866
|
+
inline_asis(str, "samp")
|
867
|
+
end
|
868
|
+
|
869
|
+
def inline_strong(str)
|
870
|
+
inline_asis(str, "strong")
|
871
|
+
end
|
872
|
+
|
873
|
+
def inline_var(str)
|
874
|
+
inline_asis(str, "var")
|
875
|
+
end
|
876
|
+
|
877
|
+
def inline_big(str)
|
878
|
+
inline_asis(str, "big")
|
879
|
+
end
|
880
|
+
|
881
|
+
def inline_small(str)
|
882
|
+
inline_asis(str, "small")
|
883
|
+
end
|
884
|
+
|
885
|
+
def inline_sub(str)
|
886
|
+
inline_asis(str, "sub")
|
887
|
+
end
|
888
|
+
|
889
|
+
def inline_sup(str)
|
890
|
+
inline_asis(str, "sup")
|
891
|
+
end
|
892
|
+
|
893
|
+
def inline_tt(str)
|
894
|
+
inline_asis(str, "tt")
|
895
|
+
end
|
896
|
+
|
897
|
+
def inline_del(str)
|
898
|
+
inline_asis(str, "del")
|
899
|
+
end
|
900
|
+
|
901
|
+
def inline_ins(str)
|
902
|
+
inline_asis(str, "ins")
|
903
|
+
end
|
904
|
+
|
905
|
+
def inline_u(str)
|
906
|
+
%Q(<u>#{escape_html(str)}</u>)
|
907
|
+
end
|
908
|
+
|
909
|
+
def inline_recipe(str)
|
910
|
+
%Q(<span class="recipe">「#{escape_html(str)}」</span>)
|
911
|
+
end
|
912
|
+
|
913
|
+
def inline_icon(id)
|
914
|
+
%Q[<img src=".#{@book.image_dir}#{find_pathes(id)[0].sub(/\A\.\//, "/")}" alt="[#{id}]" />]
|
915
|
+
end
|
916
|
+
|
917
|
+
def inline_uchar(str)
|
918
|
+
%Q(&#x#{str};)
|
358
919
|
end
|
359
920
|
|
360
921
|
def inline_raw(str)
|
@@ -365,6 +926,23 @@ module ReVIEW
|
|
365
926
|
escape_html(str)
|
366
927
|
end
|
367
928
|
|
929
|
+
def compile_href(url, label)
|
930
|
+
%Q(<a href="#{escape_html(url)}" class="link">#{label.nil? ? escape_html(url) : escape_html(label)}</a>)
|
931
|
+
end
|
932
|
+
|
933
|
+
def flushright(lines)
|
934
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
935
|
+
puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"flushright\">")
|
936
|
+
else
|
937
|
+
puts %Q[<div style="text-align:right;">]
|
938
|
+
puts %Q[<pre class="flushright">]
|
939
|
+
lines.each do |line|
|
940
|
+
puts detab(line)
|
941
|
+
end
|
942
|
+
puts '</pre>'
|
943
|
+
puts '</div>'
|
944
|
+
end
|
945
|
+
end
|
368
946
|
end
|
369
947
|
|
370
948
|
end # module ReVIEW
|