review 1.0.0 → 1.1.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/.travis.yml +1 -2
- data/ChangeLog +65 -0
- data/Gemfile +5 -0
- data/README.rdoc +6 -1
- data/Rakefile +14 -28
- data/bin/review-check +9 -21
- data/bin/review-compile +45 -12
- data/bin/review-epubmaker +477 -220
- data/bin/review-epubmaker-ng +5 -14
- data/bin/review-index +4 -2
- data/bin/review-init +94 -0
- data/bin/review-pdfmaker +70 -287
- data/bin/review-preproc +5 -2
- data/bin/review-vol +4 -11
- data/debian/changelog +3 -3
- data/debian/copyright +5 -3
- data/debian/docs +1 -0
- data/doc/format.rdoc +57 -11
- data/doc/quickstart.rdoc +4 -4
- data/doc/sample.yaml +11 -7
- data/lib/epubmaker.rb +1 -1
- data/lib/epubmaker/epubv2.rb +26 -27
- data/lib/epubmaker/epubv3.rb +13 -13
- data/lib/epubmaker/producer.rb +1 -1
- data/lib/review.rb +3 -4
- data/lib/review/book.rb +17 -581
- data/lib/review/book/base.rb +247 -0
- data/lib/review/book/chapter.rb +81 -0
- data/lib/review/book/compilable.rb +163 -0
- data/lib/review/book/index.rb +339 -0
- data/lib/review/book/page_metric.rb +38 -0
- data/lib/review/book/parameters.rb +97 -0
- data/lib/review/book/part.rb +44 -0
- data/lib/review/book/volume.rb +65 -0
- data/lib/review/builder.rb +34 -40
- data/lib/review/compiler.rb +32 -13
- data/lib/review/configure.rb +38 -0
- data/lib/review/ewbbuilder.rb +23 -21
- data/lib/review/extentions.rb +3 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/{compat.rb → extentions/string.rb} +11 -0
- data/lib/review/htmlbuilder.rb +162 -74
- data/lib/review/htmlutils.rb +28 -1
- data/lib/review/i18n.yaml +11 -0
- data/lib/review/idgxmlbuilder.rb +119 -35
- data/lib/review/inaobuilder.rb +355 -0
- data/lib/review/latexbuilder.rb +133 -59
- data/lib/review/latexutils.rb +15 -6
- data/lib/review/makerhelper.rb +59 -0
- data/lib/review/markdownbuilder.rb +129 -0
- data/lib/review/preprocessor.rb +20 -7
- data/lib/review/review.tex.erb +250 -0
- data/lib/review/textutils.rb +28 -3
- data/lib/review/tocparser.rb +20 -12
- data/lib/review/tocprinter.rb +7 -3
- data/lib/review/topbuilder.rb +44 -27
- data/lib/review/version.rb +3 -0
- data/review.gemspec +20 -117
- data/test/book_test_helper.rb +35 -0
- data/test/sample-book/README.md +5 -0
- data/test/sample-book/src/CHAPS +2 -0
- data/test/sample-book/src/PREDEF +1 -0
- data/test/sample-book/src/Rakefile +26 -0
- data/test/sample-book/src/_cover.html +3 -0
- data/test/sample-book/src/ch01.re +71 -0
- data/test/sample-book/src/ch02.re +3 -0
- data/test/sample-book/src/config.yml +55 -0
- data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
- data/test/sample-book/src/images/cover.jpg +0 -0
- data/test/sample-book/src/main.css +251 -0
- data/test/sample-book/src/preface.re +15 -0
- data/test/sample-book/src/sty/jumoline.sty +310 -0
- data/test/sample-book/src/sty/samplemacro.sty +21 -0
- data/test/sample-book/src/vendor/jumoline/README +29 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
- data/test/test_book.rb +26 -646
- data/test/test_book_chapter.rb +418 -0
- data/test/test_book_parameter.rb +42 -0
- data/test/test_book_part.rb +53 -0
- data/test/test_builder.rb +17 -10
- data/test/test_compiler.rb +46 -0
- data/test/test_epubmaker.rb +1 -1
- data/test/test_epubmaker_cmd.rb +36 -0
- data/test/test_helper.rb +17 -0
- data/test/test_htmlbuilder.rb +156 -24
- data/test/test_htmlutils.rb +4 -0
- data/test/test_i18n.rb +6 -2
- data/test/test_idgxmlbuilder.rb +33 -11
- data/test/test_inaobuilder.rb +247 -0
- data/test/test_index.rb +31 -0
- data/test/test_latexbuilder.rb +115 -35
- data/test/test_makerhelper.rb +50 -0
- data/test/test_pdfmaker_cmd.rb +36 -0
- data/test/test_preprocessor.rb +7 -7
- data/test/test_topbuilder.rb +6 -7
- data/test/test_uuid.rb +1 -0
- metadata +117 -12
- data/lib/review/index.rb +0 -323
- data/lib/review/volume.rb +0 -66
data/lib/review/ewbbuilder.rb
CHANGED
@@ -29,16 +29,17 @@ module ReVIEW
|
|
29
29
|
puts
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
# Compiler.defsyntax(:emlist, :block, 0..1) {|args|
|
33
|
+
# if args[0] and not args[0] == 'noescape'
|
34
|
+
# raise SyntaxError, "unknown //emlist option: #{args[0]}"
|
35
|
+
# end
|
36
|
+
# }
|
37
37
|
|
38
|
-
def emlist(lines,
|
38
|
+
def emlist(lines, caption = nil)
|
39
39
|
firstline = f.lineno
|
40
40
|
puts
|
41
|
-
puts
|
41
|
+
puts caption
|
42
|
+
puts "//lst1"
|
42
43
|
lines.each do |line|
|
43
44
|
if noescape
|
44
45
|
puts detab(line)
|
@@ -50,15 +51,16 @@ module ReVIEW
|
|
50
51
|
puts
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
# Compiler.defsyntax(:cmd, :block, 0..1) {|args|
|
55
|
+
# if args[0] and not args[0] == 'noescape'
|
56
|
+
# raise SyntaxError, "unknown //cmd option: #{args[0]}"
|
57
|
+
# end
|
58
|
+
# }
|
58
59
|
|
59
|
-
def cmd(lines,
|
60
|
+
def cmd(lines, caption = nil)
|
60
61
|
puts
|
61
|
-
puts
|
62
|
+
puts caption
|
63
|
+
puts "//sc1{"
|
62
64
|
lines.each do |line|
|
63
65
|
if noescape
|
64
66
|
puts detab(line)
|
@@ -73,15 +75,15 @@ module ReVIEW
|
|
73
75
|
puts
|
74
76
|
end
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
# Compiler.defsyntax(:list, :block, 0..1) {|args|
|
79
|
+
# if args[0] and not args[0] == 'noescape'
|
80
|
+
# raise SyntaxError, "unknown //list option: #{args[0]}"
|
81
|
+
# end
|
82
|
+
# }
|
81
83
|
|
82
|
-
def list(lines,
|
84
|
+
def list(lines, id, caption)
|
83
85
|
puts
|
84
|
-
puts "//l#{list_number(
|
86
|
+
puts "//l#{list_number(id)} " + caption
|
85
87
|
puts '//lst2{'
|
86
88
|
lines.each do |line|
|
87
89
|
puts escape(detab(line))
|
@@ -1,3 +1,7 @@
|
|
1
|
+
if defined?(Encoding) && Encoding.respond_to?("default_external")
|
2
|
+
Encoding.default_external = "UTF-8"
|
3
|
+
end
|
4
|
+
|
1
5
|
unless String.method_defined?(:lines)
|
2
6
|
# Ruby 1.8
|
3
7
|
class String
|
@@ -20,3 +24,10 @@ else
|
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
27
|
+
|
28
|
+
unless String.method_defined?(:each)
|
29
|
+
# Ruby 1.9
|
30
|
+
class String
|
31
|
+
alias each each_line
|
32
|
+
end
|
33
|
+
end
|
data/lib/review/htmlbuilder.rb
CHANGED
@@ -21,6 +21,7 @@ module ReVIEW
|
|
21
21
|
include TextUtils
|
22
22
|
include HTMLUtils
|
23
23
|
|
24
|
+
[:ref].each {|e| Compiler.definline(e) }
|
24
25
|
Compiler.defblock(:memo, 0..1)
|
25
26
|
Compiler.defblock(:tip, 0..1)
|
26
27
|
Compiler.defblock(:info, 0..1)
|
@@ -50,7 +51,9 @@ module ReVIEW
|
|
50
51
|
@subsection = 0
|
51
52
|
@subsubsection = 0
|
52
53
|
@subsubsubsection = 0
|
54
|
+
@column = 0
|
53
55
|
@noindent = nil
|
56
|
+
@ol_num = nil
|
54
57
|
end
|
55
58
|
private :builder_init
|
56
59
|
|
@@ -68,25 +71,26 @@ module ReVIEW
|
|
68
71
|
else
|
69
72
|
# default XHTML header/footer
|
70
73
|
header = <<EOT
|
71
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
74
|
+
<?xml version="1.0" encoding="#{ReVIEW.book.param["outencoding"] || :UTF-8}"?>
|
72
75
|
EOT
|
73
76
|
|
74
77
|
if ReVIEW.book.param["htmlversion"] == 5
|
75
78
|
header += <<EOT
|
76
79
|
<!DOCTYPE html>
|
80
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{ReVIEW.book.param["language"]}">
|
81
|
+
<head>
|
82
|
+
<meta charset="#{ReVIEW.book.param["outencoding"] || :UTF-8}" />
|
77
83
|
EOT
|
78
84
|
else
|
79
85
|
header += <<EOT
|
80
86
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
81
|
-
EOT
|
82
|
-
end
|
83
|
-
|
84
|
-
header += <<EOT
|
85
87
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{ReVIEW.book.param["language"]}">
|
86
88
|
<head>
|
87
|
-
<meta http-equiv="Content-Type" content="text/html;charset
|
89
|
+
<meta http-equiv="Content-Type" content="text/html;charset=#{ReVIEW.book.param["outencoding"] || :UTF-8}" />
|
88
90
|
<meta http-equiv="Content-Style-Type" content="text/css" />
|
89
91
|
EOT
|
92
|
+
end
|
93
|
+
|
90
94
|
unless ReVIEW.book.param["stylesheet"].nil?
|
91
95
|
ReVIEW.book.param["stylesheet"].each do |style|
|
92
96
|
header += <<EOT
|
@@ -96,7 +100,7 @@ EOT
|
|
96
100
|
end
|
97
101
|
header += <<EOT
|
98
102
|
<meta name="generator" content="ReVIEW" />
|
99
|
-
<title>#{convert_outencoding(@chapter.title)}</title>
|
103
|
+
<title>#{convert_outencoding(strip_html(compile_inline(@chapter.title)), ReVIEW.book.param["outencoding"])}</title>
|
100
104
|
</head>
|
101
105
|
<body>
|
102
106
|
EOT
|
@@ -104,7 +108,7 @@ EOT
|
|
104
108
|
</body>
|
105
109
|
</html>
|
106
110
|
EOT
|
107
|
-
header + messages() + @output.string + footer
|
111
|
+
header + messages() + convert_outencoding(@output.string, ReVIEW.book.param["outencoding"]) + footer
|
108
112
|
end
|
109
113
|
end
|
110
114
|
|
@@ -160,10 +164,17 @@ EOT
|
|
160
164
|
@subsubsubsection = 0
|
161
165
|
anchor = "#{@chapter.number}"
|
162
166
|
if ReVIEW.book.param["secnolevel"] >= 1
|
163
|
-
if @chapter.number.
|
164
|
-
prefix = "
|
165
|
-
|
166
|
-
|
167
|
+
if @chapter.number.blank?
|
168
|
+
prefix = ""
|
169
|
+
else
|
170
|
+
placeholder = if @chapter.is_a? ReVIEW::Book::Part
|
171
|
+
'part'
|
172
|
+
elsif @chapter.on_POSTDEF?
|
173
|
+
'appendix'
|
174
|
+
else
|
175
|
+
'chapter'
|
176
|
+
end
|
177
|
+
prefix = "#{I18n.t(placeholder, @chapter.number)}#{I18n.t("chapter_postfix")}"
|
167
178
|
end
|
168
179
|
end
|
169
180
|
when 2
|
@@ -173,10 +184,10 @@ EOT
|
|
173
184
|
@subsubsubsection = 0
|
174
185
|
anchor = "#{@chapter.number}-#{@section}"
|
175
186
|
if ReVIEW.book.param["secnolevel"] >= 2
|
176
|
-
if @chapter.number.
|
177
|
-
prefix = "
|
178
|
-
|
179
|
-
prefix = "#{@chapter.number}.#{@section}
|
187
|
+
if @chapter.number.blank? or @chapter.on_POSTDEF?
|
188
|
+
prefix = ""
|
189
|
+
else
|
190
|
+
prefix = "#{@chapter.number}.#{@section}#{I18n.t("chapter_postfix")}"
|
180
191
|
end
|
181
192
|
end
|
182
193
|
when 3
|
@@ -185,10 +196,10 @@ EOT
|
|
185
196
|
@subsubsubsection = 0
|
186
197
|
anchor = "#{@chapter.number}-#{@section}-#{@subsection}"
|
187
198
|
if ReVIEW.book.param["secnolevel"] >= 3
|
188
|
-
if @chapter.number.
|
189
|
-
prefix = "
|
190
|
-
|
191
|
-
prefix = "#{@chapter.number}.#{@section}.#{@subsection}
|
199
|
+
if @chapter.number.blank? or @chapter.on_POSTDEF?
|
200
|
+
prefix = ""
|
201
|
+
else
|
202
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}#{I18n.t("chapter_postfix")}"
|
192
203
|
end
|
193
204
|
end
|
194
205
|
when 4
|
@@ -196,20 +207,20 @@ EOT
|
|
196
207
|
@subsubsubsection = 0
|
197
208
|
anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}"
|
198
209
|
if ReVIEW.book.param["secnolevel"] >= 4
|
199
|
-
if @chapter.number.
|
200
|
-
prefix = "
|
201
|
-
|
202
|
-
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}
|
210
|
+
if @chapter.number.blank? or @chapter.on_POSTDEF?
|
211
|
+
prefix = ""
|
212
|
+
else
|
213
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}#{I18n.t("chapter_postfix")}"
|
203
214
|
end
|
204
215
|
end
|
205
216
|
when 5
|
206
217
|
@subsubsubsection += 1
|
207
218
|
anchor = "#{@chapter.number}-#{@section}-#{@subsection}-#{@subsubsection}-#{@subsubsubsection}"
|
208
219
|
if ReVIEW.book.param["secnolevel"] >= 5
|
209
|
-
if @chapter.number.
|
210
|
-
prefix = "
|
211
|
-
|
212
|
-
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}
|
220
|
+
if @chapter.number.blank? or @chapter.on_POSTDEF?
|
221
|
+
prefix = ""
|
222
|
+
else
|
223
|
+
prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}#{I18n.t("chapter_postfix")}"
|
213
224
|
end
|
214
225
|
end
|
215
226
|
end
|
@@ -222,7 +233,7 @@ EOT
|
|
222
233
|
puts '' if level > 1
|
223
234
|
a_id = ""
|
224
235
|
unless anchor.nil?
|
225
|
-
a_id = %Q[<a id="h#{anchor}"
|
236
|
+
a_id = %Q[<a id="h#{anchor}"></a>]
|
226
237
|
end
|
227
238
|
if caption.empty?
|
228
239
|
puts a_id unless label.nil?
|
@@ -251,7 +262,21 @@ EOT
|
|
251
262
|
|
252
263
|
def column_begin(level, label, caption)
|
253
264
|
puts %Q[<div class="column">]
|
254
|
-
|
265
|
+
|
266
|
+
@column += 1
|
267
|
+
puts '' if level > 1
|
268
|
+
a_id = %Q[<a id="column-#{@column}"></a>]
|
269
|
+
|
270
|
+
if caption.empty?
|
271
|
+
puts a_id unless label.nil?
|
272
|
+
else
|
273
|
+
if label.nil?
|
274
|
+
puts %Q[<h#{level}>#{a_id}#{compile_inline(caption)}</h#{level}>]
|
275
|
+
else
|
276
|
+
puts %Q[<h#{level} id="#{label}">#{a_id}#{compile_inline(caption)}</h#{level}>]
|
277
|
+
end
|
278
|
+
end
|
279
|
+
# headline(level, label, caption)
|
255
280
|
end
|
256
281
|
|
257
282
|
def column_end(level)
|
@@ -381,7 +406,12 @@ EOT
|
|
381
406
|
end
|
382
407
|
|
383
408
|
def ol_begin
|
384
|
-
|
409
|
+
if @ol_num
|
410
|
+
puts "<ol start=\"#{@ol_num}\">" ## it's OK in HTML5, but not OK in XHTML1.1
|
411
|
+
@ol_num = nil
|
412
|
+
else
|
413
|
+
puts '<ol>'
|
414
|
+
end
|
385
415
|
end
|
386
416
|
|
387
417
|
def ol_item(lines, num)
|
@@ -439,42 +469,46 @@ EOT
|
|
439
469
|
rescue KeyError
|
440
470
|
error "no such list: #{id}"
|
441
471
|
end
|
442
|
-
list_body lines
|
472
|
+
list_body id, lines
|
443
473
|
puts '</div>'
|
444
474
|
end
|
445
475
|
|
446
476
|
def list_header(id, caption)
|
447
477
|
if get_chap.nil?
|
448
|
-
puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header_without_chapter", [@chapter.list(id).number])}
|
478
|
+
puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
|
449
479
|
else
|
450
|
-
puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header", [get_chap, @chapter.list(id).number])}
|
480
|
+
puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
|
451
481
|
end
|
452
482
|
end
|
453
483
|
|
454
|
-
def list_body(lines)
|
484
|
+
def list_body(id, lines)
|
485
|
+
id ||= ''
|
455
486
|
print %Q[<pre class="list">]
|
456
|
-
lines.
|
457
|
-
|
458
|
-
|
487
|
+
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
488
|
+
lexer = File.extname(id).gsub(/\./, '')
|
489
|
+
puts highlight(:body => body, :lexer => lexer, :format => 'html')
|
459
490
|
puts '</pre>'
|
460
491
|
end
|
461
492
|
|
462
|
-
def source(lines, caption)
|
493
|
+
def source(lines, caption = nil)
|
463
494
|
puts %Q[<div class="source-code">]
|
464
495
|
source_header caption
|
465
|
-
source_body lines
|
496
|
+
source_body caption, lines
|
466
497
|
puts '</div>'
|
467
498
|
end
|
468
499
|
|
469
500
|
def source_header(caption)
|
470
|
-
|
501
|
+
if caption.present?
|
502
|
+
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
|
503
|
+
end
|
471
504
|
end
|
472
505
|
|
473
|
-
def source_body(lines)
|
506
|
+
def source_body(id, lines)
|
507
|
+
id ||= ''
|
474
508
|
print %Q[<pre class="source">]
|
475
|
-
lines.
|
476
|
-
|
477
|
-
|
509
|
+
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
|
510
|
+
lexer = File.extname(id).gsub(/\./, '')
|
511
|
+
puts highlight(:body => body, :lexer => lexer, :format => 'html')
|
478
512
|
puts '</pre>'
|
479
513
|
end
|
480
514
|
|
@@ -495,7 +529,7 @@ EOT
|
|
495
529
|
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
496
530
|
end
|
497
531
|
puts '</pre>'
|
498
|
-
|
532
|
+
end
|
499
533
|
|
500
534
|
def emlist(lines, caption = nil)
|
501
535
|
puts %Q[<div class="emlist-code">]
|
@@ -626,9 +660,9 @@ QUOTE
|
|
626
660
|
def image_header(id, caption)
|
627
661
|
puts %Q[<p class="caption">]
|
628
662
|
if get_chap.nil?
|
629
|
-
puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header_without_chapter", [@chapter.image(id).number])}
|
663
|
+
puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
|
630
664
|
else
|
631
|
-
puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header", [get_chap, @chapter.image(id).number])}
|
665
|
+
puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
|
632
666
|
end
|
633
667
|
puts %Q[</p>]
|
634
668
|
end
|
@@ -674,9 +708,9 @@ QUOTE
|
|
674
708
|
|
675
709
|
def table_header(id, caption)
|
676
710
|
if get_chap.nil?
|
677
|
-
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("
|
711
|
+
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
|
678
712
|
else
|
679
|
-
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}
|
713
|
+
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
|
680
714
|
end
|
681
715
|
end
|
682
716
|
|
@@ -700,16 +734,20 @@ QUOTE
|
|
700
734
|
puts '</table>'
|
701
735
|
end
|
702
736
|
|
703
|
-
def comment(
|
737
|
+
def comment(lines, comment = nil)
|
738
|
+
lines ||= []
|
739
|
+
lines.unshift comment unless comment.blank?
|
704
740
|
if ReVIEW.book.param["draft"]
|
705
|
-
|
741
|
+
str = lines.map{|line| escape_html(line) }.join("<br />")
|
742
|
+
puts %Q(<div class="draft-comment">#{str}</div>)
|
706
743
|
else
|
744
|
+
str = lines.join("\n")
|
707
745
|
puts %Q(<!-- #{escape_html(str)} -->)
|
708
746
|
end
|
709
747
|
end
|
710
748
|
|
711
749
|
def footnote(id, str)
|
712
|
-
puts %Q(<div class="footnote"><p class="footnote"
|
750
|
+
puts %Q(<div class="footnote"><p class="footnote">[<a id="fn-#{id}">*#{@chapter.footnote(id).number}</a>] #{compile_inline(str)}</p></div>)
|
713
751
|
end
|
714
752
|
|
715
753
|
def indepimage(id, caption="", metric=nil)
|
@@ -717,14 +755,14 @@ QUOTE
|
|
717
755
|
caption = "" if caption.nil?
|
718
756
|
puts %Q[<div class="image">]
|
719
757
|
begin
|
720
|
-
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{caption}"#{metrics} />]
|
758
|
+
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
|
721
759
|
rescue
|
722
760
|
puts %Q[<pre>missing image: #{id}</pre>]
|
723
761
|
end
|
724
762
|
|
725
763
|
unless caption.empty?
|
726
764
|
puts %Q[<p class="caption">]
|
727
|
-
puts %Q[#{I18n.t("numberless_image")}
|
765
|
+
puts %Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
|
728
766
|
puts %Q[</p>]
|
729
767
|
end
|
730
768
|
puts %Q[</div>]
|
@@ -737,7 +775,7 @@ QUOTE
|
|
737
775
|
end
|
738
776
|
|
739
777
|
def label(id)
|
740
|
-
puts %Q(<a id="#{id}"
|
778
|
+
puts %Q(<a id="#{id}"></a>)
|
741
779
|
end
|
742
780
|
|
743
781
|
def linebreak
|
@@ -760,6 +798,12 @@ QUOTE
|
|
760
798
|
@noindent = true
|
761
799
|
end
|
762
800
|
|
801
|
+
def inline_labelref(idref)
|
802
|
+
%Q[<a target='#{escape_html(idref)}'>「●● #{escape_html(idref)}」</a>]
|
803
|
+
end
|
804
|
+
|
805
|
+
alias inline_ref inline_labelref
|
806
|
+
|
763
807
|
def inline_chapref(id)
|
764
808
|
if ReVIEW.book.param["chapterlink"]
|
765
809
|
%Q(<a href="./#{id}.html">#{@chapter.env.chapter_index.display_string(id)}</a>)
|
@@ -784,7 +828,7 @@ QUOTE
|
|
784
828
|
|
785
829
|
def inline_title(id)
|
786
830
|
if ReVIEW.book.param["chapterlink"]
|
787
|
-
%Q(<a href="./#{id}.html">#{@chapter.env.chapter_index.title(id)}</a>)
|
831
|
+
%Q(<a href="./#{id}.html">#{compile_inline(@chapter.env.chapter_index.title(id))}</a>)
|
788
832
|
else
|
789
833
|
@chapter.env.chapter_index.title(id)
|
790
834
|
end
|
@@ -799,7 +843,11 @@ QUOTE
|
|
799
843
|
end
|
800
844
|
|
801
845
|
def compile_ruby(base, ruby)
|
802
|
-
|
846
|
+
if ReVIEW.book.param["htmlversion"] == 5
|
847
|
+
%Q[<ruby>#{escape_html(base)}<rp>#{I18n.t("ruby_prefix")}</rp><rt>#{ruby}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
|
848
|
+
else
|
849
|
+
%Q[<ruby><rb>#{escape_html(base)}</rb><rp>#{I18n.t("ruby_prefix")}</rp><rt>#{ruby}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
|
850
|
+
end
|
803
851
|
end
|
804
852
|
|
805
853
|
def compile_kw(word, alt)
|
@@ -823,12 +871,24 @@ QUOTE
|
|
823
871
|
%Q(<span class="ami">#{escape_html(str)}</span>)
|
824
872
|
end
|
825
873
|
|
874
|
+
def inline_bou(str)
|
875
|
+
%Q(<span class="bou">#{escape_html(str)}</span>)
|
876
|
+
end
|
877
|
+
|
826
878
|
def inline_tti(str)
|
827
|
-
|
879
|
+
if ReVIEW.book.param["htmlversion"] == 5
|
880
|
+
%Q(<code class="tt"><i>#{escape_html(str)}</i></code>)
|
881
|
+
else
|
882
|
+
%Q(<tt><i>#{escape_html(str)}</i></tt>)
|
883
|
+
end
|
828
884
|
end
|
829
885
|
|
830
886
|
def inline_ttb(str)
|
831
|
-
|
887
|
+
if ReVIEW.book.param["htmlversion"] == 5
|
888
|
+
%Q(<code class="tt"><b>#{escape_html(str)}</b></code>)
|
889
|
+
else
|
890
|
+
%Q(<tt><b>#{escape_html(str)}</b></tt>)
|
891
|
+
end
|
832
892
|
end
|
833
893
|
|
834
894
|
def inline_dtp(str)
|
@@ -836,7 +896,11 @@ QUOTE
|
|
836
896
|
end
|
837
897
|
|
838
898
|
def inline_code(str)
|
839
|
-
|
899
|
+
if ReVIEW.book.param["htmlversion"] == 5
|
900
|
+
%Q(<code class="inline-code tt">#{escape_html(str)}</code>)
|
901
|
+
else
|
902
|
+
%Q(<tt class="inline-code">#{escape_html(str)}</tt>)
|
903
|
+
end
|
840
904
|
end
|
841
905
|
|
842
906
|
def inline_idx(str)
|
@@ -865,7 +929,7 @@ QUOTE
|
|
865
929
|
end
|
866
930
|
|
867
931
|
def bibpaper(lines, id, caption)
|
868
|
-
puts
|
932
|
+
puts %Q[<div class="bibpaper">]
|
869
933
|
bibpaper_header id, caption
|
870
934
|
unless lines.empty?
|
871
935
|
bibpaper_bibpaper id, caption, lines
|
@@ -874,17 +938,14 @@ QUOTE
|
|
874
938
|
end
|
875
939
|
|
876
940
|
def bibpaper_header(id, caption)
|
877
|
-
|
878
|
-
|
879
|
-
|
941
|
+
print %Q(<a id="bib-#{id}">)
|
942
|
+
print "[#{@chapter.bibpaper(id).number}]"
|
943
|
+
print %Q(</a>)
|
944
|
+
puts " #{compile_inline(caption)}"
|
880
945
|
end
|
881
946
|
|
882
947
|
def bibpaper_bibpaper(id, caption, lines)
|
883
|
-
|
884
|
-
lines.each do |line|
|
885
|
-
puts detab(line)
|
886
|
-
end
|
887
|
-
puts %Q(</p>)
|
948
|
+
print split_paragraph(lines).join("")
|
888
949
|
end
|
889
950
|
|
890
951
|
def inline_bib(id)
|
@@ -892,7 +953,18 @@ QUOTE
|
|
892
953
|
end
|
893
954
|
|
894
955
|
def inline_hd_chap(chap, id)
|
895
|
-
|
956
|
+
n = chap.headline_index.number(id)
|
957
|
+
if chap.number and ReVIEW.book.param["secnolevel"] >= n.split('.').size
|
958
|
+
str = "「#{n} #{compile_inline(chap.headline(id).caption)}」"
|
959
|
+
else
|
960
|
+
str = "「#{compile_inline(chap.headline(id).caption)}」"
|
961
|
+
end
|
962
|
+
if ReVIEW.book.param["chapterlink"]
|
963
|
+
anchor = "h"+n.gsub(/\./, "-")
|
964
|
+
%Q(<a href="#{chap.id}.html\##{anchor}">#{str}</a>)
|
965
|
+
else
|
966
|
+
str
|
967
|
+
end
|
896
968
|
end
|
897
969
|
|
898
970
|
def inline_list(id)
|
@@ -988,7 +1060,11 @@ QUOTE
|
|
988
1060
|
end
|
989
1061
|
|
990
1062
|
def inline_tt(str)
|
991
|
-
|
1063
|
+
if ReVIEW.book.param["htmlversion"] == 5
|
1064
|
+
%Q(<code class="tt">#{escape_html(str)}</code>)
|
1065
|
+
else
|
1066
|
+
%Q(<tt>#{escape_html(str)}</tt>)
|
1067
|
+
end
|
992
1068
|
end
|
993
1069
|
|
994
1070
|
def inline_del(str)
|
@@ -1003,12 +1079,16 @@ QUOTE
|
|
1003
1079
|
%Q(<u>#{escape_html(str)}</u>)
|
1004
1080
|
end
|
1005
1081
|
|
1006
|
-
|
1082
|
+
def inline_recipe(str)
|
1007
1083
|
%Q(<span class="recipe">「#{escape_html(str)}」</span>)
|
1008
1084
|
end
|
1009
1085
|
|
1010
1086
|
def inline_icon(id)
|
1011
|
-
|
1087
|
+
begin
|
1088
|
+
%Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="[#{id}]" />]
|
1089
|
+
rescue
|
1090
|
+
%Q[<pre>missing image: #{id}</pre>]
|
1091
|
+
end
|
1012
1092
|
end
|
1013
1093
|
|
1014
1094
|
def inline_uchar(str)
|
@@ -1047,9 +1127,17 @@ QUOTE
|
|
1047
1127
|
end
|
1048
1128
|
end
|
1049
1129
|
|
1130
|
+
def centering(lines)
|
1131
|
+
puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"center\">")
|
1132
|
+
end
|
1133
|
+
|
1050
1134
|
def image_ext
|
1051
1135
|
"png"
|
1052
1136
|
end
|
1137
|
+
|
1138
|
+
def olnum(num)
|
1139
|
+
@ol_num = num.to_i
|
1140
|
+
end
|
1053
1141
|
end
|
1054
1142
|
|
1055
1143
|
end # module ReVIEW
|