review 1.2.0 → 1.3.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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +36 -0
  3. data/.rubocop.yml +1 -0
  4. data/ChangeLog +102 -0
  5. data/README.rdoc +2 -2
  6. data/bin/review-check +18 -16
  7. data/bin/review-compile +49 -42
  8. data/bin/review-epubmaker +23 -993
  9. data/bin/review-epubmaker-legacy +1024 -0
  10. data/bin/review-index +17 -15
  11. data/bin/review-init +39 -9
  12. data/bin/review-pdfmaker +124 -89
  13. data/bin/review-preproc +16 -14
  14. data/bin/review-vol +17 -15
  15. data/debian/docs +1 -1
  16. data/doc/catalog.rdoc +34 -0
  17. data/doc/format.rdoc +16 -2
  18. data/doc/libepubmaker/{config.yaml → config.yml} +63 -19
  19. data/doc/quickstart.rdoc +1 -1
  20. data/doc/{sample.yaml → sample.yml} +0 -0
  21. data/lib/epubmaker.rb +1 -1
  22. data/lib/epubmaker/content.rb +9 -1
  23. data/lib/epubmaker/epubv2.rb +59 -7
  24. data/lib/epubmaker/epubv3.rb +14 -9
  25. data/lib/epubmaker/producer.rb +68 -27
  26. data/lib/epubmaker/resource.rb +3 -1
  27. data/lib/lineinput.rb +2 -2
  28. data/lib/review/book/base.rb +125 -24
  29. data/lib/review/book/chapter.rb +42 -0
  30. data/lib/review/book/compilable.rb +23 -4
  31. data/lib/review/book/image_finder.rb +64 -0
  32. data/lib/review/book/index.rb +64 -50
  33. data/lib/review/book/page_metric.rb +1 -1
  34. data/lib/review/builder.rb +19 -12
  35. data/lib/review/catalog.rb +47 -0
  36. data/lib/review/compiler.rb +3 -2
  37. data/lib/review/configure.rb +5 -3
  38. data/lib/review/epubmaker.rb +130 -46
  39. data/lib/review/ewbbuilder.rb +27 -31
  40. data/lib/review/extentions/string.rb +4 -4
  41. data/lib/review/htmlbuilder.rb +140 -79
  42. data/lib/review/htmllayout.rb +26 -4
  43. data/lib/review/htmlutils.rb +20 -1
  44. data/lib/review/i18n.rb +5 -2
  45. data/lib/review/{i18n.yaml → i18n.yml} +4 -2
  46. data/lib/review/idgxmlbuilder.rb +65 -39
  47. data/lib/review/latexbuilder.rb +72 -24
  48. data/lib/review/latexutils.rb +3 -1
  49. data/lib/review/makerhelper.rb +8 -2
  50. data/lib/review/preprocessor.rb +20 -20
  51. data/lib/review/review.tex.erb +4 -0
  52. data/lib/review/sec_counter.rb +9 -11
  53. data/lib/review/tocparser.rb +2 -2
  54. data/lib/review/tocprinter.rb +12 -12
  55. data/lib/review/topbuilder.rb +15 -15
  56. data/lib/review/version.rb +1 -1
  57. data/lib/uuid.rb +7 -7
  58. data/review.gemspec +2 -2
  59. data/rubocop-todo.yml +443 -0
  60. data/test/sample-book/src/config.yml +2 -2
  61. data/test/sample-book/src/{main.css → style.css} +0 -0
  62. data/test/test_book.rb +46 -48
  63. data/test/test_book_chapter.rb +25 -13
  64. data/test/test_builder.rb +3 -3
  65. data/test/test_catalog.rb +107 -0
  66. data/test/test_epubmaker.rb +6 -6
  67. data/test/test_htmlbuilder.rb +160 -39
  68. data/test/test_htmlutils.rb +22 -0
  69. data/test/test_i18n.rb +2 -2
  70. data/test/test_idgxmlbuilder.rb +33 -47
  71. data/test/test_image_finder.rb +82 -0
  72. data/test/test_inaobuilder.rb +1 -1
  73. data/test/test_latexbuilder.rb +35 -39
  74. data/test/test_lineinput.rb +2 -2
  75. data/test/test_markdownbuilder.rb +2 -2
  76. data/test/test_topbuilder.rb +39 -23
  77. metadata +23 -14
  78. data/bin/review-epubmaker-ng +0 -23
@@ -1,4 +1,4 @@
1
- # -*- coding: euc-jp -*-
1
+ # -*- coding: utf-8 -*-
2
2
  # $Id: ewbbuilder.rb 2195 2005-11-13 21:52:18Z aamine $
