review 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.travis.yml +9 -0
  2. data/ChangeLog +326 -0
  3. data/Rakefile +3 -5
  4. data/VERSION +1 -1
  5. data/bin/review-compile +50 -50
  6. data/bin/review-epubmaker +62 -75
  7. data/bin/review-epubmaker-ng +185 -0
  8. data/bin/review-index +2 -1
  9. data/bin/review-pdfmaker +158 -101
  10. data/bin/review-vol +6 -2
  11. data/doc/format.rdoc +111 -46
  12. data/doc/libepubmaker/sample.yaml +90 -0
  13. data/doc/quickstart.rdoc +188 -0
  14. data/doc/sample.yaml +8 -0
  15. data/lib/epubmaker.rb +28 -0
  16. data/lib/epubmaker/content.rb +82 -0
  17. data/lib/epubmaker/epubv2.rb +419 -0
  18. data/lib/epubmaker/epubv3.rb +249 -0
  19. data/lib/epubmaker/producer.rb +204 -0
  20. data/lib/epubmaker/resource.rb +66 -0
  21. data/lib/review.rb +1 -1
  22. data/lib/review/book.rb +27 -4
  23. data/lib/review/builder.rb +153 -20
  24. data/lib/review/compiler.rb +61 -10
  25. data/lib/review/ewbbuilder.rb +3 -2
  26. data/lib/review/htmlbuilder.rb +174 -67
  27. data/lib/review/i18n.rb +30 -0
  28. data/lib/review/i18n.yaml +23 -0
  29. data/lib/review/idgxmlbuilder.rb +110 -63
  30. data/lib/review/index.rb +34 -12
  31. data/lib/review/latexbuilder.rb +128 -33
  32. data/lib/review/latexutils.rb +18 -1
  33. data/lib/review/textbuilder.rb +17 -0
  34. data/lib/review/tocparser.rb +3 -1
  35. data/lib/review/tocprinter.rb +1 -0
  36. data/lib/review/topbuilder.rb +397 -198
  37. data/review.gemspec +101 -100
  38. data/test/test_book.rb +27 -0
  39. data/test/test_epubmaker.rb +507 -0
  40. data/test/test_helper.rb +8 -0
  41. data/test/test_htmlbuilder.rb +295 -10
  42. data/test/test_i18n.rb +64 -0
  43. data/test/test_idgxmlbuilder.rb +268 -10
  44. data/test/test_latexbuilder.rb +316 -20
  45. data/test/test_preprocessor.rb +23 -0
  46. data/test/test_topbuilder.rb +246 -0
  47. metadata +46 -53
  48. data/doc/format.re +0 -505
  49. data/test/test_index.rb +0 -15
@@ -1,3 +1,4 @@
1
+ # -*- coding: euc-jp -*-
1
2
  # $Id: ewbbuilder.rb 2195 2005-11-13 21:52:18Z aamine $
2
3
 
3
4
  require 'review/builder'
@@ -146,7 +147,7 @@ module ReVIEW
146
147
  end
147
148
 
148
149
  def ol_item(num, lines)
149
- print "#{num}//|' + lines.join('')
150
+ print "#{num}//|" + lines.join('')
150
151
  end
151
152
 
152
153
  def ol_end
@@ -162,7 +163,7 @@ module ReVIEW
162
163
  end
163
164
 
164
165
  def vspace
165
- print "\n//h"
166
+ print %Q|\n//h|
166
167
  end
167
168
 
168
169
  def noindent
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
- # $Id: htmlbuilder.rb 4268 2009-05-27 04:17:08Z kmuto $
3
2
  #
4
3
  # Copyright (c) 2002-2007 Minero Aoki
5
- # 2008-2010 Minero Aoki, Kenshi Muto
4
+ # 2008-2012 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
5
+ # KADO Masanori
6
6
  #
7
7
  # This program is free software.
8
8
  # You can distribute or modify this program under the terms of
@@ -21,10 +21,6 @@ module ReVIEW
21
21
  include TextUtils
22
22
  include HTMLUtils
23
23
 
24
- [:icon].each {|e|
25
- Compiler.definline(e)
26
- }
27
-
28
24
  Compiler.defblock(:memo, 0..1)
29
25
  Compiler.defblock(:tip, 0..1)
30
26
  Compiler.defblock(:info, 0..1)
@@ -45,7 +41,7 @@ module ReVIEW
45
41
  end
