Class: ReVIEW::INAOBuilder
Constant Summary
Constants inherited
from Builder
Builder::CAPTION_TITLES
Instance Method Summary
collapse
-
#base_parablock(type, lines, caption = nil) ⇒ Object
-
#cmd(lines, caption = nil) ⇒ Object
-
#column_begin(level, label, caption) ⇒ Object
-
#column_end(level) ⇒ Object
-
#compile_ruby(base, ruby) ⇒ Object
-
#emlist(lines, caption = nil) ⇒ Object
-
#error(msg) ⇒ Object
-
#extname ⇒ Object
-
#footnote(id, str) ⇒ Object
-
#headline(level, label, caption) ⇒ Object
-
#image(lines, id, caption, metric = nil) ⇒ Object
-
#inline_b(str) ⇒ Object
-
#inline_balloon(str) ⇒ Object
-
#inline_cmd(str) ⇒ Object
-
#inline_comment(str) ⇒ Object
-
#inline_fn(id) ⇒ Object
-
#inline_i(str) ⇒ Object
-
#inline_img(id) ⇒ Object
-
#inline_kbd(str) ⇒ Object
-
#inline_keytop(str) ⇒ Object
-
#inline_list(id) ⇒ Object
-
#inline_raw(str) ⇒ Object
-
#inline_table(id) ⇒ Object
-
#inline_tt(str) ⇒ Object
-
#inline_uchar(str) ⇒ Object
-
#list_body(id, lines) ⇒ Object
-
#list_header(id, caption) ⇒ Object
-
#listnum_body(lines) ⇒ Object
-
#messages ⇒ Object
-
#nofunc_text(str) ⇒ Object
-
#noindent ⇒ Object
-
#ol_begin ⇒ Object
-
#ol_end ⇒ Object
-
#ol_item(lines, num) ⇒ Object
-
#paragraph(lines) ⇒ Object
-
#post_paragraph ⇒ Object
-
#pre_paragraph ⇒ Object
-
#quote(lines) ⇒ Object
-
#result ⇒ Object
-
#table(lines, id = nil, caption = nil) ⇒ Object
-
#table_begin(ncols) ⇒ Object
-
#table_end ⇒ Object
-
#table_header(id, caption) ⇒ Object
-
#td(str) ⇒ Object
-
#text(str) ⇒ Object
-
#th(str) ⇒ Object
-
#tr(rows) ⇒ Object
-
#ul_begin ⇒ Object
-
#ul_end ⇒ Object
-
#ul_item(lines) ⇒ Object
-
#warn(msg) ⇒ Object
Methods included from TextUtils
#convert_inencoding, #convert_outencoding, #detab, #split_paragraph
Methods inherited from Builder
#bibpaper, #bind, #captionblock, #compile_inline, #detab, #entries, #extract_chapter_id, #find_pathes, #get_chap, #graph, #handle_metric, #image_ext, #include, #initialize, #inline_bou, #inline_chap, #inline_chapref, #inline_hd, #inline_href, #inline_include, #inline_kw, #inline_ruby, #inline_title, #list, #listnum, #parse_metric, #raw, #result_metric, #source, #ul_item_begin, #ul_item_end
Instance Method Details
#base_parablock(type, lines, caption = nil) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/review/inaobuilder.rb', line 81
def base_parablock(type, lines, caption=nil)
puts "◆#{@titles[type]}/◆"
puts "■■■■■#{compile_inline(caption)}" unless caption.nil?
puts split_paragraph(lines).join("\n")
puts "◆/#{@titles[type]}◆"
blank
end
|
#cmd(lines, caption = nil) ⇒ Object
230
231
232
233
234
235
236
237
|
# File 'lib/review/inaobuilder.rb', line 230
def cmd(lines, caption=nil)
puts "◆list-white/◆"
puts %Q[●#{compile_inline(caption)}] unless caption.nil?
lines.each do |line|
puts detab(line)
end
puts "◆/list-white◆"
end
|
#column_begin(level, label, caption) ⇒ Object
146
147
148
149
150
|
# File 'lib/review/inaobuilder.rb', line 146
def column_begin(level, label, caption)
puts "◆column/◆"
puts "■■■■#{compile_inline(caption)}"
end
|
#column_end(level) ⇒ Object
152
153
154
|
# File 'lib/review/inaobuilder.rb', line 152
def column_end(level)
puts "◆/column◆"
end
|
#compile_ruby(base, ruby) ⇒ Object
138
139
140
|
# File 'lib/review/inaobuilder.rb', line 138
def compile_ruby(base, ruby)
"◆ルビ/◆#{base}◆#{ruby}◆/ルビ◆"
end
|
#emlist(lines, caption = nil) ⇒ Object
210
211
212
213
214
215
216
217
|
# File 'lib/review/inaobuilder.rb', line 210
def emlist(lines, caption=nil)
puts "◆list/◆"
puts %Q[●#{compile_inline(caption)}] unless caption.nil?
lines.each do |line|
puts detab(line)
end
puts "◆/list◆"
end
|
#error(msg) ⇒ Object
73
74
75
|
# File 'lib/review/inaobuilder.rb', line 73
def error(msg)
$stderr.puts "#{@location.filename}:#{@location.lineno}: error: #{msg}"
end
|
28
29
30
|
# File 'lib/review/inaobuilder.rb', line 28
def extname
'.txt'
end
|
120
121
122
|
# File 'lib/review/inaobuilder.rb', line 120
def (id, str)
end
|
#headline(level, label, caption) ⇒ Object
89
90
91
92
|
# File 'lib/review/inaobuilder.rb', line 89
def headline(level, label, caption)
prefix = "■" * level
puts "#{prefix}#{compile_inline(caption)}"
end
|
#image(lines, id, caption, metric = nil) ⇒ Object
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/review/inaobuilder.rb', line 248
def image(lines, id, caption, metric=nil)
if get_chap.nil?
puts "●図#{@chapter.image(id).number} #{compile_inline(caption)}"
else
puts "●図#{get_chap}.#{@chapter.image(id).number} #{compile_inline(caption)}"
end
if @chapter.image(id).bound?
puts @chapter.image(id).path
else
lines.each do |line|
puts line
end
end
end
|
#inline_b(str) ⇒ Object
104
105
106
|
# File 'lib/review/inaobuilder.rb', line 104
def inline_b(str)
"◆b/◆#{str}◆/b◆"
end
|
#inline_balloon(str) ⇒ Object
221
222
223
|
# File 'lib/review/inaobuilder.rb', line 221
def inline_balloon(str)
"◆comment/◆#{str}◆/comment◆"
end
|
#inline_cmd(str) ⇒ Object
116
117
118
|
# File 'lib/review/inaobuilder.rb', line 116
def inline_cmd(str)
inline_tt(str)
end
|
225
226
227
|
# File 'lib/review/inaobuilder.rb', line 225
def (str)
inline_balloon(str)
end
|
#inline_fn(id) ⇒ Object
124
125
126
|
# File 'lib/review/inaobuilder.rb', line 124
def inline_fn(id)
"◆注/◆#{compile_inline(@chapter.footnote(id).content.strip)}◆/注◆"
end
|
#inline_i(str) ⇒ Object
108
109
110
|
# File 'lib/review/inaobuilder.rb', line 108
def inline_i(str)
"◆i/◆#{str}◆/i◆"
end
|
#inline_img(id) ⇒ Object
239
240
241
242
243
244
245
246
|
# File 'lib/review/inaobuilder.rb', line 239
def inline_img(id)
chapter, id = (id)
if get_chap(chapter).nil?
"図#{chapter.image(id).number}"
else
"図#{get_chap(chapter)}.#{chapter.image(id).number}"
end
end
|
#inline_kbd(str) ⇒ Object
132
133
134
|
# File 'lib/review/inaobuilder.rb', line 132
def inline_kbd(str)
inline_keytop(str)
end
|
#inline_keytop(str) ⇒ Object
128
129
130
|
# File 'lib/review/inaobuilder.rb', line 128
def inline_keytop(str)
"#{str}▲"
end
|
#inline_list(id) ⇒ Object
178
179
180
181
182
183
184
185
|
# File 'lib/review/inaobuilder.rb', line 178
def inline_list(id)
chapter, id = (id)
if get_chap(chapter).nil?
%Q[リスト#{@chapter.list(id).number}]
else
%Q[リスト#{get_chap(chapter)}.#{@chapter.list(id).number}]
end
end
|
#inline_raw(str) ⇒ Object
338
339
340
|
# File 'lib/review/inaobuilder.rb', line 338
def inline_raw(str)
%Q[#{super(str).gsub("\\n", "\n")}]
end
|
#inline_table(id) ⇒ Object
263
264
265
266
267
268
269
270
|
# File 'lib/review/inaobuilder.rb', line 263
def inline_table(id)
chapter, id = (id)
if get_chap(chapter).nil?
"表#{chapter.table(id).number}"
else
"表#{get_chap(chapter)}.#{chapter.table(id).number}"
end
end
|
#inline_tt(str) ⇒ Object
112
113
114
|
# File 'lib/review/inaobuilder.rb', line 112
def inline_tt(str)
"◆cmd/◆#{str}◆/cmd◆"
end
|
#inline_uchar(str) ⇒ Object
342
343
344
|
# File 'lib/review/inaobuilder.rb', line 342
def inline_uchar(str)
[str.to_i(16)].pack("U")
end
|
#list_body(id, lines) ⇒ Object
196
197
198
199
200
201
|
# File 'lib/review/inaobuilder.rb', line 196
def list_body(id, lines)
lines.each do |line|
puts detab(line)
end
puts "◆/list◆"
end
|
187
188
189
190
191
192
193
194
|
# File 'lib/review/inaobuilder.rb', line 187
def (id, caption)
puts "◆list/◆"
if get_chap.nil?
puts %Q[●リスト#{@chapter.list(id).number} #{compile_inline(caption)}]
else
puts %Q[●リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}]
end
end
|
#listnum_body(lines) ⇒ Object
203
204
205
206
207
208
|
# File 'lib/review/inaobuilder.rb', line 203
def listnum_body(lines)
lines.each_with_index do |line, i|
puts detab((i+1).to_s.rjust(2) + " " +line)
end
puts "◆/list◆"
end
|
77
78
79
|
# File 'lib/review/inaobuilder.rb', line 77
def messages
error_messages() + warning_messages()
end
|
#nofunc_text(str) ⇒ Object
350
351
352
|
# File 'lib/review/inaobuilder.rb', line 350
def nofunc_text(str)
str
end
|
100
101
102
|
# File 'lib/review/inaobuilder.rb', line 100
def noindent
@noindent = true
end
|
166
167
168
|
# File 'lib/review/inaobuilder.rb', line 166
def ol_begin
@olitem = 0
end
|
174
175
176
|
# File 'lib/review/inaobuilder.rb', line 174
def ol_end
@olitem = nil
end
|
#ol_item(lines, num) ⇒ Object
170
171
172
|
# File 'lib/review/inaobuilder.rb', line 170
def ol_item(lines, num)
puts "(#{num})#{lines.join}"
end
|
#paragraph(lines) ⇒ Object
94
95
96
97
98
|
# File 'lib/review/inaobuilder.rb', line 94
def paragraph(lines)
print " " if @noindent.nil?
@noindent = nil
puts lines.join
end
|
#post_paragraph ⇒ Object
24
25
26
|
# File 'lib/review/inaobuilder.rb', line 24
def post_paragraph
''
end
|
#pre_paragraph ⇒ Object
20
21
22
|
# File 'lib/review/inaobuilder.rb', line 20
def pre_paragraph
''
end
|
#quote(lines) ⇒ Object
142
143
144
|
# File 'lib/review/inaobuilder.rb', line 142
def quote(lines)
base_parablock "quote", lines, nil
end
|
65
66
67
|
# File 'lib/review/inaobuilder.rb', line 65
def result
@output.string
end
|
#table(lines, id = nil, caption = nil) ⇒ Object
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
# File 'lib/review/inaobuilder.rb', line 272
def table(lines, id = nil, caption = nil)
rows = []
sepidx = nil
lines.each_with_index do |line, idx|
if /\A[\=\-]{12}/ =~ line
sepidx ||= idx
next
end
rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
end
rows = adjust_n_cols(rows)
puts "◆table/◆"
begin
id, caption unless caption.nil?
rescue KeyError => err
error "no such table: #{id}"
end
return if rows.empty?
table_begin rows.first.size
if sepidx
sepidx.times do
print "◆table-title◆"
tr rows.shift.map {|s| th(s) }
end
rows.each do |cols|
tr cols.map {|s| td(s) }
end
else
rows.each do |cols|
h, *cs = *cols
tr [th(h)] + cs.map {|s| td(s) }
end
end
table_end
end
|
#table_begin(ncols) ⇒ Object
319
320
|
# File 'lib/review/inaobuilder.rb', line 319
def table_begin(ncols)
end
|
#table_end ⇒ Object
334
335
336
|
# File 'lib/review/inaobuilder.rb', line 334
def table_end
puts "◆/table◆"
end
|
311
312
313
314
315
316
317
|
# File 'lib/review/inaobuilder.rb', line 311
def (id, caption)
if get_chap.nil?
puts "●表#{@chapter.table(id).number} #{compile_inline(caption)}"
else
puts "●表#{get_chap}.#{@chapter.table(id).number} #{compile_inline(caption)}"
end
end
|
330
331
332
|
# File 'lib/review/inaobuilder.rb', line 330
def td(str)
str
end
|
#text(str) ⇒ Object
346
347
348
|
# File 'lib/review/inaobuilder.rb', line 346
def text(str)
str
end
|
326
327
328
|
# File 'lib/review/inaobuilder.rb', line 326
def th(str)
str
end
|
322
323
324
|
# File 'lib/review/inaobuilder.rb', line 322
def tr(rows)
puts rows.join("\t")
end
|
156
157
|
# File 'lib/review/inaobuilder.rb', line 156
def ul_begin
end
|
163
164
|
# File 'lib/review/inaobuilder.rb', line 163
def ul_end
end
|
#ul_item(lines) ⇒ Object
159
160
161
|
# File 'lib/review/inaobuilder.rb', line 159
def ul_item(lines)
puts "・#{lines.join}"
end
|
#warn(msg) ⇒ Object
69
70
71
|
# File 'lib/review/inaobuilder.rb', line 69
def warn(msg)
$stderr.puts "#{@location.filename}:#{@location.lineno}: warning: #{msg}"
end
|