3
3
 
4
4
  require 'review/builder'
@@ -6,9 +6,7 @@ require 'review/textutils'
6
6
  require 'review/exception'
7
7
 
8
8
  module ReVIEW
9
-
10
9
  class EWBBuilder < Builder
11
-
12
10
  include TextUtils
13
11
 
14
12
  def initialize(chap)
@@ -39,7 +37,7 @@ module ReVIEW
39
37
  firstline = f.lineno
40
38
  puts
41
39
  puts caption
42
- puts "//lst1"
40
+ puts '//lst1'
43
41
  lines.each do |line|
44
42
  if noescape
45
43
  puts detab(line)
@@ -60,7 +58,7 @@ module ReVIEW
60
58
  def cmd(lines, caption = nil)
61
59
  puts
62
60
  puts caption
63
- puts "//sc1{"
61
+ puts '//sc1{'
64
62
  lines.each do |line|
65
63
  if noescape
66
64
  puts detab(line)
@@ -128,7 +126,7 @@ module ReVIEW
128
126
  output.puts '//}'
129
127
  end
130
128
 
131
- LI = '��'
129
+ LI = ''
132
130
 
133
131
  def ul_begin
134
132
  puts
@@ -165,7 +163,8 @@ module ReVIEW
165
163
  end
166
164
 
167
165
  def vspace