46
42
 
47
43
  def extname
48
- '.html'
44
+ ".#{ReVIEW.book.param["htmlext"]}"
49
45
  end
50
46
 
51
47
  def builder_init(no_error = false)
@@ -73,16 +69,30 @@ module ReVIEW
73
69
  # default XHTML header/footer
74
70
  header = <<EOT
75
71
  <?xml version="1.0" encoding="UTF-8"?>
72
+ EOT
73
+
74
+ if ReVIEW.book.param["htmlversion"] == 5
75
+ header += <<EOT
76
+ <!DOCTYPE html>
77
+ EOT
78
+ else
79
+ header += <<EOT
76
80
  <!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">
81
+ EOT
82
+ end
83
+
84
+ header += <<EOT
85
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{ReVIEW.book.param["language"]}">
78
86
  <head>
79
87
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
80
88
  <meta http-equiv="Content-Style-Type" content="text/css" />
81
89
  EOT
82
90
  unless ReVIEW.book.param["stylesheet"].nil?
83
- header += <<EOT
84
- <link rel="stylesheet" type="text/css" href="#{ReVIEW.book.param["stylesheet"]}" />
91
+ ReVIEW.book.param["stylesheet"].each do |style|
92
+ header += <<EOT
93
+ <link rel="stylesheet" type="text/css" href="#{style}" />
85
94
  EOT
95
+ end
86
96
  end
87
97
  header += <<EOT
88
98
  <meta name="generator" content="ReVIEW" />
@@ -124,7 +134,7 @@ EOT
124
134
  return '' if @errors.empty?
125
135
  "<h2>Syntax Errors</h2>\n" +
126
136
  "<ul>\n" +
127
- @errors.map {|file, line, msg|
137
+ @errors.map {|file, line, msg|
128
138
  "<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n"
129
139
  }.join('') +
130
140
  "</ul>\n"
@@ -150,10 +160,10 @@ EOT
150
160
  @subsubsubsection = 0
151
161
  anchor = "#{@chapter.number}"
152
162
  if ReVIEW.book.param["secnolevel"] >= 1
153
- if @chapter.number.to_s =~ /\A\d+$/
154
- prefix = "第#{@chapter.number}章 "
163
+ if @chapter.number.to_s =~ /\A\d+\Z/
164
+ prefix = "#{I18n.t("chapter", @chapter.number)}#{I18n.t("chapter_postfix")}"
155
165
  elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
156
- prefix = "#{@chapter.number} "
166
+ prefix = "#{@chapter.number}#{I18n.t("chapter_postfix")}"
157
167
  end
158
168
  end
159
169
  when 2
@@ -163,7 +173,7 @@ EOT
163
173
  @subsubsubsection = 0
164
174
  anchor = "#{@chapter.number}-#{@section}"
165
175
  if ReVIEW.book.param["secnolevel"] >= 2
166
- if @chapter.number.to_s =~ /\A\d+$/
176
+ if @chapter.number.to_s =~ /\A\d+\Z/
167
177
  prefix = "#{@chapter.number}.#{@section} "
168
178
  elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
169
179
  prefix = "#{@chapter.number}.#{@section} "
@@ -175,7 +185,7 @@ EOT
175
185
  @subsubsubsection = 0
176
186
  anchor = "#{@chapter.number}-#{@section}-#{@subsection}"
177
187
  if ReVIEW.book.param["secnolevel"] >= 3
178
- if @chapter.number.to_s =~ /\A\d+$/
188
+ if @chapter.number.to_s =~ /\A\d+\Z/
179
189
  prefix = "#{@chapter.number}.#{@section}.#{@subsection} "
180
190
  elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
181
191
  prefix = "#{@chapter.number}.#{@section}.#{@subsection} "
@@ -186,7 +196,7 @@ EOT
186
196
  @subsubsubsection = 0
187
197
  anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}"
188
198
  if ReVIEW.book.param["secnolevel"] >= 4
189
- if @chapter.number.to_s =~ /\A\d+$/
199
+ if @chapter.number.to_s =~ /\A\d+\Z/
190
200
  prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection} "
191
201
  elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
192
202
  prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection} "
@@ -196,7 +206,7 @@ EOT
196
206
  @subsubsubsection += 1
197
207
  anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}-#{@subsubsubsection}"
198
208
  if ReVIEW.book.param["secnolevel"] >= 5
