review 0.6.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/COPYING +515 -0
- data/ChangeLog +1278 -0
- data/README.rdoc +21 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/bin/review-check +190 -0
- data/bin/review-checkdep +63 -0
- data/bin/review-compile +165 -0
- data/bin/review-epubmaker +525 -0
- data/bin/review-index +108 -0
- data/bin/review-preproc +140 -0
- data/bin/review-validate +51 -0
- data/bin/review-vol +106 -0
- data/doc/format.re +486 -0
- data/doc/format.txt +434 -0
- data/doc/format_idg.txt +194 -0
- data/doc/format_sjis.txt +313 -0
- data/doc/sample.css +91 -0
- data/doc/sample.yaml +46 -0
- data/lib/lineinput.rb +155 -0
- data/lib/review/book.rb +580 -0
- data/lib/review/builder.rb +274 -0
- data/lib/review/compat.rb +22 -0
- data/lib/review/compiler.rb +483 -0
- data/lib/review/epubbuilder.rb +692 -0
- data/lib/review/ewbbuilder.rb +382 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/htmlbuilder.rb +370 -0
- data/lib/review/htmllayout.rb +19 -0
- data/lib/review/htmlutils.rb +27 -0
- data/lib/review/idgxmlbuilder.rb +1078 -0
- data/lib/review/index.rb +224 -0
- data/lib/review/latexbuilder.rb +420 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +52 -0
- data/lib/review/preprocessor.rb +520 -0
- data/lib/review/textutils.rb +19 -0
- data/lib/review/tocparser.rb +333 -0
- data/lib/review/tocprinter.rb +220 -0
- data/lib/review/topbuilder.rb +572 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/review/volume.rb +66 -0
- data/lib/review.rb +4 -0
- data/review.gemspec +93 -0
- data/setup.rb +1587 -0
- data/test/test_epubbuilder.rb +73 -0
- data/test/test_helper.rb +2 -0
- data/test/test_htmlbuilder.rb +42 -0
- data/test/test_latexbuilder.rb +74 -0
- metadata +122 -0
@@ -0,0 +1,382 @@
|
|
1
|
+
# $Id: ewbbuilder.rb 2195 2005-11-13 21:52:18Z aamine $
|
2
|
+
|
3
|
+
require 'review/builder'
|
4
|
+
require 'review/textutils'
|
5
|
+
require 'review/exception'
|
6
|
+
|
7
|
+
module ReVIEW
|
8
|
+
|
9
|
+
class EWBBuilder < Builder
|
10
|
+
|
11
|
+
include TextUtils
|
12
|
+
|
13
|
+
def initialize(chap)
|
14
|
+
super
|
15
|
+
@footnote_buf = []
|
16
|
+
@index_buffer = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_index
|
20
|
+
@index_buffer.each_with_index do |str, n|
|
21
|
+
printf "%d\t%s\n", index_number(n + 1), str
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def headline(level, caption)
|
26
|
+
puts unless level == 1
|
27
|
+
puts "//#{'i' * level} #{caption}"
|
28
|
+
puts
|
29
|
+
end
|
30
|
+
|
31
|
+
Compiler.defsyntax(:emlist, :block, 0..1) {|args|
|
32
|
+
if args[0] and not args[0] == 'noescape'
|
33
|
+
raise SyntaxError, "unknown //emlist option: #{args[0]}"
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
37
|
+
def emlist(lines, noescape = false)
|
38
|
+
firstline = f.lineno
|
39
|
+
puts
|
40
|
+
puts '//lst1{'
|
41
|
+
lines.each do |line|
|
42
|
+
if noescape
|
43
|
+
puts detab(line)
|
44
|
+
else
|
45
|
+
puts escape(detab(line))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
puts '//}'
|
49
|
+
puts
|
50
|
+
end
|
51
|
+
|
52
|
+
Compiler.defsyntax(:cmd, :block, 0..1) {|args|
|
53
|
+
if args[0] and not args[0] == 'noescape'
|
54
|
+
raise SyntaxError, "unknown //cmd option: #{args[0]}"
|
55
|
+
end
|
56
|
+
}
|
57
|
+
|
58
|
+
def cmd(lines, noescape = false)
|
59
|
+
puts
|
60
|
+
puts '//sc1{'
|
61
|
+
lines.each do |line|
|
62
|
+
if noescape
|
63
|
+
puts detab(line)
|
64
|
+
elsif /\AC:.*?>(.+)/ =~ line # DOS prompt hack
|
65
|
+
prompt, cmd = *line.split('>', 2)
|
66
|
+
puts "#{escape(prompt)}>//command{#{escape(cmd)}}//}"
|
67
|
+
else
|
68
|
+
puts escape(detab(line))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
puts '//}'
|
72
|
+
puts
|
73
|
+
end
|
74
|
+
|
75
|
+
Compiler.defsyntax(:list, :block, 0..1) {|args|
|
76
|
+
if args[0] and not args[0] == 'noescape'
|
77
|
+
raise SyntaxError, "unknown //list option: #{args[0]}"
|
78
|
+
end
|
79
|
+
}
|
80
|
+
|
81
|
+
def list(lines, noescape = false)
|
82
|
+
puts
|
83
|
+
puts "//l#{list_number(ident)} " + caption
|
84
|
+
puts '//lst2{'
|
85
|
+
lines.each do |line|
|
86
|
+
puts escape(detab(line))
|
87
|
+
end
|
88
|
+
puts '//}'
|
89
|
+
puts
|
90
|
+
end
|
91
|
+
|
92
|
+
def image_header(file, caption)
|
93
|
+
if /\.png\z/ =~ file and not FileTest.exist?('images/' + file)
|
94
|
+
warn "image file not exist: #{file}"
|
95
|
+
end
|
96
|
+
id = file.sub(/\.\w+\z/, '')
|
97
|
+
puts "//f#{figure_number(id)} #{text(caption)} file=#{file}" if id
|
98
|
+
end
|
99
|
+
|
100
|
+
def image_dummy
|
101
|
+
puts '//lst1{'
|
102
|
+
puts '---- dummy figure ----'
|
103
|
+
print dummy
|
104
|
+
puts '//}'
|
105
|
+
puts
|
106
|
+
end
|
107
|
+
|
108
|
+
def table
|
109
|
+
# %r<\A//table\[(\w+)\]>
|
110
|
+
spec = $1
|
111
|
+
buf = []
|
112
|
+
while line = f.gets
|
113
|
+
break if %r[\A//\}] === line
|
114
|
+
buf.push line.strip.split(/\t+/).map {|s| s == '.' ? '' : s }
|
115
|
+
end
|
116
|
+
table_type = 'tabm'
|
117
|
+
output.puts "//#{table_type}[" + spec + ']{'
|
118
|
+
buf.each_with_index do |col, idx|
|
119
|
+
if /----/ === col[0]
|
120
|
+
output.puts '//kb'
|
121
|
+
else
|
122
|
+
output.puts col.map {|s| text(s) }.join("\t")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
output.puts '//}'
|
126
|
+
end
|
127
|
+
|
128
|
+
LI = '��'
|
129
|
+
|
130
|
+
def ul_begin
|
131
|
+
puts
|
132
|
+
puts '//k1{'
|
133
|
+
end
|
134
|
+
|
135
|
+
def ul_item(lines)
|
136
|
+
puts "#{LI}//|" + lines.join('')
|
137
|
+
end
|
138
|
+
|
139
|
+
def ul_end
|
140
|
+
puts '//}'
|
141
|
+
end
|
142
|
+
|
143
|
+
def ol_begin
|
144
|
+
output.puts
|
145
|
+
output.puts '//k2{'
|
146
|
+
end
|
147
|
+
|
148
|
+
def ol_item(num, lines)
|
149
|
+
print "#{num}//|' + lines.join('')
|
150
|
+
end
|
151
|
+
|
152
|
+
def ol_end
|
153
|
+
puts '//}'
|
154
|
+
end
|
155
|
+
|
156
|
+
def quote(lines)
|
157
|
+
puts '//c1{'
|
158
|
+
lines.each do |line|
|
159
|
+
puts text(line)
|
160
|
+
end
|
161
|
+
puts '//}'
|
162
|
+
end
|
163
|
+
|
164
|
+
def vspace
|
165
|
+
print "\n//h"
|
166
|
+
end
|
167
|
+
|
168
|
+
def noindent
|
169
|
+
@noindent = true
|
170
|
+
end
|
171
|
+
|
172
|
+
def refer(f)
|
173
|
+
puts
|
174
|
+
puts '//refer{'
|
175
|
+
cascade f
|
176
|
+
puts '//}'
|
177
|
+
end
|
178
|
+
|
179
|
+
def point(f)
|
180
|
+
puts
|
181
|
+
puts '//point{'
|
182
|
+
cascade f
|
183
|
+
puts '//}'
|
184
|
+
end
|
185
|
+
|
186
|
+
def note(f, caption)
|
187
|
+
puts
|
188
|
+
puts '//note{'
|
189
|
+
puts "//cg{#{caption}//}"
|
190
|
+
puts '//h'
|
191
|
+
cascade f
|
192
|
+
puts '//}'
|
193
|
+
end
|
194
|
+
|
195
|
+
def cascade(f)
|
196
|
+
# FIXME
|
197
|
+
end
|
198
|
+
|
199
|
+
Z_SPACE = "\241\241" # zen-kaku space in EUC-JP
|
200
|
+
|
201
|
+
def paragraph(lines)
|
202
|
+
if @noindent
|
203
|
+
@noindent = false
|
204
|
+
else
|
205
|
+
print Z_SPACE
|
206
|
+
end
|
207
|
+
prev = ''
|
208
|
+
lines.each do |line|
|
209
|
+
if /[a-zA-Z0-9]\z/ =~ prev and /\A[a-zA-Z0-9]/ =~ line
|
210
|
+
print ' '
|
211
|
+
end
|
212
|
+
print line
|
213
|
+
end
|
214
|
+
puts
|
215
|
+
end
|
216
|
+
|
217
|
+
def figure_filename(key)
|
218
|
+
if ext = key.slice(/\.\w+\z/)
|
219
|
+
base = key.sub(/\.\w+\z/, '')
|
220
|
+
else
|
221
|
+
base = key
|
222
|
+
ext = '.eps'
|
223
|
+
end
|
224
|
+
currname = "images/ch_#{chapter_id()}_#{base}#{ext}"
|
225
|
+
destname = "images/fig#{figure_number(base)}#{ext}"
|
226
|
+
unless File.exist? currname
|
227
|
+
# error "image file not exist: #{currname}"
|
228
|
+
end
|
229
|
+
destname
|
230
|
+
end
|
231
|
+
|
232
|
+
def image_label(str)
|
233
|
+
"#{chapter_id()}:#{str}"
|
234
|
+
end
|
235
|
+
|
236
|
+
def text(str)
|
237
|
+
str = str.gsub(/\t/, ' ')
|
238
|
+
str.gsub(/([^@^]+)|\^(.*?)\^|@<(\w+)>\{(.*?)\}|@\{(.*?)\}|([@^])/) {
|
239
|
+
if normal = $1
|
240
|
+
escape(normal)
|
241
|
+
elsif tt = $2
|
242
|
+
'//tt{' + escape(tt) + '//}'
|
243
|
+
elsif inline = $3
|
244
|
+
compile_inline(inline, $4)
|
245
|
+
elsif index = $5
|
246
|
+
error 'index not implemented'
|
247
|
+
text(index) + index_command(index)
|
248
|
+
elsif char = $6
|
249
|
+
escape(char)
|
250
|
+
else
|
251
|
+
error "unknown inline: #{str.inspect}"
|
252
|
+
end
|
253
|
+
}
|
254
|
+
rescue DocumentError => e
|
255
|
+
error e.message
|
256
|
+
return 'ERROR'
|
257
|
+
end
|
258
|
+
|
259
|
+
def inline_kw(arg)
|
260
|
+
word, eng, abbr = arg.split(/,/).map {|s| s.strip }
|
261
|
+
if abbr
|
262
|
+
add_index(word) + "//g{#{word}//}" +
|
263
|
+
add_index(abbr) + "��#{abbr}, " +
|
264
|
+
add_index(eng) + "#{eng}��"
|
265
|
+
elsif eng
|
266
|
+
add_index(word) + "//g{#{word}//}" +
|
267
|
+
add_index(eng) + "��#{eng}��"
|
268
|
+
else
|
269
|
+
add_index(word) + "//g{#{word}//}"
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def inline_keytop(arg)
|
274
|
+
"//keytop{#{arg}//}"
|
275
|
+
end
|
276
|
+
|
277
|
+
def inline_chap(id)
|
278
|
+
chapter_number(arg)
|
279
|
+
end
|
280
|
+
|
281
|
+
def inline_chapref(id)
|
282
|
+
chapter_number(arg) + chapter_name(arg)
|
283
|
+
end
|
284
|
+
|
285
|
+
def inline_chapname(id)
|
286
|
+
chapter_name(arg)
|
287
|
+
end
|
288
|
+
|
289
|
+
def inline_list(arg)
|
290
|
+
'//l' + list_number(arg)
|
291
|
+
end
|
292
|
+
|
293
|
+
def inline_img(arg)
|
294
|
+
error "wrong image label: #{arg}" if /[^a-zA-Z\d\-]/ =~ arg
|
295
|
+
'//f' + figure_number(arg)
|
296
|
+
end
|
297
|
+
|
298
|
+
def inline_footnote(id)
|
299
|
+
'//ky' + footnote_number(id)
|
300
|
+
end
|
301
|
+
|
302
|
+
def inline_ruby(arg)
|
303
|
+
error 'wrong number of arg: @<ruby>' unless arg.count(',') == 1
|
304
|
+
"//ruby{#{arg}//}"
|
305
|
+
end
|
306
|
+
|
307
|
+
NAKAGURO = '��'
|
308
|
+
|
309
|
+
def inline_bou(str)
|
310
|
+
"//ruby{#{escape(str)},#{NAKAGURO * char_length(str)}//}"
|
311
|
+
end
|
312
|
+
|
313
|
+
def char_length(str)
|
314
|
+
str.gsub(/./, '.').length
|
315
|
+
end
|
316
|
+
|
317
|
+
def inline_em(str)
|
318
|
+
"//g{#{arg}//}"
|
319
|
+
end
|
320
|
+
|
321
|
+
def inline_math(arg)
|
322
|
+
"//LaTeX{ $#{arg}$ //}"
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
def chapter_id
|
327
|
+
File.basename(@filename, '.rd')
|
328
|
+
end
|
329
|
+
|
330
|
+
def chapter_prefix
|
331
|
+
sprintf('%02d', @chapter_table.number(chapter_id()))
|
332
|
+
end
|
333
|
+
|
334
|
+
def chapter_number( key )
|
335
|
+
curr = @chapter_table.number(chapter_id())
|
336
|
+
dest = @chapter_table.number(key)
|
337
|
+
|
338
|
+
case chapter_id()
|
339
|
+
when /\.ewb\z/, 'tmp', 'temp'
|
340
|
+
return '��' + dest + '��'
|
341
|
+
end
|
342
|
+
if dest == curr + 1
|
343
|
+
'����'
|
344
|
+
elsif dest == curr - 1
|
345
|
+
'����'
|
346
|
+
else
|
347
|
+
"��#{dest}��"
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
def chapter_name(key)
|
352
|
+
'��' + text(@chapter_table.title(key)) + '��'
|
353
|
+
end
|
354
|
+
|
355
|
+
def list_number(key)
|
356
|
+
sprintf(chapter_prefix() + '%02d0', @list_table.number(key))
|
357
|
+
end
|
358
|
+
|
359
|
+
def figure_number(key)
|
360
|
+
sprintf(chapter_prefix() + '%02d0', @figure_table.number(key))
|
361
|
+
end
|
362
|
+
|
363
|
+
def footnote_number(key)
|
364
|
+
sprintf('%02d', @footnote_index.number(key) * 5)
|
365
|
+
end
|
366
|
+
|
367
|
+
def add_index(str)
|
368
|
+
@index_buffer.push str
|
369
|
+
"//in#{index_number(@index_buffer.size)}"
|
370
|
+
end
|
371
|
+
|
372
|
+
def index_number(n)
|
373
|
+
900000 + @chapter_index.number(chapter_id()) * 1000 + n
|
374
|
+
end
|
375
|
+
|
376
|
+
def escape(str)
|
377
|
+
str.gsub(%r<//>, '////')
|
378
|
+
end
|
379
|
+
|
380
|
+
end
|
381
|
+
|
382
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# $Id: exception.rb 3881 2008-02-09 14:44:17Z aamine $
|
3
|
+
#
|
4
|
+
# Copyright (c) 2002-2007 Minero Aoki
|
5
|
+
#
|
6
|
+
# This program is free software.
|
7
|
+
# You can distribute or modify this program under the terms of
|
8
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
9
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
10
|
+
#
|
11
|
+
|
12
|
+
module ReVIEW
|
13
|
+
|
14
|
+
class Error < ::StandardError; end
|
15
|
+
class ApplicationError < Error; end
|
16
|
+
class ConfigError < ApplicationError; end
|
17
|
+
class CompileError < ApplicationError; end
|
18
|
+
class SyntaxError < CompileError; end
|
19
|
+
class FileNotFound < ApplicationError; end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,370 @@
|
|
1
|
+
# $Id: htmlbuilder.rb 4268 2009-05-27 04:17:08Z kmuto $
|
2
|
+
#
|
3
|
+
# Copyright (c) 2002-2007 Minero Aoki
|
4
|
+
# 2008-2009 Minero Aoki, Kenshi Muto
|
5
|
+
#
|
6
|
+
# This program is free software.
|
7
|
+
# You can distribute or modify this program under the terms of
|
8
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'review/builder'
|
12
|
+
require 'review/htmlutils'
|
13
|
+
require 'review/htmllayout'
|
14
|
+
require 'review/textutils'
|
15
|
+
|
16
|
+
module ReVIEW
|
17
|
+
|
18
|
+
class HTMLBuilder < Builder
|
19
|
+
|
20
|
+
include TextUtils
|
21
|
+
include HTMLUtils
|
22
|
+
|
23
|
+
def extname
|
24
|
+
'.html'
|
25
|
+
end
|
26
|
+
|
27
|
+
def builder_init(no_error = false)
|
28
|
+
@no_error = no_error
|
29
|
+
end
|
30
|
+
private :builder_init
|
31
|
+
|
32
|
+
def builder_init_file
|
33
|
+
@warns = []
|
34
|
+
@errors = []
|
35
|
+
end
|
36
|
+
private :builder_init_file
|
37
|
+
|
38
|
+
def result
|
39
|
+
layout_file = File.join(@book.basedir, "layouts", "layout.erb")
|
40
|
+
if File.exists?(layout_file)
|
41
|
+
messages() +
|
42
|
+
HTMLLayout.new(@output.string, @chapter.title, layout_file).result
|
43
|
+
else
|
44
|
+
messages() + @output.string
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def warn(msg)
|
49
|
+
if @no_error
|
50
|
+
@warns.push [@location.filename, @location.lineno, msg]
|
51
|
+
puts "----WARNING: #{escape_html(msg)}----"
|
52
|
+
else
|
53
|
+
$stderr.puts "#{@location}: warning: #{msg}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def error(msg)
|
58
|
+
if @no_error
|
59
|
+
@errors.push [@location.filename, @location.lineno, msg]
|
60
|
+
puts "----ERROR: #{escape_html(msg)}----"
|
61
|
+
else
|
62
|
+
$stderr.puts "#{@location}: error: #{msg}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def messages
|
67
|
+
error_messages() + warning_messages()
|
68
|
+
end
|
69
|
+
|
70
|
+
def error_messages
|
71
|
+
return '' if @errors.empty?
|
72
|
+
"<h2>Syntax Errors</h2>\n" +
|
73
|
+
"<ul>\n" +
|
74
|
+
@errors.map {|file, line, msg|
|
75
|
+
"<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n"
|
76
|
+
}.join('') +
|
77
|
+
"</ul>\n"
|
78
|
+
end
|
79
|
+
|
80
|
+
def warning_messages
|
81
|
+
return '' if @warns.empty?
|
82
|
+
"<h2>Warnings</h2>\n" +
|
83
|
+
"<ul>\n" +
|
84
|
+
@warns.map {|file, line, msg|
|
85
|
+
"<li>#{escape_html(file)}:#{line}: #{escape_html(msg)}</li>\n"
|
86
|
+
}.join('') +
|
87
|
+
"</ul>\n"
|
88
|
+
end
|
89
|
+
|
90
|
+
def headline(level, label, caption)
|
91
|
+
puts '' if level > 1
|
92
|
+
if label.nil?
|
93
|
+
puts "<h#{level}>#{escape_html(caption)}</h#{level}>"
|
94
|
+
else
|
95
|
+
puts "<h#{level} id='#{label}'>#{escape_html(caption)}</h#{level}>"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def column_begin(level, label, caption)
|
100
|
+
puts "<div class='column'>"
|
101
|
+
headline(level, label, caption) # FIXME
|
102
|
+
end
|
103
|
+
|
104
|
+
def column_end(level)
|
105
|
+
puts '</div>'
|
106
|
+
end
|
107
|
+
|
108
|
+
def ul_begin
|
109
|
+
puts '<ul>'
|
110
|
+
end
|
111
|
+
|
112
|
+
def ul_item(lines)
|
113
|
+
puts "<li>#{lines.join("\n")}</li>"
|
114
|
+
end
|
115
|
+
|
116
|
+
def ul_end
|
117
|
+
puts '</ul>'
|
118
|
+
end
|
119
|
+
|
120
|
+
def ol_begin
|
121
|
+
puts '<ol>'
|
122
|
+
end
|
123
|
+
|
124
|
+
def ol_item(lines, num)
|
125
|
+
puts "<li>#{lines.join("\n")}</li>"
|
126
|
+
end
|
127
|
+
|
128
|
+
def ol_end
|
129
|
+
puts '</ol>'
|
130
|
+
end
|
131
|
+
|
132
|
+
def dl_begin
|
133
|
+
puts '<dl>'
|
134
|
+
end
|
135
|
+
|
136
|
+
def dt(line)
|
137
|
+
puts "<dt>#{line}</dt>"
|
138
|
+
end
|
139
|
+
|
140
|
+
def dd(lines)
|
141
|
+
puts "<dd>#{lines.join("\n")}</dd>"
|
142
|
+
end
|
143
|
+
|
144
|
+
def dl_end
|
145
|
+
puts '</dl>'
|
146
|
+
end
|
147
|
+
|
148
|
+
def paragraph(lines)
|
149
|
+
puts "<p>#{lines.join("")}</p>"
|
150
|
+
end
|
151
|
+
|
152
|
+
def parasep()
|
153
|
+
puts '<br />'
|
154
|
+
end
|
155
|
+
|
156
|
+
def read(lines)
|
157
|
+
puts %Q[<p class="lead">\n#{lines.join("\n")}\n</p>]
|
158
|
+
end
|
159
|
+
|
160
|
+
def lead(lines)
|
161
|
+
read(lines)
|
162
|
+
end
|
163
|
+
|
164
|
+
def list_header(id, caption)
|
165
|
+
puts %Q[<p class="toplabel">リスト#{@chapter.list(id).number}: #{escape_html(caption)}</p>]
|
166
|
+
end
|
167
|
+
|
168
|
+
def list_body(lines)
|
169
|
+
puts '<div class="caption-code">'
|
170
|
+
puts '<pre class="list">'
|
171
|
+
lines.each do |line|
|
172
|
+
puts detab(line)
|
173
|
+
end
|
174
|
+
puts '</pre>'
|
175
|
+
puts '</div>'
|
176
|
+
end
|
177
|
+
|
178
|
+
def source_header(caption)
|
179
|
+
puts %Q[<p class="toplabel">▼#{escape_html(caption)}</p>]
|
180
|
+
end
|
181
|
+
|
182
|
+
def source_body(lines)
|
183
|
+
puts '<div class="caption-code">'
|
184
|
+
puts '<pre class="source">'
|
185
|
+
lines.each do |line|
|
186
|
+
puts detab(line)
|
187
|
+
end
|
188
|
+
puts '</pre>'
|
189
|
+
puts '</div>'
|
190
|
+
end
|
191
|
+
|
192
|
+
def listnum_body(lines)
|
193
|
+
puts '<div class="code">'
|
194
|
+
puts '<pre class="list">'
|
195
|
+
lines.each_with_index do |line, i|
|
196
|
+
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
197
|
+
end
|
198
|
+
puts '</pre>'
|
199
|
+
puts '</div>'
|
200
|
+
end
|
201
|
+
|
202
|
+
def emlist(lines)
|
203
|
+
puts '<div class="code">'
|
204
|
+
puts '<pre class="emlist">'
|
205
|
+
lines.each do |line|
|
206
|
+
puts detab(line)
|
207
|
+
end
|
208
|
+
puts '</pre>'
|
209
|
+
puts '</div>'
|
210
|
+
end
|
211
|
+
|
212
|
+
def emlistnum(lines)
|
213
|
+
puts '<div class="code">'
|
214
|
+
puts '<pre class="emlist">'
|
215
|
+
lines.each_with_index do |line, i|
|
216
|
+
puts detab((i+1).to_s.rjust(2) + ": " + line)
|
217
|
+
end
|
218
|
+
puts '</pre>'
|
219
|
+
puts '</div>'
|
220
|
+
end
|
221
|
+
|
222
|
+
def cmd(lines)
|
223
|
+
puts '<div class="code">'
|
224
|
+
puts '<pre class="cmd">'
|
225
|
+
lines.each do |line|
|
226
|
+
puts detab(line)
|
227
|
+
end
|
228
|
+
puts '</pre>'
|
229
|
+
puts '</div>'
|
230
|
+
end
|
231
|
+
|
232
|
+
def quotedlist(lines, css_class)
|
233
|
+
puts %Q[<blockquote><pre class="#{css_class}">]
|
234
|
+
lines.each do |line|
|
235
|
+
puts detab(line)
|
236
|
+
end
|
237
|
+
puts '</pre></blockquote>'
|
238
|
+
end
|
239
|
+
private :quotedlist
|
240
|
+
|
241
|
+
def quote(lines)
|
242
|
+
puts "<blockquote>#{lines.join("\n")}</blockquote>"
|
243
|
+
end
|
244
|
+
|
245
|
+
def image_image(id, metric, caption)
|
246
|
+
puts %Q[<p class="image">]
|
247
|
+
puts %Q[<img src="#{@chapter.image(id).path}" alt="(#{escape_html(caption)})">]
|
248
|
+
puts %Q[</p>]
|
249
|
+
image_header id, caption
|
250
|
+
end
|
251
|
+
|
252
|
+
def image_dummy(id, caption, lines)
|
253
|
+
puts %Q[<pre class="dummyimage">]
|
254
|
+
lines.each do |line|
|
255
|
+
puts detab(line)
|
256
|
+
end
|
257
|
+
puts %Q[</pre>]
|
258
|
+
image_header id, caption
|
259
|
+
end
|
260
|
+
|
261
|
+
def image_header(id, caption)
|
262
|
+
puts %Q[<p class="botlabel">]
|
263
|
+
puts %Q[図#{@chapter.image(id).number}: #{escape_html(caption)}]
|
264
|
+
puts %Q[</p>]
|
265
|
+
end
|
266
|
+
|
267
|
+
def table_header(id, caption)
|
268
|
+
puts %Q[<p class="toplabel">表#{@chapter.table(id).number}: #{escape_html(caption)}</p>]
|
269
|
+
end
|
270
|
+
|
271
|
+
def table_begin(ncols)
|
272
|
+
puts '<table>'
|
273
|
+
end
|
274
|
+
|
275
|
+
def tr(rows)
|
276
|
+
puts "<tr>#{rows.join('')}</tr>"
|
277
|
+
end
|
278
|
+
|
279
|
+
def th(str)
|
280
|
+
"<th>#{str}</th>"
|
281
|
+
end
|
282
|
+
|
283
|
+
def td(str)
|
284
|
+
"<td>#{str}</td>"
|
285
|
+
end
|
286
|
+
|
287
|
+
def table_end
|
288
|
+
puts '</table>'
|
289
|
+
end
|
290
|
+
|
291
|
+
def comment(str)
|
292
|
+
puts %Q(<p class="comment">[Comment] #{escape_html(str)}</p>)
|
293
|
+
end
|
294
|
+
|
295
|
+
def footnote(id, str)
|
296
|
+
puts %Q(<p class="comment"><a name="fn-#{id}">#{escape_html(str)}</a></p>)
|
297
|
+
end
|
298
|
+
|
299
|
+
def inline_fn(id)
|
300
|
+
%Q(<a href="\#fn-#{id}">*#{@chapter.footnote(id).number}</a>)
|
301
|
+
end
|
302
|
+
|
303
|
+
def compile_ruby(base, ruby)
|
304
|
+
escape_html(base) # tmp
|
305
|
+
end
|
306
|
+
|
307
|
+
def compile_kw(word, alt)
|
308
|
+
'<span class="kw">' +
|
309
|
+
if alt
|
310
|
+
#then escape_html(word + sprintf(@locale[:parens], alt.strip))
|
311
|
+
then escape_html(word + " (#{alt.strip})")
|
312
|
+
else escape_html(word)
|
313
|
+
end +
|
314
|
+
'</span>'
|
315
|
+
end
|
316
|
+
|
317
|
+
def inline_i(str)
|
318
|
+
%Q(<i>#{escape_html(str)}</i>)
|
319
|
+
end
|
320
|
+
|
321
|
+
def inline_b(str)
|
322
|
+
%Q(<b>#{escape_html(str)}</b>)
|
323
|
+
end
|
324
|
+
|
325
|
+
def inline_ami(str)
|
326
|
+
escape_html(str) # tmp
|
327
|
+
end
|
328
|
+
|
329
|
+
def inline_dtp(arg)
|
330
|
+
# ignore all
|
331
|
+
''
|
332
|
+
end
|
333
|
+
|
334
|
+
def inline_code(str)
|
335
|
+
%Q(<span class="inline-code">#{str}</span>)
|
336
|
+
end
|
337
|
+
|
338
|
+
def text(str)
|
339
|
+
str
|
340
|
+
end
|
341
|
+
|
342
|
+
def bibpaper_header(id, caption)
|
343
|
+
puts %Q(<a name="bib-#{id}">)
|
344
|
+
puts "[#{@chapter.bibpaper(id).number}] #{caption}"
|
345
|
+
puts %Q(</a>)
|
346
|
+
end
|
347
|
+
|
348
|
+
def bibpaper_bibpaper(id, caption, lines)
|
349
|
+
puts %Q(<p>)
|
350
|
+
lines.each do |line|
|
351
|
+
puts detab(line)
|
352
|
+
end
|
353
|
+
puts %Q(</p>)
|
354
|
+
end
|
355
|
+
|
356
|
+
def inline_bib(id)
|
357
|
+
%Q(<a href=".#{@book.bib_file.gsub(/re$/, "html")}\#bib-#{id}">[#{@chapter.bibpaper(id).number}]</a>)
|
358
|
+
end
|
359
|
+
|
360
|
+
def inline_raw(str)
|
361
|
+
escape_html(str)
|
362
|
+
end
|
363
|
+
|
364
|
+
def nofunc_text(str)
|
365
|
+
escape_html(str)
|
366
|
+
end
|
367
|
+
|
368
|
+
end
|
369
|
+
|
370
|
+
end # module ReVIEW
|