168
- print %Q|\n//h|
166
+ print %Q(
167
+ //h)
169
168
  end
170
169
 
171
170
  def noindent
@@ -224,7 +223,7 @@ module ReVIEW
224
223
  base = key
225
224
  ext = '.eps'
226
225
  end
227
- currname = "images/ch_#{chapter_id()}_#{base}#{ext}"
226
+ currname = "images/ch_#{chapter_id}_#{base}#{ext}"
228
227
  destname = "images/fig#{figure_number(base)}#{ext}"
229
228
  unless File.exist? currname
230
229
  # error "image file not exist: #{currname}"
@@ -233,12 +232,12 @@ module ReVIEW
233
232
  end
234
233
 
235
234
  def image_label(str)
236
- "#{chapter_id()}:#{str}"
235
+ "#{chapter_id}:#{str}"
237
236
  end
238
237
 
239
238
  def text(str)
240
239
  str = str.gsub(/\t/, ' ')
241
- str.gsub(/([^@^]+)|\^(.*?)\^|@<(\w+)>\{(.*?)\}|@\{(.*?)\}|([@^])/) {
240
+ str.gsub(/([^@^]+)|\^(.*?)\^|@<(\w+)>\{(.*?)\}|@\{(.*?)\}|([@^])/) do
242
241
  if normal = $1
243
242
  escape(normal)
244
243
  elsif tt = $2
@@ -253,7 +252,7 @@ module ReVIEW
253
252
  else
254
253
  error "unknown inline: #{str.inspect}"
255
254
  end
256
- }
255
+ end
257
256
  rescue DocumentError => e
258
257
  error e.message
259
258
  return 'ERROR'
@@ -263,11 +262,11 @@ module ReVIEW
263
262
  word, eng, abbr = arg.split(/,/).map {|s| s.strip }
264
263
  if abbr
265
264
  add_index(word) + "//g{#{word}//}" +
266
- add_index(abbr) + "��#{abbr}, " +
267
- add_index(eng) + "#{eng}��"
265
+ add_index(abbr) + "(#{abbr}, " +
266
+ add_index(eng) + "#{eng}"
268
267
  elsif eng
269
268
  add_index(word) + "//g{#{word}//}" +
270
- add_index(eng) + "��#{eng}��"
269
+ add_index(eng) + "(#{eng}"
271
270
  else
272
271
  add_index(word) + "//g{#{word}//}"
273
272
  end
@@ -307,7 +306,7 @@ module ReVIEW
307
306
  "//ruby{#{arg}//}"
308
307
  end
309
308
 
310
- NAKAGURO = '��'
309
+ NAKAGURO = ''
311
310
 
312
311
  def inline_bou(str)
313
312
  "//ruby{#{escape(str)},#{NAKAGURO * char_length(str)}//}"
@@ -325,42 +324,41 @@ module ReVIEW
325
324
  "//LaTeX{ $#{arg}$ //}"
326
325
  end
327
326
 
328
-
329
327
  def chapter_id
330
328
  File.basename(@filename, '.rd')
331
329
  end
332
330
 
333
331
  def chapter_prefix
334
- sprintf('%02d', @chapter_table.number(chapter_id()))
332
+ sprintf('%02d', @chapter_table.number(chapter_id))
335
333
  end
336
334
 
337
- def chapter_number( key )
338
- curr = @chapter_table.number(chapter_id())
335
+ def chapter_number(key)
336
+ curr = @chapter_table.number(chapter_id)
339
337
  dest = @chapter_table.number(key)
340
338
 
341
- case chapter_id()
339
+ case chapter_id
342
340
  when /\.ewb\z/, 'tmp', 'temp'
343
- return '��' + dest + '��'
341
+ return '' + dest + ''
344
342
  end
345
343
  if dest == curr + 1
346
- '����'
344
+ '次章'
347
345
  elsif dest == curr - 1
348
- '����'
346
+ '前章'
349
347
  else
350
- "��#{dest}��"
348
+ "第#{dest}"
351
349
  end
352
350
  end
353
351
 
354
352
  def chapter_name(key)
355
- '��' + text(@chapter_table.title(key)) + '��'
353
+ '' + text(@chapter_table.title(key)) + ''
356
354
  end
357
355
 
358
356
  def list_number(key)
359
- sprintf(chapter_prefix() + '%02d0', @list_table.number(key))
357
+ sprintf(chapter_prefix + '%02d0', @list_table.number(key))
360
358
  end
361
359
 
362
360
  def figure_number(key)
363
- sprintf(chapter_prefix() + '%02d0', @figure_table.number(key))
361
+ sprintf(chapter_prefix + '%02d0', @figure_table.number(key))
364
362
  end
365
363
 
366
364
  def footnote_number(key)
@@ -373,13 +371,11 @@ module ReVIEW
373
371
  end
374
372
 
375
373
  def index_number(n)
376
- 900000 + @chapter_index.number(chapter_id()) * 1000 + n
374
+ 900_000 + @chapter_index.number(chapter_id) * 1000 + n
377
375
  end
378
376
 
379
377
  def escape(str)
380
- str.gsub(%r<//>, '////')
378
+ str.gsub(%r{//}, '////')
381
379
  end
382
-
383
380
  end
384
-
385
381
  end
@@ -5,19 +5,19 @@ end
5
5
  unless String.method_defined?(:lines)
6
6
  # Ruby 1.8
7
7
  class String
8
- alias lines to_a
8
+ alias_method :lines, :to_a
9
9
  end
10
10
  end
11
11
 
12
12
  if String.method_defined?(:bytesize)
13
13
  # Ruby 1.9
14
14
  class String
15
- alias charsize size
15
+ alias_method :charsize, :size
16
16
  end
17
17
  else
18
18
  # Ruby 1.8
19
19
  class String
20
- alias bytesize size
20
+ alias_method :bytesize, :size
21
21
 
22
22
  def charsize
23
23
  split(//).size
@@ -28,6 +28,6 @@ end
28
28
  unless String.method_defined?(:each)
29
29
  # Ruby 1.9
30
30
  class String
31
- alias each each_line
31
+ alias_method :each, :each_line
32
32
  end
33
33
  end
@@ -43,7 +43,7 @@ module ReVIEW
43
43
  end
44
44
 
45
45
  def extname
46
- ".#{ReVIEW.book.param["htmlext"]}"
46
+ ".#{@book.config["htmlext"]}"
47
47
  end
48
48
 
49
49
  def builder_init(no_error = false)
@@ -65,54 +65,82 @@ module ReVIEW
65
65
  def result
66
66
  layout_file = File.join(@book.basedir, "layouts", "layout.erb")
67
67
  if File.exist?(layout_file)
68
- title = convert_outencoding(strip_html(compile_inline(@chapter.title)), ReVIEW.book.param["outencoding"])
69
- messages() +
70
- HTMLLayout.new(@output.string, title, layout_file).result
71
- else
72
- # default XHTML header/footer
73
- header = <<EOT
74
- <?xml version="1.0" encoding="#{ReVIEW.book.param["outencoding"] || :UTF-8}"?>
68
+ if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0
69
+ warn "user's layout is prohibited in safe mode. ignored."
70
+ else
71
+ title = convert_outencoding(strip_html(compile_inline(@chapter.title)), @book.config["outencoding"])
72
+
73
+ toc = ""
74
+ toc_level = 0
75
+ @chapter.headline_index.items.each do |i|
76
+ caption = "<li>#{strip_html(compile_inline(i.caption))}</li>\n"
77
+ if toc_level == i.number.size
78
+ # do nothing
79
+ elsif toc_level < i.number.size
80
+ toc += "<ul>\n" * (i.number.size - toc_level)
81
+ toc_level = i.number.size
82
+ elsif toc_level > i.number.size
83
+ toc += "</ul>\n" * (toc_level - i.number.size)
84
+ toc_level = i.number.size
85
+ toc += "<ul>\n" * (toc_level - 1)
86
+ end
87
+ toc += caption
88
+ end
89
+ toc += "</ul>" * toc_level
90
+
91
+ return messages() +
92
+ HTMLLayout.new(
93
+ {'body' => @output.string, 'title' => title, 'toc' => toc,
94
+ 'builder' => self,
95
+ 'next' => @chapter.next_chapter,
96
+ 'prev' => @chapter.prev_chapter},
97
+ layout_file).result
98
+ end
99
+ end
100
+
101
+ # default XHTML header/footer
102
+ header = <<EOT
103
+ <?xml version="1.0" encoding="#{@book.config["outencoding"] || :UTF-8}"?>
75
104
  EOT
76
- if ReVIEW.book.param["htmlversion"].to_i == 5
77
- header += <<EOT
105
+ if @book.config["htmlversion"].to_i == 5
106
+ header += <<EOT
78
107
  <!DOCTYPE html>
79
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:#{xmlns_ops_prefix}="http://www.idpf.org/2007/ops" xml:lang="#{ReVIEW.book.param["language"]}">
108
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:#{xmlns_ops_prefix}="http://www.idpf.org/2007/ops" xml:lang="#{@book.config["language"]}">
80
109
  <head>
81
- <meta charset="#{ReVIEW.book.param["outencoding"] || :UTF-8}" />
110
+ <meta charset="#{@book.config["outencoding"] || :UTF-8}" />
82
111
  EOT
83
- else
84
- header += <<EOT
112
+ else
113
+ header += <<EOT
85
114
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
86
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{ReVIEW.book.param["language"]}">
115
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{@book.config["language"]}">
87
116
  <head>
88
- <meta http-equiv="Content-Type" content="text/html;charset=#{ReVIEW.book.param["outencoding"] || :UTF-8}" />
117
+ <meta http-equiv="Content-Type" content="text/html;charset=#{@book.config["outencoding"] || :UTF-8}" />
89
118
  <meta http-equiv="Content-Style-Type" content="text/css" />
90
119
  EOT
91
- end
120
+ end
92
121
 
93
- unless ReVIEW.book.param["stylesheet"].nil?
94
- ReVIEW.book.param["stylesheet"].each do |style|
95
- header += <<EOT
122
+ unless @book.config["stylesheet"].nil?
123
+ @book.config["stylesheet"].each do |style|
124
+ header += <<EOT
96
125
  <link rel="stylesheet" type="text/css" href="#{style}" />
97
126
  EOT
98
- end
99
127
  end
100
- header += <<EOT
128
+ end
129
+ header += <<EOT
101
130
  <meta name="generator" content="Re:VIEW" />
102
- <title>#{convert_outencoding(strip_html(compile_inline(@chapter.title)), ReVIEW.book.param["outencoding"])}</title>
131
+ <title>#{convert_outencoding(strip_html(compile_inline(@chapter.title)), @book.config["outencoding"])}</title>
103
132
  </head>
104
133
  <body>
105
134
  EOT
106
- footer = <<EOT
135
+ footer = <<EOT
107
136
  </body>
108
137
  </html>
109
138
  EOT
110
- header + messages() + convert_outencoding(@output.string, ReVIEW.book.param["outencoding"]) + footer
111
- end
139
+ header + messages() + convert_outencoding(@output.string, @book.config["outencoding"]) + footer
112
140
  end
113
141
 
114
142
  def xmlns_ops_prefix
115
- if ReVIEW.book.param["epubversion"].to_i == 3
143
+ if @book.config["epubversion"].to_i == 3
116
144
  "epub"
117
145
  else
118
146
  "ops"
@@ -164,7 +192,7 @@ EOT
164
192
  def headline_prefix(level)
165
193
  @sec_counter.inc(level)
166
194
  anchor = @sec_counter.anchor(level)
167
- prefix = @sec_counter.prefix(level, ReVIEW.book.param["secnolevel"])
195
+ prefix = @sec_counter.prefix(level, @book.config["secnolevel"])
168
196
  [prefix, anchor]
169
197
  end
170
198
  private :headline_prefix
@@ -182,7 +210,7 @@ EOT
182
210
  if label.nil?
183
211
  puts %Q[<h#{level}>#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
184
212
  else
185
- puts %Q[<h#{level} id="#{label}">#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
213
+ puts %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
186
214
  end
187
215
  end
188
216
  end
@@ -193,7 +221,7 @@ EOT
193
221
  if label.nil?
194
222
  puts %Q[<h#{level}>#{compile_inline(caption)}</h#{level}>]
195
223
  else
196
- puts %Q[<h#{level} id="#{label}">#{compile_inline(caption)}</h#{level}>]
224
+ puts %Q[<h#{level} id="#{normalize_id(label)}">#{compile_inline(caption)}</h#{level}>]
197
225
  end
198
226
  end
199
227
  end
@@ -214,7 +242,7 @@ EOT
214
242
  if label.nil?
215
243
  puts %Q[<h#{level}>#{a_id}#{compile_inline(caption)}</h#{level}>]
216
244
  else
217
- puts %Q[<h#{level} id="#{label}">#{a_id}#{compile_inline(caption)}</h#{level}>]
245
+ puts %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{compile_inline(caption)}</h#{level}>]
218
246
  end
219
247
  end
220
248
  # headline(level, label, caption)
@@ -260,7 +288,7 @@ EOT
260
288
  unless caption.nil?
261
289
  puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
262
290
  end
263
- if ReVIEW.book.param["deprecated-blocklines"].nil?
291
+ if @book.config["deprecated-blocklines"].nil?
264
292
  blocked_lines = split_paragraph(lines)
265
293
  puts blocked_lines.join("\n")
266
294
  else
@@ -388,12 +416,12 @@ EOT
388
416
  end
389
417
  end
390
418
 
391
- def parasep()
419
+ def parasep
392
420
  puts '<br />'
393
421
  end
394
422
 
395
423
  def read(lines)
396
- if ReVIEW.book.param["deprecated-blocklines"].nil?
424
+ if @book.config["deprecated-blocklines"].nil?
397
425
  blocked_lines = split_paragraph(lines)
398
426
  puts %Q[<div class="lead">\n#{blocked_lines.join("\n")}\n</div>]
399
427
  else
@@ -401,7 +429,7 @@ EOT
401
429
  end
402
430
  end
403
431
 
404
- alias :lead read
432
+ alias_method :lead, :read
405
433
 
406
434
  def list(lines, id, caption)
407
435
  puts %Q[<div class="caption-code">]
@@ -515,7 +543,7 @@ EOT
515
543
  private :quotedlist
516
544
 
517
545
  def quote(lines)
518
- if ReVIEW.book.param["deprecated-blocklines"].nil?
546
+ if @book.config["deprecated-blocklines"].nil?
519
547
  blocked_lines = split_paragraph(lines)
520
548
  puts "<blockquote>#{blocked_lines.join("\n")}</blockquote>"
521
549
  else
@@ -524,7 +552,7 @@ EOT
524
552
  end
525
553
 
526
554
  def doorquote(lines, ref)
527
- if ReVIEW.book.param["deprecated-blocklines"].nil?
555
+ if @book.config["deprecated-blocklines"].nil?
528
556
  blocked_lines = split_paragraph(lines)
529
557
  puts %Q[<blockquote style="text-align:right;">]
530
558
  puts "#{blocked_lines.join("\n")}"
@@ -543,7 +571,7 @@ QUOTE
543
571
 
544
572
  def talk(lines)
545
573
  puts %Q[<div class="talk">]
546
- if ReVIEW.book.param["deprecated-blocklines"].nil?
574
+ if @book.config["deprecated-blocklines"].nil?
547
575
  blocked_lines = split_paragraph(lines)
548
576
  puts "#{blocked_lines.join("\n")}"
549
577
  else
@@ -556,7 +584,7 @@ QUOTE
556
584
 
557
585
  def texequation(lines)
558
586
  puts %Q[<div class="equation">]
559
- if ReVIEW.book.param["mathml"]
587
+ if @book.config["mathml"]
560
588
  p = MathML::LaTeX::Parser.new(:symbol=>MathML::Symbol::CharacterReference)
561
589
  puts p.parse(unescape_html(lines.join("\n")), true)
562
590
  else
@@ -582,7 +610,7 @@ QUOTE
582
610
 
583
611
  def image_image(id, caption, metric)
584
612
  metrics = parse_metric("html", metric)
585
- puts %Q[<div class="image">]
613
+ puts %Q[<div id="#{normalize_id(id)}" class="image">]
586
614
  puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
587
615
  image_header id, caption
588
616
  puts %Q[</div>]
@@ -623,7 +651,11 @@ QUOTE
623
651
  end
624
652
  rows = adjust_n_cols(rows)
625
653
 
626
- puts %Q[<div class="table">]
654
+ if id
655
+ puts %Q[<div id="#{normalize_id(id)}" class="table">]
656
+ else
657
+ puts %Q[<div class="table">]
658
+ end
627
659
  begin
628
660
  table_header id, caption unless caption.nil?
629
661
  rescue KeyError
@@ -679,20 +711,20 @@ QUOTE
679
711
  def comment(lines, comment = nil)
680
712
  lines ||= []
681
713
  lines.unshift comment unless comment.blank?
682
- if ReVIEW.book.param["draft"]
683
- str = lines.map{|line| escape_html(line) }.join("<br />")
714
+ if @book.config["draft"]
715
+ str = lines.join("<br />")
684
716
  puts %Q(<div class="draft-comment">#{str}</div>)
685
717
  else
686
718
  str = lines.join("\n")
687
- puts %Q(<!-- #{escape_html(str)} -->)
719
+ puts %Q(<!-- #{escape_comment(str)} -->)
688
720
  end
689
721
  end
690
722
 
691
723
  def footnote(id, str)
692
- if ReVIEW.book.param["epubversion"].to_i == 3
693
- puts %Q(<div class="footnote" epub:type="footnote" id="fn-#{id}"><p class="footnote">[*#{@chapter.footnote(id).number}] #{compile_inline(str)}</p></div>)
724
+ if @book.config["epubversion"].to_i == 3
725
+ puts %Q(<div class="footnote" epub:type="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[*#{@chapter.footnote(id).number}] #{compile_inline(str)}</p></div>)
694
726
  else
695
- puts %Q(<div class="footnote"><p class="footnote">[<a id="fn-#{id}">*#{@chapter.footnote(id).number}</a>] #{compile_inline(str)}</p></div>)
727
+ puts %Q(<div class="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[<a href="#fnb-#{normalize_id(id)}">*#{@chapter.footnote(id).number}</a>] #{compile_inline(str)}</p></div>)
696
728
  end
697
729
  end
698
730
 
@@ -714,14 +746,14 @@ QUOTE
714
746
  puts %Q[</div>]
715
747
  end
716
748
 
717
- alias :numberlessimage indepimage
749
+ alias_method :numberlessimage, :indepimage
718
750
 
719
751
  def hr
720
752
  puts "<hr />"
721
753
  end
722
754
 
723
755
  def label(id)
724
- puts %Q(<a id="#{id}"></a>)
756
+ puts %Q(<a id="#{normalize_id(id)}"></a>)
725
757
  end
726
758
 
727
759
  def linebreak
@@ -748,12 +780,12 @@ QUOTE
748
780
  %Q[<a target='#{escape_html(idref)}'>「●● #{escape_html(idref)}」</a>]
749
781
  end
750
782
 
751
- alias inline_ref inline_labelref
783
+ alias_method :inline_ref, :inline_labelref
752
784
 
753
785
  def inline_chapref(id)
754
786
  title = super
755
- if ReVIEW.book.param["chapterlink"]
756
- %Q(<a href="./#{id}.html">#{title}</a>)
787
+ if @book.config["chapterlink"]
788
+ %Q(<a href="./#{id}#{extname}">#{title}</a>)
757
789
  else
758
790
  title
759
791
  end
@@ -763,8 +795,8 @@ QUOTE
763
795
  end
764
796
 
765
797
  def inline_chap(id)
766
- if ReVIEW.book.param["chapterlink"]
767
- %Q(<a href="./#{id}.html">#{@chapter.env.chapter_index.number(id)}</a>)
798
+ if @book.config["chapterlink"]
799
+ %Q(<a href="./#{id}#{extname}">#{@chapter.env.chapter_index.number(id)}</a>)
768
800
  else
769
801
  @chapter.env.chapter_index.number(id)
770
802
  end
@@ -774,8 +806,8 @@ QUOTE
774
806
  end
775
807
 
776
808
  def inline_title(id)
777
- if ReVIEW.book.param["chapterlink"]
778
- %Q(<a href="./#{id}.html">#{compile_inline(@chapter.env.chapter_index.title(id))}</a>)
809
+ if @book.config["chapterlink"]
810
+ %Q(<a href="./#{id}#{extname}">#{compile_inline(@chapter.env.chapter_index.title(id))}</a>)
779
811
  else
780
812
  @chapter.env.chapter_index.title(id)
781
813
  end
@@ -785,15 +817,15 @@ QUOTE
785
817
  end
786
818
 
787
819
  def inline_fn(id)
788
- if ReVIEW.book.param["epubversion"].to_i == 3
789
- %Q(<a href="#fn-#{id}" class="noteref" epub:type="noteref">*#{@chapter.footnote(id).number}</a>)
820
+ if @book.config["epubversion"].to_i == 3
821
+ %Q(<a id="fnb-#{normalize_id(id)}" href="#fn-#{normalize_id(id)}" class="noteref" epub:type="noteref">*#{@chapter.footnote(id).number}</a>)
790
822
  else
791
- %Q(<a href="#fn-#{id}" class="noteref">*#{@chapter.footnote(id).number}</a>)
823
+ %Q(<a id="fnb-#{normalize_id(id)}" href="#fn-#{normalize_id(id)}" class="noteref">*#{@chapter.footnote(id).number}</a>)
792
824
  end
793
825
  end
794
826
 
795
827
  def compile_ruby(base, ruby)
796
- if ReVIEW.book.param["htmlversion"].to_i == 5
828
+ if @book.config["htmlversion"].to_i == 5
797
829
  %Q[<ruby>#{escape_html(base)}<rp>#{I18n.t("ruby_prefix")}</rp><rt>#{escape_html(ruby)}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
798
830
  else
799
831
  %Q[<ruby><rb>#{escape_html(base)}</rb><rp>#{I18n.t("ruby_prefix")}</rp><rt>#{ruby}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
@@ -806,7 +838,7 @@ QUOTE
806
838
  then escape_html(word + " (#{alt.strip})")
807
839
  else escape_html(word)
808
840
  end +
809
- "</b><!-- IDX:#{escape_html(word)} -->"
841
+ "</b><!-- IDX:#{escape_comment(escape_html(word))} -->"
810
842
  end
811
843
 
812
844
  def inline_i(str)
@@ -826,7 +858,7 @@ QUOTE
826
858
  end
827
859
 
828
860
  def inline_tti(str)
829
- if ReVIEW.book.param["htmlversion"].to_i == 5
861
+ if @book.config["htmlversion"].to_i == 5
830
862
  %Q(<code class="tt"><i>#{escape_html(str)}</i></code>)
831
863
  else
832
864
  %Q(<tt><i>#{escape_html(str)}</i></tt>)
@@ -834,7 +866,7 @@ QUOTE
834
866
  end
835
867
 
836
868
  def inline_ttb(str)
837
- if ReVIEW.book.param["htmlversion"].to_i == 5
869
+ if @book.config["htmlversion"].to_i == 5
838
870
  %Q(<code class="tt"><b>#{escape_html(str)}</b></code>)
839
871
  else
840
872
  %Q(<tt><b>#{escape_html(str)}</b></tt>)
@@ -846,7 +878,7 @@ QUOTE
846
878
  end
847
879
 
848
880
  def inline_code(str)
849
- if ReVIEW.book.param["htmlversion"].to_i == 5
881
+ if @book.config["htmlversion"].to_i == 5
850
882
  %Q(<code class="inline-code tt">#{escape_html(str)}</code>)
851
883
  else
852
884
  %Q(<tt class="inline-code">#{escape_html(str)}</tt>)
@@ -854,11 +886,11 @@ QUOTE
854
886
  end
855
887
 
856
888
  def inline_idx(str)
857
- %Q(#{escape_html(str)}<!-- IDX:#{escape_html(str)} -->)
889
+ %Q(#{escape_html(str)}<!-- IDX:#{escape_comment(escape_html(str))} -->)
858
890
  end
859
891
 
860
892
  def inline_hidx(str)
861
- %Q(<!-- IDX:#{escape_html(str)} -->)
893
+ %Q(<!-- IDX:#{escape_comment(escape_html(str))} -->)
862
894
  end
863
895
 
864
896
  def inline_br(str)
@@ -866,7 +898,7 @@ QUOTE
866
898
  end
867
899
 
868
900
  def inline_m(str)
869
- if ReVIEW.book.param["mathml"]
901
+ if @book.config["mathml"]
870
902
  p = MathML::LaTeX::Parser.new(:symbol=>MathML::Symbol::CharacterReference)
871
903
  %Q[<span class="equation">#{p.parse(str, nil)}</span>]
872
904
  else
@@ -888,7 +920,7 @@ QUOTE
888
920
  end
889
921
 
890
922
  def bibpaper_header(id, caption)
891
- print %Q(<a id="bib-#{id}">)
923
+ print %Q(<a id="bib-#{normalize_id(id)}">)
892
924
  print "[#{@chapter.bibpaper(id).number}]"
893
925
  print %Q(</a>)
894
926
  puts " #{compile_inline(caption)}"
@@ -904,19 +936,36 @@ QUOTE
904
936
 
905
937
  def inline_hd_chap(chap, id)
906
938
  n = chap.headline_index.number(id)
907
- if chap.number and ReVIEW.book.param["secnolevel"] >= n.split('.').size
939
+ if chap.number and @book.config["secnolevel"] >= n.split('.').size
908
940
  str = "「#{n} #{compile_inline(chap.headline(id).caption)}」"
909
941
  else
910
942
  str = "「#{compile_inline(chap.headline(id).caption)}」"
911
943
  end
912
- if ReVIEW.book.param["chapterlink"]
944
+ if @book.config["chapterlink"]
913
945
  anchor = "h"+n.gsub(/\./, "-")
914
- %Q(<a href="#{chap.id}.html\##{anchor}">#{str}</a>)
946
+ %Q(<a href="#{chap.id}#{extname}##{anchor}">#{str}</a>)
915
947
  else
916
948
  str
917
949
  end
918
950
  end
919
951
 
952
+ def column_label(id)
953
+ num = @chapter.column(id).number
954
+ "column-#{num}"
955
+ end
956
+ private :column_label
957
+
958
+ def inline_column(id)
959
+ if @book.config["chapterlink"]
960
+ %Q(<a href="\##{column_label(id)}" class="columnref">#{I18n.t("column", escape_html(@chapter.column(id).caption))}</a>)
961
+ else
962
+ escape_html(@chapter.column(id).caption)
963
+ end
964
+ rescue KeyError
965
+ error "unknown column: #{id}"
966
+ nofunc_text("[UnknownColumn:#{id}]")
967
+ end
968
+
920
969
  def inline_list(id)
921
970
  chapter, id = extract_chapter_id(id)
922
971
  if get_chap(chapter).nil?
@@ -931,10 +980,16 @@ QUOTE
931
980
 
932
981
  def inline_table(id)
933
982
  chapter, id = extract_chapter_id(id)
983
+ str = nil
934
984
  if get_chap(chapter).nil?
935
- "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}"
985
+ str = "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}"
986
+ else
987
+ str = "#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}"
988
+ end
989
+ if @book.config["chapterlink"]
990
+ %Q(<a href="./#{chapter.id}#{extname}##{id}">#{str}</a>)
936
991
  else
937
- "#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}"
992
+ str
938
993
  end
939
994
  rescue KeyError
940
995
  error "unknown table: #{id}"
@@ -943,10 +998,16 @@ QUOTE
943
998
 
944
999
  def inline_img(id)
945
1000
  chapter, id = extract_chapter_id(id)
1001
+ str = nil
946
1002
  if get_chap(chapter).nil?
947
- "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}"
1003
+ str = "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}"
1004
+ else
1005
+ str = "#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}"
1006
+ end
1007
+ if @book.config["chapterlink"]
1008
+ %Q(<a href="./#{chapter.id}#{extname}##{normalize_id(id)}">#{str}</a>)
948
1009
  else
949
- "#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}"
1010
+ str
950
1011
  end
951
1012
  rescue KeyError
952
1013
  error "unknown image: #{id}"
@@ -1010,7 +1071,7 @@ QUOTE
1010
1071
  end
1011
1072
 
1012
1073
  def inline_tt(str)
1013
- if ReVIEW.book.param["htmlversion"].to_i == 5
1074
+ if @book.config["htmlversion"].to_i == 5
1014
1075
  %Q(<code class="tt">#{escape_html(str)}</code>)
1015
1076
  else
1016
1077
  %Q(<tt>#{escape_html(str)}</tt>)
@@ -1046,10 +1107,10 @@ QUOTE
1046
1107
  end
1047
1108
 
1048
1109
  def inline_comment(str)
1049
- if ReVIEW.book.param["draft"]
1110
+ if @book.config["draft"]
1050
1111
  %Q(<span class="draft-comment">#{escape_html(str)}</span>)
1051
1112
  else
1052
- %Q(<!-- #{escape_html(str)} -->)
1113
+ %Q(<!-- #{escape_comment(escape_html(str))} -->)
1053
1114
  end
1054
1115
  end
1055
1116
 
@@ -1066,7 +1127,7 @@ QUOTE
1066
1127
  end
1067
1128
 
1068
1129
  def flushright(lines)
1069
- if ReVIEW.book.param["deprecated-blocklines"].nil?
1130
+ if @book.config["deprecated-blocklines"].nil?
1070
1131
  puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"flushright\">")
1071
1132
  else
1072
1133
  puts %Q[<div style="text-align:right;">]