199
- if @chapter.number.to_s =~ /\A\d+$/
209
+ if @chapter.number.to_s =~ /\A\d+\Z/
200
210
  prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection} "
201
211
  elsif !@chapter.number.nil? && !@chapter.number.to_s.empty?
202
212
  prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection} "
@@ -288,9 +298,7 @@ EOT
288
298
  blocked_lines = split_paragraph(lines)
289
299
  puts blocked_lines.join("\n")
290
300
  else
291
- lines.each {|l|
292
- puts "<p>#{l}</p>"
293
- }
301
+ lines.each {|l| puts "<p>#{l}</p>" }
294
302
  end
295
303
  puts '</div>'
296
304
  end
@@ -342,18 +350,14 @@ EOT
342
350
  def box(lines, caption = nil)
343
351
  puts %Q[<div class="syntax">]
344
352
  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
353
+ print %Q[<pre class="syntax">]
354
+ lines.each {|line| puts detab(line) }
349
355
  puts '</pre>'
350
356
  puts '</div>'
351
357
  end
352
358
 
353
359
  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>"
360
+ captionblock("note", lines, caption)
357
361
  end
358
362
 
359
363
  def ul_begin
@@ -361,7 +365,15 @@ EOT
361
365
  end
362
366
 
363
367
  def ul_item(lines)
364
- puts "<li>#{lines.join("\n")}</li>"
368
+ puts "<li>#{lines.join}</li>"
369
+ end
370
+
371
+ def ul_item_begin(lines)
372
+ print "<li>#{lines.join}"
373
+ end
374
+
375
+ def ul_item_end
376
+ puts "</li>"
365
377
  end
366
378
 
367
379
  def ul_end
@@ -373,7 +385,7 @@ EOT
373
385
  end
374
386
 
375
387
  def ol_item(lines, num)
376
- puts "<li>#{lines.join("\n")}</li>"
388
+ puts "<li>#{lines.join}</li>"
377
389
  end
378
390
 
379
391
  def ol_end
@@ -389,7 +401,7 @@ EOT
389
401
  end
390
402
 
391
403
  def dd(lines)
392
- puts "<dd>#{lines.join("\n")}</dd>"
404
+ puts "<dd>#{lines.join}</dd>"
393
405
  end
394
406
 
395
407
  def dl_end
@@ -432,11 +444,15 @@ EOT
432
444
  end
433
445
 
434
446
  def list_header(id, caption)
