review 0.6.0 → 0.9.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.
- 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/htmlutils.rb
CHANGED
data/lib/review/idgxmlbuilder.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
#
|
2
3
|
# Copyright (c) 2002-2007 Minero Aoki
|
3
4
|
# 2008-2010 Minero Aoki, Kenshi Muto
|
@@ -19,11 +20,10 @@ module ReVIEW
|
|
19
20
|
include TextUtils
|
20
21
|
include HTMLUtils
|
21
22
|
|
22
|
-
[:
|
23
|
+
[:ttbold, :hint, :maru, :keytop, :labelref, :ref, :pageref, :icon, :balloon].each {|e|
|
23
24
|
Compiler.definline(e)
|
24
25
|
}
|
25
26
|
Compiler.defsingle(:dtp, 1)
|
26
|
-
Compiler.defsingle(:indepimage, 1)
|
27
27
|
|
28
28
|
Compiler.defblock(:insn, 0..1)
|
29
29
|
Compiler.defblock(:memo, 0..1)
|
@@ -41,11 +41,17 @@ module ReVIEW
|
|
41
41
|
Compiler.defblock(:term, 0)
|
42
42
|
Compiler.defblock(:link, 0..1)
|
43
43
|
Compiler.defblock(:practice, 0)
|
44
|
-
Compiler.defblock(:box, 0..1)
|
45
44
|
Compiler.defblock(:expert, 0)
|
46
|
-
Compiler.defblock(:lead, 0)
|
47
45
|
Compiler.defblock(:rawblock, 0)
|
48
46
|
|
47
|
+
def pre_paragraph
|
48
|
+
'<p>'
|
49
|
+
end
|
50
|
+
|
51
|
+
def post_paragraph
|
52
|
+
'</p>'
|
53
|
+
end
|
54
|
+
|
49
55
|
def extname
|
50
56
|
'.xml'
|
51
57
|
end
|
@@ -55,11 +61,6 @@ module ReVIEW
|
|
55
61
|
end
|
56
62
|
private :builder_init
|
57
63
|
|
58
|
-
def setParameter(param)
|
59
|
-
@param = param
|
60
|
-
alias puts print unless @param["nolf"].nil?
|
61
|
-
end
|
62
|
-
|
63
64
|
def builder_init_file
|
64
65
|
@warns = []
|
65
66
|
@errors = []
|
@@ -71,9 +72,12 @@ module ReVIEW
|
|
71
72
|
@rootelement = "doc"
|
72
73
|
@secttags = nil
|
73
74
|
@tsize = nil
|
75
|
+
@texblockequation = 0
|
76
|
+
@texinlineequation = 0
|
74
77
|
|
75
78
|
print %Q(<?xml version="1.0" encoding="UTF-8"?>\n)
|
76
79
|
print %Q(<#{@rootelement} xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">)
|
80
|
+
alias puts print unless ReVIEW.book.param["nolf"].nil?
|
77
81
|
end
|
78
82
|
private :builder_init_file
|
79
83
|
|
@@ -203,9 +207,9 @@ module ReVIEW
|
|
203
207
|
raise "caption level too deep or unsupported: #{level}"
|
204
208
|
end
|
205
209
|
|
206
|
-
prefix = "" if (level.to_i >
|
210
|
+
prefix = "" if (level.to_i > ReVIEW.book.param["secnolevel"])
|
207
211
|
label = label.nil? ? "" : " id=\"#{label}\""
|
208
|
-
puts %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{
|
212
|
+
puts %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{prefix}#{escape_html(compile_inline(caption))}"?>)
|
209
213
|
end
|
210
214
|
|
211
215
|
def ul_begin
|
@@ -266,41 +270,32 @@ module ReVIEW
|
|
266
270
|
|
267
271
|
def paragraph(lines)
|
268
272
|
if @noindent.nil?
|
269
|
-
if lines[0] =~
|
270
|
-
puts %Q(<p inlist="#{$1.size}">#{lines.join('').sub(
|
273
|
+
if lines[0] =~ /\A(\t+)/
|
274
|
+
puts %Q(<p inlist="#{$1.size}">#{lines.join('').sub(/\A\t+/, "")}</p>)
|
271
275
|
else
|
272
|
-
puts "<p>#{lines.join
|
276
|
+
puts "<p>#{lines.join}</p>"
|
273
277
|
end
|
274
278
|
else
|
275
|
-
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{lines.join
|
279
|
+
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{lines.join}</p>)
|
276
280
|
@noindent = nil
|
277
281
|
end
|
278
282
|
end
|
279
283
|
|
280
284
|
def read(lines)
|
281
|
-
|
285
|
+
blocked_lines = ReVIEW.book.param["deprecated-blocklines"].nil? ? split_paragraph(lines) : lines
|
286
|
+
puts %Q[<p aid:pstyle="lead">#{blocked_lines.join}</p>]
|
282
287
|
end
|
283
288
|
|
284
|
-
|
285
|
-
read(lines)
|
286
|
-
end
|
289
|
+
alias :lead read
|
287
290
|
|
288
291
|
def inline_list(id)
|
289
|
-
|
290
|
-
|
291
|
-
else
|
292
|
-
"<span type='list'>リスト#{@chapter.list(id).number}</span>"
|
293
|
-
end
|
292
|
+
chapter, id = extract_chapter_id(id)
|
293
|
+
"<span type='list'>リスト#{getChap(chapter)}#{chapter.list(id).number}</span>"
|
294
294
|
end
|
295
295
|
|
296
296
|
def list_header(id, caption)
|
297
|
-
|
298
|
-
|
299
|
-
puts %Q[<caption>リスト#{@chapter.number}.#{@chapter.list(id).number} #{escape_html(caption)}</caption>]
|
300
|
-
else
|
301
|
-
puts %Q[<codelist>]
|
302
|
-
puts %Q[<caption>リスト#{@chapter.list(id).number} #{escape_html(caption)}</caption>]
|
303
|
-
end
|
297
|
+
puts %Q[<codelist>]
|
298
|
+
puts %Q[<caption>リスト#{getChap}#{@chapter.list(id).number} #{compile_inline(caption)}</caption>]
|
304
299
|
end
|
305
300
|
|
306
301
|
def list_body(lines)
|
@@ -319,7 +314,7 @@ module ReVIEW
|
|
319
314
|
def emlistnum(lines, caption = nil)
|
320
315
|
_lines = []
|
321
316
|
lines.each_with_index do |line, i|
|
322
|
-
_lines << detab("<span type='lineno'>" + (i+1).to_s.rjust(2) + ": </span>" + line)
|
317
|
+
_lines << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
|
323
318
|
end
|
324
319
|
quotedlist _lines, 'emlist', caption
|
325
320
|
end
|
@@ -327,7 +322,7 @@ module ReVIEW
|
|
327
322
|
def listnum_body(lines)
|
328
323
|
print %Q(<pre>)
|
329
324
|
lines.each_with_index do |line, i|
|
330
|
-
print detab("<span type='lineno'>" + (i+1).to_s.rjust(2) + ": </span>" + line)
|
325
|
+
print detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
|
331
326
|
print "\n"
|
332
327
|
end
|
333
328
|
puts "</pre></codelist>"
|
@@ -339,11 +334,11 @@ module ReVIEW
|
|
339
334
|
|
340
335
|
def quotedlist(lines, css_class, caption)
|
341
336
|
print %Q[<list type='#{css_class}'>]
|
342
|
-
puts "<caption aid:pstyle='#{css_class}-title'>#{
|
337
|
+
puts "<caption aid:pstyle='#{css_class}-title'>#{compile_inline(caption)}</caption>" unless caption.nil?
|
343
338
|
print %Q[<pre>]
|
344
339
|
no = 1
|
345
340
|
lines.each do |line|
|
346
|
-
unless
|
341
|
+
unless ReVIEW.book.param["listinfo"].nil?
|
347
342
|
print "<listinfo line=\"#{no}\""
|
348
343
|
print " begin=\"1\"" if no == 1
|
349
344
|
print " end=\"#{no}\"" if no == lines.size
|
@@ -351,7 +346,7 @@ module ReVIEW
|
|
351
346
|
end
|
352
347
|
print detab(line)
|
353
348
|
print "\n"
|
354
|
-
print "</listinfo>" unless
|
349
|
+
print "</listinfo>" unless ReVIEW.book.param["listinfo"].nil?
|
355
350
|
no += 1
|
356
351
|
end
|
357
352
|
puts '</pre></list>'
|
@@ -359,34 +354,46 @@ module ReVIEW
|
|
359
354
|
private :quotedlist
|
360
355
|
|
361
356
|
def quote(lines)
|
362
|
-
|
357
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
358
|
+
blocked_lines = split_paragraph(lines)
|
359
|
+
puts "<quote>#{blocked_lines.join("")}</quote>"
|
360
|
+
else
|
361
|
+
puts "<quote>#{lines.join("\n")}</quote>"
|
362
|
+
end
|
363
363
|
end
|
364
364
|
|
365
365
|
def inline_table(id)
|
366
|
-
|
367
|
-
|
368
|
-
else
|
369
|
-
"<span type='table'>表#{@chapter.table(id).number}</span>"
|
370
|
-
end
|
366
|
+
chapter, id = extract_chapter_id(id)
|
367
|
+
"<span type='table'>表#{getChap(chapter)}#{chapter.table(id).number}</span>"
|
371
368
|
end
|
372
369
|
|
373
370
|
def inline_img(id)
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
371
|
+
chapter, id = extract_chapter_id(id)
|
372
|
+
"<span type='image'>図#{getChap(chapter)}#{chapter.image(id).number}</span>"
|
373
|
+
end
|
374
|
+
|
375
|
+
def parse_metric(metric)
|
376
|
+
return [] if metric.nil? || metric.empty?
|
377
|
+
params = []
|
378
|
+
values = metric.split(/\s*?,\s*?/)
|
379
|
+
return [] if values.size == 0
|
380
|
+
values.each {|value|
|
381
|
+
k, v = value.split("=", 2)
|
382
|
+
params.push("#{k}=\"" + v.gsub("\"", '') + "\"")
|
383
|
+
}
|
384
|
+
return params
|
379
385
|
end
|
380
386
|
|
381
|
-
def image_image(id,
|
387
|
+
def image_image(id, caption, metric=nil)
|
382
388
|
puts "<img>"
|
383
|
-
|
389
|
+
params = parse_metric(metric)
|
390
|
+
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}" #{params.join(" ")} />]
|
384
391
|
image_header id, caption
|
385
392
|
puts "</img>"
|
386
393
|
end
|
387
394
|
|
388
395
|
def image_dummy(id, caption, lines)
|
389
|
-
if
|
396
|
+
if ReVIEW.book.param["subdirmode"].nil?
|
390
397
|
warn "image file not exist: images/#{@chapter.id}-#{id}.eps" unless File.exist?("images/#{@chapter.id}-#{id}.eps")
|
391
398
|
else
|
392
399
|
warn "image file not exist: images/#{@chapter.id}/#{id}.eps" unless File.exist?("images/#{@chapter.id}/#{id}.eps")
|
@@ -403,27 +410,29 @@ module ReVIEW
|
|
403
410
|
end
|
404
411
|
|
405
412
|
def image_header(id, caption)
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
413
|
+
puts %Q[<caption>図#{getChap}#{@chapter.image(id).number} #{compile_inline(caption)}</caption>]
|
414
|
+
end
|
415
|
+
|
416
|
+
def texequation(lines)
|
417
|
+
@texblockequation += 1
|
418
|
+
puts %Q[<replace idref="texblock-#{@texblockequation}">]
|
419
|
+
puts '<pre>'
|
420
|
+
puts "#{lines.join("\n")}"
|
421
|
+
puts '</pre>'
|
422
|
+
puts '</replace>'
|
411
423
|
end
|
412
424
|
|
413
425
|
def table(lines, id = nil, caption = nil)
|
414
|
-
# puts %Q(<表 xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table">)
|
415
426
|
tablewidth = nil
|
416
427
|
col = 0
|
417
|
-
unless
|
418
|
-
tablewidth =
|
428
|
+
unless ReVIEW.book.param["tableopt"].nil?
|
429
|
+
tablewidth = ReVIEW.book.param["tableopt"].split(",")[0].to_f / 0.351 # mm -> pt
|
419
430
|
end
|
420
431
|
puts "<table>"
|
421
432
|
rows = []
|
422
433
|
sepidx = nil
|
423
434
|
lines.each_with_index do |line, idx|
|
424
435
|
if /\A[\=\-]{12}/ =~ line
|
425
|
-
# just ignore
|
426
|
-
#error "too many table separator" if sepidx
|
427
436
|
sepidx ||= idx
|
428
437
|
next
|
429
438
|
end
|
@@ -446,7 +455,7 @@ module ReVIEW
|
|
446
455
|
cellwidth = @tsize.split(/\s*,\s*/)
|
447
456
|
totallength = 0
|
448
457
|
cellwidth.size.times {|n|
|
449
|
-
cellwidth[n] = cellwidth[n].to_f / 0.351 # mm->pt
|
458
|
+
cellwidth[n] = cellwidth[n].to_f / 0.351 # mm -> pt
|
450
459
|
totallength = totallength + cellwidth[n]
|
451
460
|
warn "total length exceeds limit for table: #{id}" if totallength > tablewidth
|
452
461
|
}
|
@@ -470,93 +479,65 @@ module ReVIEW
|
|
470
479
|
if tablewidth.nil?
|
471
480
|
print "<tbody>"
|
472
481
|
else
|
473
|
-
print
|
482
|
+
print %Q[<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">]
|
474
483
|
end
|
475
484
|
|
476
485
|
if sepidx
|
477
486
|
sepidx.times do
|
478
487
|
if tablewidth.nil?
|
479
|
-
puts
|
488
|
+
puts %Q[<tr type="header">#{rows.shift}</tr>]
|
480
489
|
else
|
481
490
|
i = 0
|
482
491
|
rows.shift.split(/\t/).each {|cell|
|
483
|
-
print
|
484
|
-
i
|
492
|
+
print %Q[<td aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
|
493
|
+
i += 1
|
485
494
|
}
|
486
495
|
end
|
487
496
|
end
|
497
|
+
end
|
498
|
+
trputs(tablewidth, rows, cellwidth)
|
499
|
+
puts "</tbody></table>"
|
500
|
+
@tsize = nil
|
501
|
+
end
|
488
502
|
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
puts "<tr type=\"lastline\">" + lastline + "</tr>" unless lastline.nil?
|
495
|
-
else
|
496
|
-
rows.each do |row|
|
497
|
-
i = 0
|
498
|
-
row.split(/\t/).each {|cell|
|
499
|
-
print "<td aid:table=\"cell\" aid:crows=\"1\" aid:ccols=\"1\" aid:ccolwidth=\"#{cellwidth[i]}\">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>"
|
500
|
-
i = i + 1
|
501
|
-
}
|
502
|
-
end
|
503
|
+
def trputs(tablewidth, rows, cellwidth)
|
504
|
+
if tablewidth.nil?
|
505
|
+
lastline = rows.pop
|
506
|
+
rows.each do |row|
|
507
|
+
puts %Q[<tr>#{row}</tr>]
|
503
508
|
end
|
509
|
+
puts %Q[<tr type="lastline">#{lastline}</tr>] unless lastline.nil?
|
504
510
|
else
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
else
|
512
|
-
rows.each do |row|
|
513
|
-
i = 0
|
514
|
-
row.split(/\t/).each {|cell|
|
515
|
-
print "<td aid:table=\"cell\" aid:crows=\"1\" aid:ccols=\"1\" aid:ccolwidth=\"#{cellwidth[i]}\">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>"
|
516
|
-
i = i + 1
|
517
|
-
}
|
518
|
-
end
|
511
|
+
rows.each do |row|
|
512
|
+
i = 0
|
513
|
+
row.split(/\t/).each {|cell|
|
514
|
+
print %Q[<td aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
|
515
|
+
i += 1
|
516
|
+
}
|
519
517
|
end
|
520
518
|
end
|
521
|
-
print "</tbody>"
|
522
|
-
puts "</table>"
|
523
|
-
@tsize = nil
|
524
519
|
end
|
525
520
|
|
526
521
|
def table_header(id, caption)
|
527
|
-
|
528
|
-
puts %Q[<caption>表#{@chapter.number}.#{@chapter.table(id).number} #{escape_html(caption)}</caption>]
|
529
|
-
else
|
530
|
-
puts %Q[<caption>表#{@chapter.table(id).number} #{escape_html(caption)}</caption>]
|
531
|
-
end
|
522
|
+
puts %Q[<caption>表#{getChap}#{@chapter.table(id).number} #{compile_inline(caption)}</caption>]
|
532
523
|
end
|
533
524
|
|
534
525
|
def table_begin(ncols)
|
535
|
-
# aid:trows="" aid:tcols="" widths="列1の幅, 列2の幅, ..."をdtp命令で入れておく
|
536
|
-
# puts %Q(<表 xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table">)
|
537
526
|
end
|
538
527
|
|
539
528
|
def tr(rows)
|
540
|
-
|
541
|
-
puts "<tr>" + rows.join("\t") + "</tr>"
|
529
|
+
puts %Q[<tr>#{rows.join("\t")}</tr>]
|
542
530
|
end
|
543
531
|
|
544
532
|
def th(str)
|
545
|
-
|
546
|
-
# FIXME strが2回エスケープされている
|
547
|
-
# %Q(<セル aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="1">#{str}</セル>)
|
548
|
-
%Q(<?dtp tablerow header?>#{str})
|
533
|
+
%Q[<?dtp tablerow header?>#{str}]
|
549
534
|
end
|
550
535
|
|
551
536
|
def td(str)
|
552
|
-
# FIXME aid:ccolwidth=""
|
553
|
-
# FIXME strが2回エスケープされている
|
554
|
-
# %Q(<セル aid:table="cell" aid:crows="1" aid:ccols="1">#{str}</セル>)
|
555
537
|
str
|
556
538
|
end
|
557
539
|
|
558
540
|
def table_end
|
559
|
-
# puts '</表>'
|
560
541
|
print "<?dtp tablerow last?>"
|
561
542
|
end
|
562
543
|
|
@@ -565,63 +546,71 @@ module ReVIEW
|
|
565
546
|
end
|
566
547
|
|
567
548
|
def footnote(id, str)
|
568
|
-
#
|
569
|
-
# puts %Q(<footnote id="#{id}" no="#{@chapter.footnote(id).number}">#{compile_inline(str)}</footnote>)
|
549
|
+
# see inline_fn
|
570
550
|
end
|
571
551
|
|
572
552
|
def inline_fn(id)
|
573
|
-
%Q
|
553
|
+
%Q[<footnote>#{compile_inline(@chapter.footnote(id).content.strip)}</footnote>]
|
574
554
|
end
|
575
555
|
|
576
556
|
def compile_ruby(base, ruby)
|
577
|
-
%Q
|
557
|
+
%Q[<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape_html(base.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rb><aid:rt>#{escape_html(ruby.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rt></aid:ruby></GroupRuby>]
|
578
558
|
end
|
579
559
|
|
580
560
|
def compile_kw(word, alt)
|
581
561
|
'<keyword>' +
|
582
562
|
if alt
|
583
|
-
|
584
|
-
then escape_html(word + "(#{alt.strip})")
|
563
|
+
then escape_html("#{word}(#{alt.strip})")
|
585
564
|
else escape_html(word)
|
586
565
|
end +
|
587
566
|
'</keyword>' +
|
588
|
-
%Q
|
567
|
+
%Q[<index value="#{escape_html(word)}" />] +
|
589
568
|
if alt
|
590
|
-
alt.split(/\s*,\s*/).collect! {|e| %Q
|
569
|
+
alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{escape_html(e.strip)}" />] }.join
|
591
570
|
else
|
592
571
|
""
|
593
572
|
end
|
594
573
|
end
|
595
574
|
|
596
575
|
def compile_href(url, label)
|
597
|
-
%Q
|
576
|
+
%Q[<a linkurl='#{url}'>#{label.nil? ? url : label}</a>]
|
598
577
|
end
|
599
578
|
|
600
579
|
def inline_sup(str)
|
601
|
-
%Q
|
580
|
+
%Q[<sup>#{escape_html(str)}</sup>]
|
602
581
|
end
|
603
582
|
|
604
583
|
def inline_sub(str)
|
605
|
-
%Q
|
584
|
+
%Q[<sub>#{escape_html(str)}</sub>]
|
606
585
|
end
|
607
586
|
|
608
587
|
def inline_raw(str)
|
609
|
-
%Q
|
588
|
+
%Q[#{str.gsub("\\n", "\n")}]
|
610
589
|
end
|
611
590
|
|
612
591
|
def inline_hint(str)
|
613
|
-
if
|
614
|
-
%Q
|
592
|
+
if ReVIEW.book.param["nolf"].nil?
|
593
|
+
%Q[\n<hint>#{escape_html(str)}</hint>]
|
615
594
|
else
|
616
|
-
%Q
|
595
|
+
%Q[<hint>#{escape_html(str)}</hint>]
|
617
596
|
end
|
618
597
|
end
|
619
598
|
|
620
599
|
def inline_maru(str)
|
621
|
-
if str =~
|
600
|
+
if str =~ /\A\d+$/
|
622
601
|
sprintf("&#x%x;", 9311 + str.to_i)
|
623
|
-
elsif str =~
|
624
|
-
|
602
|
+
elsif str =~ /\A[A-Z]$/
|
603
|
+
begin
|
604
|
+
sprintf("&#x%x;", 9398 + str.codepoints.to_a[0] - 65)
|
605
|
+
rescue NoMethodError
|
606
|
+
sprintf("&#x%x;", 9398 + str[0] - 65)
|
607
|
+
end
|
608
|
+
elsif str =~ /\A[a-z]$/
|
609
|
+
begin
|
610
|
+
sprintf("&#x%x;", 9392 + str.codepoints.to_a[0] - 65)
|
611
|
+
rescue NoMethodError
|
612
|
+
sprintf("&#x%x;", 9392 + str[0] - 65)
|
613
|
+
end
|
625
614
|
else
|
626
615
|
raise "can't parse maru: #{str}"
|
627
616
|
end
|
@@ -651,11 +640,13 @@ module ReVIEW
|
|
651
640
|
%Q(<tt>#{escape_html(str)}</tt>)
|
652
641
|
end
|
653
642
|
|
654
|
-
def
|
643
|
+
def inline_ttb(str)
|
655
644
|
index = escape_html(str).gsub(/<.*?>/, "").gsub(/\*/, "ESCAPED_ASTERISK").gsub(/'/, "")
|
656
645
|
%Q(<tt style='bold'>#{escape_html(str)}</tt><index value='#{index}' />)
|
657
646
|
end
|
658
647
|
|
648
|
+
alias :inline_ttbold inline_ttb
|
649
|
+
|
659
650
|
def inline_tti(str)
|
660
651
|
%Q(<tt style='italic'>#{escape_html(str)}</tt>)
|
661
652
|
end
|
@@ -665,39 +656,43 @@ module ReVIEW
|
|
665
656
|
end
|
666
657
|
|
667
658
|
def inline_icon(id)
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
%Q[<Image href="file://images/#{@chapter.id}/#{id}.eps" type='inline'/>]
|
659
|
+
begin
|
660
|
+
%Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}" type="inline" />]
|
661
|
+
rescue
|
662
|
+
warn "no such icon image: #{id}"
|
663
|
+
""
|
674
664
|
end
|
675
665
|
end
|
676
666
|
|
677
667
|
def inline_bou(str)
|
678
|
-
%Q
|
668
|
+
%Q[<bou>#{escape_html(str)}</bou>]
|
679
669
|
end
|
680
670
|
|
681
671
|
def inline_keytop(str)
|
682
|
-
%Q
|
672
|
+
%Q[<keytop>#{escape_html(str)}</keytop>]
|
683
673
|
end
|
684
674
|
|
685
675
|
def inline_labelref(idref)
|
686
|
-
%Q
|
676
|
+
%Q[<ref idref='#{idref}'>「●● #{idref}」</ref>] # FIXME:節名とタイトルも込みで要出力
|
687
677
|
end
|
688
678
|
|
689
679
|
alias inline_ref inline_labelref
|
690
680
|
|
691
681
|
def inline_pageref(idref)
|
692
|
-
%Q
|
682
|
+
%Q[<pageref idref='#{idref}'>●●</pageref>] # ページ番号を参照
|
693
683
|
end
|
694
684
|
|
695
685
|
def inline_balloon(str)
|
696
|
-
%Q
|
686
|
+
%Q[<balloon>#{escape_html(str).gsub(/@maru\[(\d+)\]/) {|m| inline_maru($1)}}</balloon>]
|
697
687
|
end
|
698
688
|
|
699
689
|
def inline_uchar(str)
|
700
|
-
%Q
|
690
|
+
%Q[&#x#{str};]
|
691
|
+
end
|
692
|
+
|
693
|
+
def inline_m(str)
|
694
|
+
@texinlineequation += 1
|
695
|
+
%Q[<replace idref="texinline-#{@texinlineequation}"><pre>#{escape_html(str)}</pre></replace>]
|
701
696
|
end
|
702
697
|
|
703
698
|
def noindent
|
@@ -714,71 +709,74 @@ module ReVIEW
|
|
714
709
|
end
|
715
710
|
|
716
711
|
def nonum_begin(level, label, caption)
|
717
|
-
puts %Q
|
712
|
+
puts %Q[<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{escape_html(compile_inline(caption))}"?>]
|
718
713
|
end
|
719
714
|
|
720
715
|
def nonum_end(level)
|
721
716
|
end
|
722
717
|
|
723
718
|
def circle_begin(level, label, caption)
|
724
|
-
puts %Q
|
719
|
+
puts %Q[<title aid:pstyle="smallcircle">•#{compile_inline(caption)}</title>]
|
725
720
|
end
|
726
721
|
|
727
722
|
def circle_end(level)
|
728
723
|
end
|
729
724
|
|
725
|
+
def common_column_begin(type, caption)
|
726
|
+
print "<#{type}column>"
|
727
|
+
puts %Q[<title aid:pstyle="#{type}column-title">#{compile_inline(caption)}</title>]
|
728
|
+
end
|
729
|
+
|
730
|
+
def common_column_end(type)
|
731
|
+
puts "</#{type}column>"
|
732
|
+
end
|
733
|
+
|
730
734
|
def column_begin(level, label, caption)
|
731
|
-
|
732
|
-
puts %Q(<title aid:pstyle="column-title">#{escape_html(caption)}</title>)
|
735
|
+
common_column_begin("", caption)
|
733
736
|
end
|
734
737
|
|
735
738
|
def column_end(level)
|
736
|
-
|
739
|
+
common_column_end("")
|
737
740
|
end
|
738
741
|
|
739
742
|
def xcolumn_begin(level, label, caption)
|
740
|
-
|
741
|
-
puts %Q(<title aid:pstyle="xcolumn-title">#{escape_html(caption)}</title>)
|
743
|
+
common_column_begin("x", caption)
|
742
744
|
end
|
743
745
|
|
744
746
|
def xcolumn_end(level)
|
745
|
-
|
747
|
+
common_column_end("x")
|
746
748
|
end
|
747
749
|
|
748
750
|
def world_begin(level, label, caption)
|
749
|
-
|
750
|
-
puts %Q(<title aid:pstyle="worldcolumn-title">#{escape_html(caption)}</title>)
|
751
|
+
common_column_begin("world", caption)
|
751
752
|
end
|
752
753
|
|
753
754
|
def world_end(level)
|
754
|
-
|
755
|
+
common_column_end("world")
|
755
756
|
end
|
756
757
|
|
757
758
|
def hood_begin(level, label, caption)
|
758
|
-
|
759
|
-
puts %Q(<title aid:pstyle="hoodcolumn-title">#{escape_html(caption)}</title>)
|
759
|
+
common_column_begin("hood", caption)
|
760
760
|
end
|
761
761
|
|
762
762
|
def hood_end(level)
|
763
|
-
|
763
|
+
common_column_end("hood")
|
764
764
|
end
|
765
765
|
|
766
766
|
def edition_begin(level, label, caption)
|
767
|
-
|
768
|
-
puts %Q(<title aid:pstyle="editioncolumn-title">#{escape_html(caption)}</title>)
|
767
|
+
common_column_begin("edition", caption)
|
769
768
|
end
|
770
769
|
|
771
770
|
def edition_end(level)
|
772
|
-
|
771
|
+
common_column_end("edition")
|
773
772
|
end
|
774
773
|
|
775
774
|
def insideout_begin(level, label, caption)
|
776
|
-
|
777
|
-
puts %Q(<title aid:pstyle="insideoutcolumn-title">#{escape_html(caption)}</title>)
|
775
|
+
common_column_begin("insideout", caption)
|
778
776
|
end
|
779
777
|
|
780
778
|
def insideout_end(level)
|
781
|
-
|
779
|
+
common_column_end("insideout")
|
782
780
|
end
|
783
781
|
|
784
782
|
def ref_begin(level, label, caption)
|
@@ -806,168 +804,155 @@ module ReVIEW
|
|
806
804
|
end
|
807
805
|
|
808
806
|
def flushright(lines)
|
809
|
-
|
807
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
808
|
+
puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
|
809
|
+
else
|
810
|
+
puts "<p align='right'>#{lines.join("\n")}</p>"
|
811
|
+
end
|
812
|
+
end
|
813
|
+
|
814
|
+
def captionblock(type, lines, caption, specialstyle = nil)
|
815
|
+
print "<#{type}>"
|
816
|
+
style = specialstyle.nil? ? "#{type}-title" : specialstyle
|
817
|
+
puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
|
818
|
+
if ReVIEW.book.param["deprecated-blocklines"].nil?
|
819
|
+
blocked_lines = split_paragraph(lines)
|
820
|
+
puts "#{blocked_lines.join}</#{type}>"
|
821
|
+
else
|
822
|
+
puts "#{lines.join("\n")}</#{type}>"
|
823
|
+
end
|
810
824
|
end
|
811
825
|
|
812
826
|
def note(lines, caption = nil)
|
813
|
-
|
814
|
-
puts "<title aid:pstyle='note-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
815
|
-
puts "#{lines.join("\n")}</note>"
|
827
|
+
captionblock("note", lines, caption)
|
816
828
|
end
|
817
829
|
|
818
830
|
def memo(lines, caption = nil)
|
819
|
-
|
820
|
-
puts "<title aid:pstyle='memo-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
821
|
-
puts "#{lines.join("\n")}</memo>"
|
831
|
+
captionblock("memo", lines, caption)
|
822
832
|
end
|
823
833
|
|
824
834
|
def tip(lines, caption = nil)
|
825
|
-
|
826
|
-
puts "<title aid:pstyle='tip-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
827
|
-
puts "#{lines.join("\n")}</tip>"
|
835
|
+
captionblock("tip", lines, caption)
|
828
836
|
end
|
829
837
|
|
830
838
|
def info(lines, caption = nil)
|
831
|
-
|
832
|
-
puts "<title aid:pstyle='info-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
833
|
-
puts "#{lines.join("\n")}</info>"
|
839
|
+
captionblock("info", lines, caption)
|
834
840
|
end
|
835
841
|
|
836
842
|
def planning(lines, caption = nil)
|
837
|
-
|
838
|
-
puts "<title aid:pstyle='planning-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
839
|
-
puts "#{lines.join("\n")}</planning>"
|
843
|
+
captionblock("planning", lines, caption)
|
840
844
|
end
|
841
845
|
|
842
846
|
def best(lines, caption = nil)
|
843
|
-
|
844
|
-
puts "<title aid:pstyle='best-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
845
|
-
puts "#{lines.join("\n")}</best>"
|
847
|
+
captionblock("best", lines, caption)
|
846
848
|
end
|
847
849
|
|
848
850
|
def important(lines, caption = nil)
|
849
|
-
|
850
|
-
puts "<title aid:pstyle='important-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
851
|
-
puts "#{lines.join("\n")}</important>"
|
851
|
+
captionblock("important", lines, caption)
|
852
852
|
end
|
853
853
|
|
854
854
|
def security(lines, caption = nil)
|
855
|
-
|
856
|
-
puts "<title aid:pstyle='security-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
857
|
-
puts "#{lines.join("\n")}</security>"
|
855
|
+
captionblock("security", lines, caption)
|
858
856
|
end
|
859
857
|
|
860
858
|
def caution(lines, caption = nil)
|
861
|
-
|
862
|
-
puts "<title aid:pstyle='caution-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
863
|
-
puts "#{lines.join("\n")}</caution>"
|
859
|
+
captionblock("caution", lines, caption)
|
864
860
|
end
|
865
861
|
|
866
862
|
def term(lines)
|
867
|
-
|
863
|
+
captionblock("term", lines, nil)
|
868
864
|
end
|
869
865
|
|
870
866
|
def link(lines, caption = nil)
|
871
|
-
|
872
|
-
puts "<title aid:pstyle='link-title'>#{escape_html(caption)}</title>" unless caption.nil?
|
873
|
-
puts "#{lines.join("\n")}</link>"
|
867
|
+
captionblock("link", lines, caption)
|
874
868
|
end
|
875
869
|
|
876
870
|
def notice(lines, caption = nil)
|
877
871
|
if caption.nil?
|
878
|
-
|
872
|
+
captionblock("notice", lines, nil)
|
879
873
|
else
|
880
|
-
|
881
|
-
puts "#{lines.join("\n")}</notice-t>"
|
874
|
+
captionblock("notice-t", lines, caption, "notice-title")
|
882
875
|
end
|
883
876
|
end
|
884
877
|
|
885
878
|
def point(lines, caption = nil)
|
886
879
|
if caption.nil?
|
887
|
-
|
880
|
+
captionblock("point", lines, nil)
|
888
881
|
else
|
889
|
-
|
890
|
-
puts "#{lines.join("\n")}</point-t>"
|
882
|
+
captionblock("point-t", lines, caption, "point-title")
|
891
883
|
end
|
892
884
|
end
|
893
885
|
|
894
886
|
def shoot(lines, caption = nil)
|
895
887
|
if caption.nil?
|
896
|
-
|
888
|
+
captionblock("shoot", lines, nil)
|
897
889
|
else
|
898
|
-
|
899
|
-
puts "#{lines.join("\n")}</shoot-t>"
|
890
|
+
captionblock("shoot-t", lines, caption, "shoot-title")
|
900
891
|
end
|
901
892
|
end
|
902
893
|
|
903
894
|
def reference(lines)
|
904
|
-
|
895
|
+
captionblock("reference", lines, nil)
|
905
896
|
end
|
906
897
|
|
907
898
|
def practice(lines)
|
908
|
-
|
899
|
+
captionblock("practice", lines, nil)
|
909
900
|
end
|
910
|
-
|
901
|
+
|
911
902
|
def expert(lines)
|
912
|
-
|
903
|
+
captionblock("expert", lines, nil)
|
913
904
|
end
|
914
905
|
|
915
|
-
def
|
906
|
+
def syntaxblock(type, lines, caption)
|
916
907
|
if caption.nil?
|
917
|
-
puts %Q[
|
908
|
+
puts %Q[<#{type}>]
|
918
909
|
else
|
919
|
-
|
910
|
+
titleopentag = %Q[caption aid:pstyle="#{type}-title"]
|
911
|
+
titleclosetag = "caption"
|
912
|
+
if type == "insn"
|
913
|
+
titleopentag = %Q[floattitle type="insn"]
|
914
|
+
titleclosetag = "floattitle"
|
915
|
+
end
|
916
|
+
puts %Q[<#{type}><#{titleopentag}>#{compile_inline(caption)}</#{titleclosetag}>]
|
920
917
|
end
|
921
918
|
no = 1
|
922
919
|
lines.each do |line|
|
923
|
-
unless
|
924
|
-
print
|
925
|
-
print
|
926
|
-
print
|
927
|
-
print
|
920
|
+
unless ReVIEW.book.param["listinfo"].nil?
|
921
|
+
print %Q[<listinfo line="#{no}"]
|
922
|
+
print %Q[ begin="1"] if no == 1
|
923
|
+
print %Q[ end="#{no}"] if no == lines.size
|
924
|
+
print %Q[>]
|
928
925
|
end
|
929
926
|
print detab(line)
|
930
927
|
print "\n"
|
931
|
-
print "</listinfo>" unless
|
928
|
+
print "</listinfo>" unless ReVIEW.book.param["listinfo"].nil?
|
932
929
|
no += 1
|
933
930
|
end
|
934
|
-
puts "
|
931
|
+
puts "</#{type}>"
|
932
|
+
end
|
933
|
+
|
934
|
+
def insn(lines, caption = nil)
|
935
|
+
syntaxblock("insn", lines, caption)
|
935
936
|
end
|
936
937
|
|
937
938
|
def box(lines, caption = nil)
|
938
|
-
|
939
|
-
print %Q[<box>]
|
940
|
-
else
|
941
|
-
puts %Q[<box><caption aid:pstyle="box-title">#{escape_html(caption)}</caption>]
|
942
|
-
end
|
943
|
-
no = 1
|
944
|
-
lines.each do |line|
|
945
|
-
unless @param["listinfo"].nil?
|
946
|
-
print "<listinfo line=\"#{no}\""
|
947
|
-
print " begin=\"1\"" if no == 1
|
948
|
-
print " end=\"#{no}\"" if no == lines.size
|
949
|
-
print ">"
|
950
|
-
end
|
951
|
-
print detab(line)
|
952
|
-
print "\n"
|
953
|
-
print "</listinfo>" unless @param["listinfo"].nil?
|
954
|
-
no += 1
|
955
|
-
end
|
956
|
-
puts "</box>"
|
939
|
+
syntaxblock("box", lines, caption)
|
957
940
|
end
|
958
941
|
|
959
|
-
|
942
|
+
def indepimage(id, caption=nil, metric=nil)
|
960
943
|
puts "<img>"
|
961
|
-
|
962
|
-
|
963
|
-
puts %Q[<Image href="file
|
964
|
-
|
965
|
-
warn
|
966
|
-
puts %Q[<Image href="file://images/#{@chapter.id}/#{id}.eps" />]
|
944
|
+
params = parse_metric(metric)
|
945
|
+
begin
|
946
|
+
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}" #{params.join(" ")} />]
|
947
|
+
rescue
|
948
|
+
warn %Q[no such image: #{id}]
|
967
949
|
end
|
950
|
+
puts %Q[<caption>#{compile_inline(caption)}</caption>] if !caption.nil? && !caption.empty?
|
968
951
|
puts "</img>"
|
969
952
|
end
|
970
953
|
|
954
|
+
alias :numberlessimage indepimage
|
955
|
+
|
971
956
|
def label(id)
|
972
957
|
# FIXME
|
973
958
|
print "<label id='#{id}' />"
|
@@ -982,7 +967,7 @@ module ReVIEW
|
|
982
967
|
end
|
983
968
|
|
984
969
|
def hr
|
985
|
-
print "<hr/>"
|
970
|
+
print "<hr />"
|
986
971
|
end
|
987
972
|
|
988
973
|
def bpo(lines)
|
@@ -997,6 +982,10 @@ module ReVIEW
|
|
997
982
|
%Q(<tt type='inline-code'>#{escape_html(str)}</tt>)
|
998
983
|
end
|
999
984
|
|
985
|
+
def inline_br(str)
|
986
|
+
"\n"
|
987
|
+
end
|
988
|
+
|
1000
989
|
def rawblock(lines)
|
1001
990
|
no = 1
|
1002
991
|
lines.each {|l|
|
@@ -1012,8 +1001,8 @@ module ReVIEW
|
|
1012
1001
|
|
1013
1002
|
def inline_chapref(id)
|
1014
1003
|
chs = ["", "「", "」"]
|
1015
|
-
unless
|
1016
|
-
_chs = NKF.nkf("-w",
|
1004
|
+
unless ReVIEW.book.param["chapref"].nil?
|
1005
|
+
_chs = NKF.nkf("-w", ReVIEW.book.param["chapref"]).split(",")
|
1017
1006
|
if _chs.size != 3
|
1018
1007
|
error "--chapsplitter must have exactly 3 parameters with comma."
|
1019
1008
|
else
|
@@ -1029,7 +1018,7 @@ module ReVIEW
|
|
1029
1018
|
|
1030
1019
|
def source_header(caption)
|
1031
1020
|
puts %Q[<source>]
|
1032
|
-
puts %Q[<caption>#{
|
1021
|
+
puts %Q[<caption>#{compile_inline(caption)}</caption>]
|
1033
1022
|
end
|
1034
1023
|
|
1035
1024
|
def source_body(lines)
|
@@ -1051,7 +1040,7 @@ module ReVIEW
|
|
1051
1040
|
|
1052
1041
|
def bibpaper_header(id, caption)
|
1053
1042
|
puts %Q(<bibitem id="bib-#{id}">)
|
1054
|
-
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{
|
1043
|
+
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>"
|
1055
1044
|
end
|
1056
1045
|
|
1057
1046
|
def bibpaper_bibpaper(id, caption, lines)
|