435
- puts %Q[<p class="caption">リスト#{getChap}#{@chapter.list(id).number}: #{compile_inline(caption)}</p>]
447
+ if get_chap.nil?
448
+ puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header_without_chapter", [@chapter.list(id).number])} #{compile_inline(caption)}</p>]
449
+ else
450
+ puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header", [get_chap, @chapter.list(id).number])} #{compile_inline(caption)}</p>]
451
+ end
436
452
  end
437
453
 
438
454
  def list_body(lines)
439
- puts %Q[<pre class="list">]
455
+ print %Q[<pre class="list">]
440
456
  lines.each do |line|
441
457
  puts detab(line)
442
458
  end
@@ -455,7 +471,7 @@ EOT
455
471
  end
456
472
 
457
473
  def source_body(lines)
458
- puts %Q[<pre class="source">]
474
+ print %Q[<pre class="source">]
459
475
  lines.each do |line|
460
476
  puts detab(line)
461
477
  end
@@ -474,7 +490,7 @@ EOT
474
490
  end
475
491
 
476
492
  def listnum_body(lines)
477
- puts %Q[<pre class="list">]
493
+ print %Q[<pre class="list">]
478
494
  lines.each_with_index do |line, i|
479
495
  puts detab((i+1).to_s.rjust(2) + ": " + line)
480
496
  end
@@ -484,7 +500,7 @@ EOT
484
500
  def emlist(lines, caption = nil)
485
501
  puts %Q[<div class="emlist-code">]
486
502
  puts %Q(<p class="caption">#{caption}</p>) unless caption.nil?
487
- puts %Q[<pre class="emlist">]
503
+ print %Q[<pre class="emlist">]
488
504
  lines.each do |line|
489
505
  puts detab(line)
490
506
  end
@@ -494,7 +510,7 @@ EOT
494
510
 
495
511
  def emlistnum(lines)
496
512
  puts %Q[<div class="emlistnum-code">]
497
- puts %Q[<pre class="emlist">]
513
+ print %Q[<pre class="emlist">]
498
514
  lines.each_with_index do |line, i|
499
515
  puts detab((i+1).to_s.rjust(2) + ": " + line)
500
516
  end
@@ -502,9 +518,10 @@ EOT
502
518
  puts '</div>'
503
519
  end
504
520
 
505
- def cmd(lines)
521
+ def cmd(lines, caption = nil)
506
522
  puts %Q[<div class="cmd-code">]
507
- puts %Q[<pre class="cmd">]
523
+ puts %Q(<p class="caption">#{caption}</p>) unless caption.nil?
524
+ print %Q[<pre class="cmd">]
508
525
  lines.each do |line|
509
526
  puts detab(line)
510
527
  end
@@ -513,7 +530,7 @@ EOT
513
530
  end
514
531
 
515
532
  def quotedlist(lines, css_class)
516
- puts %Q[<blockquote><pre class="#{css_class}">]
533
+ print %Q[<blockquote><pre class="#{css_class}">]
517
534
  lines.each do |line|
518
535
  puts detab(line)
519
536
  end
@@ -540,8 +557,7 @@ EOT
540
557
  else
541
558
  puts <<-QUOTE
542
559
  <blockquote style="text-align:right;">
543
- <pre>
544
- #{lines.join("\n")}
560
+ <pre>#{lines.join("\n")}
545
561
 
546
562
  #{ref}より</pre>
547
563
  </blockquote>
@@ -555,7 +571,7 @@ QUOTE
555
571
  blocked_lines = split_paragraph(lines)
556
572
  puts "#{blocked_lines.join("\n")}"
557
573
  else
558
- puts '<pre>'
574
+ print '<pre>'
559
575
  puts "#{lines.join("\n")}"
560
576
  puts '</pre>'
561
577
  end
@@ -568,17 +584,30 @@ QUOTE
568
584
  p = MathML::LaTeX::Parser.new
569
585
  puts p.parse(unescape_html(lines.join("\n")), true)
570
586
  else
571
- puts '<pre>'
587
+ print '<pre>'
572
588
  puts "#{lines.join("\n")}"
573
589
  puts '</pre>'
574
590
  end
575
591
  puts '</div>'
576
592
  end
577
593
 
594
+ def handle_metric(str)
595
+ if str =~ /\Ascale=([\d.]+)\Z/
596
+ return "width=\"#{($1.to_f * 100).round}%\""
597
+ else
598
+ k, v = str.split('=', 2)
599
+ return %Q|#{k}=\"#{v.sub(/\A["']/, '').sub(/["']\Z/, '')}\"|
600
+ end
601
+ end
602
+
603
+ def result_metric(array)
604
+ " #{array.join(' ')}"
605
+ end
606
+
578
607
  def image_image(id, caption, metric)
579
- # FIXME: should respect metric?
608
+ metrics = parse_metric("html", metric)
580
609
  puts %Q[<div class="image">]
581
- puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}" />]
610
+ puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
582
611
  image_header id, caption
583
612
  puts %Q[</div>]
584
613
  end
@@ -596,7 +625,11 @@ QUOTE
596
625
 
597
626
  def image_header(id, caption)
598
627
  puts %Q[<p class="caption">]
599
- puts %Q[図#{getChap}#{@chapter.image(id).number}: #{compile_inline(caption)}]
628
+ if get_chap.nil?
629
+ puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header_without_chapter", [@chapter.image(id).number])} #{compile_inline(caption)}]
630
+ else
631
+ puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header", [get_chap, @chapter.image(id).number])} #{compile_inline(caption)}]
632
+ end
600
633
  puts %Q[</p>]
601
634
  end
602
635
 
@@ -640,7 +673,11 @@ QUOTE
640
673
  end
641
674
 
642
675
  def table_header(id, caption)
643
- puts %Q[<p class="caption">表#{getChap}#{@chapter.table(id).number}: #{compile_inline(caption)}</p>]
676
+ if get_chap.nil?
677
+ puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header_without_header", [@chapter.table(id).number])} #{compile_inline(caption)}</p>]
678
+ else
679
+ puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])} #{compile_inline(caption)}</p>]
680
+ end
644
681
  end
645
682
 
646
683
  def table_begin(ncols)
@@ -658,13 +695,17 @@ QUOTE
658
695
  def td(str)
659
696
  "<td>#{str}</td>"
660
697
  end
661
-
698
+
662
699
  def table_end
663
700
  puts '</table>'
664
701
  end
665
702
 
666
703
  def comment(str)
667
- puts %Q(<!-- #{escape_html(str)} -->)
704
+ if ReVIEW.book.param["draft"]
705
+ puts %Q(<div class="draft-comment">#{escape_html(str)}</div>)
706
+ else
707
+ puts %Q(<!-- #{escape_html(str)} -->)
708
+ end
668
709
  end
669
710
 
670
711
  def footnote(id, str)
@@ -672,20 +713,21 @@ QUOTE
672
713
  end
673
714
 
674
715
  def indepimage(id, caption="", metric=nil)
716
+ metrics = parse_metric("html", metric)
675
717
  caption = "" if caption.nil?
676
718
  puts %Q[<div class="image">]
677
719
  begin
678
- puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{caption}" />]
720
+ puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{caption}"#{metrics} />]
679
721
  rescue
680
722
  puts %Q[<pre>missing image: #{id}</pre>]
681
723
  end
682
724
 
683
725
  unless caption.empty?
684
726
  puts %Q[<p class="caption">]
685
- puts %Q[図: #{compile_inline(caption)}]
727
+ puts %Q[#{I18n.t("numberless_image")} #{compile_inline(caption)}]
686
728
  puts %Q[</p>]
687
- puts %Q[</div>]
688
729
  end
730
+ puts %Q[</div>]
689
731
  end
690
732
 
691
733
  alias :numberlessimage indepimage
@@ -718,12 +760,46 @@ QUOTE
718
760
  @noindent = true
719
761
  end
720
762
 
763
+ def inline_chapref(id)
764
+ if ReVIEW.book.param["chapterlink"]
765
+ %Q(<a href="./#{id}.html">#{@chapter.env.chapter_index.display_string(id)}</a>)
766
+ else
767
+ @chapter.env.chapter_index.display_string(id)
768
+ end
769
+ rescue KeyError
770
+ error "unknown chapter: #{id}"
771
+ nofunc_text("[UnknownChapter:#{id}]")
772
+ end
773
+
774
+ def inline_chap(id)
775
+ if ReVIEW.book.param["chapterlink"]
776
+ %Q(<a href="./#{id}.html">#{@chapter.env.chapter_index.number(id)}</a>)
777
+ else
778
+ @chapter.env.chapter_index.number(id)
779
+ end
780
+ rescue KeyError
781
+ error "unknown chapter: #{id}"
782
+ nofunc_text("[UnknownChapter:#{id}]")
783
+ end
784
+
785
+ def inline_title(id)
786
+ if ReVIEW.book.param["chapterlink"]
787
+ %Q(<a href="./#{id}.html">#{@chapter.env.chapter_index.title(id)}</a>)
788
+ else
789
+ @chapter.env.chapter_index.title(id)
790
+ end
791
+ rescue KeyError
792
+ error "unknown chapter: #{id}"
793
+ nofunc_text("[UnknownChapter:#{id}]")
794
+ end
795
+
796
+
721
797
  def inline_fn(id)
722
798
  %Q(<a href="#fn-#{id}">*#{@chapter.footnote(id).number}</a>)
723
799
  end
724
800
 
725
801
  def compile_ruby(base, ruby)
726
- %Q[<ruby><rb>{escape_html(base)}</rb><rp>(</rp><rt>#{ruby}</rt><rp>)</rp></ruby>]
802
+ %Q[<ruby><rb>#{escape_html(base)}</rb><rp>(</rp><rt>#{ruby}</rt><rp>)</rp></ruby>]
727
803
  end
728
804
 
729
805
  def compile_kw(word, alt)
@@ -760,7 +836,7 @@ QUOTE
760
836
  end
761
837
 
762
838
  def inline_code(str)
763
- %Q(<tt class="inline-code">#{str}</tt>)
839
+ %Q(<tt class="inline-code">#{escape_html(str)}</tt>)
764
840
  end
765
841
 
766
842
  def inline_idx(str)
@@ -788,9 +864,18 @@ QUOTE
788
864
  str
789
865
  end
790
866
 
867
+ def bibpaper(lines, id, caption)
868
+ puts "<div>"
869
+ bibpaper_header id, caption
870
+ unless lines.empty?
871
+ bibpaper_bibpaper id, caption, lines
872
+ end
873
+ puts "</div>"
874
+ end
875
+
791
876
  def bibpaper_header(id, caption)
792
- puts %Q(<a name="bib-#{id}">)
793
- puts "[#{@chapter.bibpaper(id).number}] #{caption}"
877
+ puts %Q(<a id="bib-#{id}">)
878
+ puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}"
794
879
  puts %Q(</a>)
795
880
  end
796
881
 
@@ -803,7 +888,7 @@ QUOTE
803
888
  end
804
889
 
805
890
  def inline_bib(id)
806
- %Q(<a href=".#{@book.bib_file.gsub(/re$/, "html")}#bib-#{id}">[#{@chapter.bibpaper(id).number}]</a>)
891
+ %Q(<a href=".#{@book.bib_file.gsub(/re\Z/, "html")}#bib-#{id}">[#{@chapter.bibpaper(id).number}]</a>)
807
892
  end
808
893
 
809
894
  def inline_hd_chap(chap, id)
@@ -812,7 +897,11 @@ QUOTE
812
897
 
813
898
  def inline_list(id)
814
899
  chapter, id = extract_chapter_id(id)
815
- "リスト#{getChap(chapter)}#{chapter.list(id).number}"
900
+ if get_chap(chapter).nil?
901
+ "#{I18n.t("list")}#{I18n.t("format_number_without_header", [chapter.list(id).number])}"
902
+ else
903
+ "#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), chapter.list(id).number])}"
904
+ end
816
905
  rescue KeyError
817
906
  error "unknown list: #{id}"
818
907
  nofunc_text("[UnknownList:#{id}]")
@@ -820,7 +909,11 @@ QUOTE
820
909
 
821
910
  def inline_table(id)
822
911
  chapter, id = extract_chapter_id(id)
823
- "表#{getChap(chapter)}#{chapter.table(id).number}"
912
+ if get_chap(chapter).nil?
913
+ "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}"
914
+ else
915
+ "#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}"
916
+ end
824
917
  rescue KeyError
825
918
  error "unknown table: #{id}"
826
919
  nofunc_text("[UnknownTable:#{id}]")
@@ -828,7 +921,11 @@ QUOTE
828
921
 
829
922
  def inline_img(id)
830
923
  chapter, id = extract_chapter_id(id)
831
- "図#{getChap(chapter)}#{chapter.image(id).number}"
924
+ if get_chap(chapter).nil?
925
+ "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}"
926
+ else
927
+ "#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}"
928
+ end
832
929
  rescue KeyError
833
930
  error "unknown image: #{id}"
834
931
  nofunc_text("[UnknownImage:#{id}]")
@@ -911,15 +1008,23 @@ QUOTE
911
1008
  end
912
1009
 
913
1010
  def inline_icon(id)
914
- %Q[<img src=".#{@book.image_dir}#{find_pathes(id)[0].sub(/\A\.\//, "/")}" alt="[#{id}]" />]
1011
+ %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="[#{id}]" />]
915
1012
  end
916
1013
 
917
1014
  def inline_uchar(str)
918
1015
  %Q(&#x#{str};)
919
1016
  end
920
1017
 
1018
+ def inline_comment(str)
1019
+ if ReVIEW.book.param["draft"]
1020
+ %Q(<span class="draft-comment">#{escape_html(str)}</span>)
1021
+ else
1022
+ %Q(<!-- #{escape_html(str)} -->)
1023
+ end
1024
+ end
1025
+
921
1026
  def inline_raw(str)
922
- escape_html(str)
1027
+ super(str)
923
1028
  end
924
1029
 
925
1030
  def nofunc_text(str)
@@ -935,14 +1040,16 @@ QUOTE
935
1040
  puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"flushright\">")
936
1041
  else
937
1042
  puts %Q[<div style="text-align:right;">]
938
- puts %Q[<pre class="flushright">]
939
- lines.each do |line|
940
- puts detab(line)
941
- end
1043
+ print %Q[<pre class="flushright">]
1044
+ lines.each {|line| puts detab(line) }
942
1045
  puts '</pre>'
943
1046
  puts '</div>'
944
1047
  end
945
1048
  end
1049
+
1050
+ def image_ext
1051
+ "png"
1052
+ end
946
1053
  end
947
1054
 
948
1055
  end # module ReVIEW