Class: ReVIEW::IDGXMLBuilder
Constant Summary
Constants included
from HTMLUtils
HTMLUtils::ESC
Constants inherited
from Builder
Builder::CAPTION_TITLES
Instance Method Summary
collapse
-
#best(lines, caption = nil) ⇒ Object
-
#bibpaper(lines, id, caption) ⇒ Object
-
#bibpaper_bibpaper(id, caption, lines) ⇒ Object
-
#bibpaper_header(id, caption) ⇒ Object
-
#box(lines, caption = nil) ⇒ Object
-
#bpo(lines) ⇒ Object
-
#captionblock(type, lines, caption, specialstyle = nil) ⇒ Object
-
#caution(lines, caption = nil) ⇒ Object
-
#centering(lines) ⇒ Object
-
#choice_multi_begin ⇒ Object
-
#choice_multi_end ⇒ Object
-
#choice_single_begin ⇒ Object
-
#choice_single_end ⇒ Object
-
#circle_begin(level, label, caption) ⇒ Object
-
#circle_end(level) ⇒ Object
-
#cmd(lines, caption = nil) ⇒ Object
-
#codelines_body(lines) ⇒ Object
-
#column_begin(level, label, caption) ⇒ Object
-
#column_end(level) ⇒ Object
-
#comment(str) ⇒ Object
-
#common_column_begin(type, caption) ⇒ Object
-
#common_column_end(type) ⇒ Object
-
#compile_href(url, label) ⇒ Object
-
#compile_kw(word, alt) ⇒ Object
-
#compile_ruby(base, ruby) ⇒ Object
-
#dd(lines) ⇒ Object
-
#dl_begin ⇒ Object
-
#dl_end ⇒ Object
-
#dt(line) ⇒ Object
-
#dtp(str) ⇒ Object
-
#edition_begin(level, label, caption) ⇒ Object
-
#edition_end(level) ⇒ Object
-
#emlist(lines, caption = nil, lang = nil) ⇒ Object
-
#emlistnum(lines, caption = nil, lang = nil) ⇒ Object
-
#error(msg) ⇒ Object
-
#error_messages ⇒ Object
-
#expert(lines) ⇒ Object
-
#extname ⇒ Object
-
#flushright(lines) ⇒ Object
-
#footnote(id, str) ⇒ Object
-
#handle_metric(str) ⇒ Object
-
#headline(level, label, caption) ⇒ Object
-
#hood_begin(level, label, caption) ⇒ Object
-
#hood_end(level) ⇒ Object
-
#hr ⇒ Object
-
#image_dummy(id, caption, lines) ⇒ Object
-
#image_ext ⇒ Object
-
#image_header(id, caption) ⇒ Object
-
#image_image(id, caption, metric = nil) ⇒ Object
-
#important(lines, caption = nil) ⇒ Object
-
#indepimage(id, caption = nil, metric = nil) ⇒ Object
(also: #numberlessimage)
-
#info(lines, caption = nil) ⇒ Object
-
#inline_ami(str) ⇒ Object
-
#inline_b(str) ⇒ Object
-
#inline_balloon(str) ⇒ Object
-
#inline_bib(id) ⇒ Object
-
#inline_bou(str) ⇒ Object
-
#inline_br(str) ⇒ Object
-
#inline_chap(id) ⇒ Object
-
#inline_chapref(id) ⇒ Object
-
#inline_code(str) ⇒ Object
-
#inline_column(id) ⇒ Object
-
#inline_dtp(str) ⇒ Object
-
#inline_fn(id) ⇒ Object
-
#inline_hd_chap(chap, id) ⇒ Object
-
#inline_hidx(str) ⇒ Object
-
#inline_hint(str) ⇒ Object
-
#inline_i(str) ⇒ Object
-
#inline_icon(id) ⇒ Object
-
#inline_idx(str) ⇒ Object
-
#inline_img(id) ⇒ Object
-
#inline_imgref(id) ⇒ Object
-
#inline_keytop(str) ⇒ Object
-
#inline_labelref(idref) ⇒ Object
(also: #inline_ref)
-
#inline_list(id) ⇒ Object
-
#inline_m(str) ⇒ Object
-
#inline_maru(str) ⇒ Object
-
#inline_pageref(idref) ⇒ Object
-
#inline_raw(str) ⇒ Object
-
#inline_recipe(id) ⇒ Object
-
#inline_sub(str) ⇒ Object
-
#inline_sup(str) ⇒ Object
-
#inline_table(id) ⇒ Object
-
#inline_title(id) ⇒ Object
-
#inline_tt(str) ⇒ Object
-
#inline_ttb(str) ⇒ Object
(also: #inline_ttbold)
-
#inline_tti(str) ⇒ Object
-
#inline_u(str) ⇒ Object
-
#inline_uchar(str) ⇒ Object
-
#insideout_begin(level, label, caption) ⇒ Object
-
#insideout_end(level) ⇒ Object
-
#insn(lines, caption = nil) ⇒ Object
-
#label(id) ⇒ Object
-
#linebreak ⇒ Object
-
#link(lines, caption = nil) ⇒ Object
-
#list_body(id, lines, lang) ⇒ Object
-
#list_header(id, caption, lang) ⇒ Object
-
#listnum_body(lines, lang) ⇒ Object
-
#memo(lines, caption = nil) ⇒ Object
-
#messages ⇒ Object
-
#nofunc_text(str) ⇒ Object
-
#noindent ⇒ Object
-
#nonum_begin(level, label, caption) ⇒ Object
-
#nonum_end(level) ⇒ Object
-
#note(lines, caption = nil) ⇒ Object
-
#notice(lines, caption = nil) ⇒ Object
-
#ol_begin ⇒ Object
-
#ol_end ⇒ Object
-
#ol_item(lines, num) ⇒ Object
-
#olnum(num) ⇒ Object
-
#pagebreak ⇒ Object
-
#paragraph(lines) ⇒ Object
-
#planning(lines, caption = nil) ⇒ Object
-
#point(lines, caption = nil) ⇒ Object
-
#post_paragraph ⇒ Object
-
#practice(lines) ⇒ Object
-
#pre_paragraph ⇒ Object
-
#quote(lines) ⇒ Object
-
#rawblock(lines) ⇒ Object
-
#read(lines) ⇒ Object
(also: #lead)
-
#ref_begin(level, label, caption) ⇒ Object
-
#ref_end(level) ⇒ Object
-
#reference(lines) ⇒ Object
-
#result ⇒ Object
-
#result_metric(array) ⇒ Object
-
#security(lines, caption = nil) ⇒ Object
-
#shoot(lines, caption = nil) ⇒ Object
-
#source_body(lines, lang) ⇒ Object
-
#source_header(caption) ⇒ Object
-
#sup_begin(level, label, caption) ⇒ Object
-
#sup_end(level) ⇒ Object
-
#syntaxblock(type, lines, caption) ⇒ Object
-
#table(lines, id = nil, caption = nil) ⇒ Object
-
#table_begin(ncols) ⇒ Object
-
#table_end ⇒ Object
-
#table_header(id, caption) ⇒ Object
-
#td(str) ⇒ Object
-
#term(lines) ⇒ Object
-
#texequation(lines) ⇒ Object
-
#text(str) ⇒ Object
-
#th(str) ⇒ Object
-
#tip(lines, caption = nil) ⇒ Object
-
#tr(rows) ⇒ Object
-
#trputs(tablewidth, rows, cellwidth, sepidx) ⇒ Object
-
#tsize(str) ⇒ Object
-
#ul_begin ⇒ Object
-
#ul_end ⇒ Object
-
#ul_item(lines) ⇒ Object
-
#ul_item_begin(lines) ⇒ Object
-
#ul_item_end ⇒ Object
-
#warn(msg) ⇒ Object
-
#warning_messages ⇒ Object
-
#world_begin(level, label, caption) ⇒ Object
-
#world_end(level) ⇒ Object
-
#xcolumn_begin(level, label, caption) ⇒ Object
-
#xcolumn_end(level) ⇒ Object
Methods included from HTMLUtils
#escape_comment, #escape_html, #highlight, #highlight?, #normalize_id, #strip_html, #unescape_html
Methods included from TextUtils
#detab, #split_paragraph
Methods inherited from Builder
#bind, #compile_inline, #detab, #extract_chapter_id, #get_chap, #graph, #image, #include, #initialize, #inline_hd, #inline_href, #inline_include, #inline_kw, #inline_ruby, #list, #listnum, #parse_metric, #print, #puts, #raw, #source, #target_name
Instance Method Details
#best(lines, caption = nil) ⇒ Object
939
940
941
|
# File 'lib/review/idgxmlbuilder.rb', line 939
def best(lines, caption = nil)
captionblock("best", lines, caption)
end
|
#bibpaper(lines, id, caption) ⇒ Object
1151
1152
1153
1154
1155
1156
1157
|
# File 'lib/review/idgxmlbuilder.rb', line 1151
def bibpaper(lines, id, caption)
id, caption
unless lines.empty?
bibpaper_bibpaper id, caption, lines
end
puts %Q(</bibitem>)
end
|
#bibpaper_bibpaper(id, caption, lines) ⇒ Object
1164
1165
1166
|
# File 'lib/review/idgxmlbuilder.rb', line 1164
def bibpaper_bibpaper(id, caption, lines)
print split_paragraph(lines).join("")
end
|
1159
1160
1161
1162
|
# File 'lib/review/idgxmlbuilder.rb', line 1159
def (id, caption)
puts %Q(<bibitem id="bib-#{id}">)
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>"
end
|
#box(lines, caption = nil) ⇒ Object
1031
1032
1033
|
# File 'lib/review/idgxmlbuilder.rb', line 1031
def box(lines, caption = nil)
syntaxblock("box", lines, caption)
end
|
#bpo(lines) ⇒ Object
1066
1067
1068
|
# File 'lib/review/idgxmlbuilder.rb', line 1066
def bpo(lines)
puts %Q[<bpo>#{lines.join("\n")}</bpo>]
end
|
#captionblock(type, lines, caption, specialstyle = nil) ⇒ Object
907
908
909
910
911
912
913
914
915
916
917
|
# File 'lib/review/idgxmlbuilder.rb', line 907
def captionblock(type, lines, caption, specialstyle = nil)
print "<#{type}>"
style = specialstyle.nil? ? "#{type}-title" : specialstyle
puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "#{blocked_lines.join}</#{type}>"
else
puts "#{lines.join("\n")}</#{type}>"
end
end
|
#caution(lines, caption = nil) ⇒ Object
951
952
953
|
# File 'lib/review/idgxmlbuilder.rb', line 951
def caution(lines, caption = nil)
captionblock("caution", lines, caption)
end
|
#centering(lines) ⇒ Object
903
904
905
|
# File 'lib/review/idgxmlbuilder.rb', line 903
def centering(lines)
puts split_paragraph(lines).join.gsub("<p>", "<p align='center'>")
end
|
#choice_multi_begin ⇒ Object
235
236
237
|
# File 'lib/review/idgxmlbuilder.rb', line 235
def choice_multi_begin
puts "<choice type='multi'>"
end
|
#choice_multi_end ⇒ Object
243
244
245
|
# File 'lib/review/idgxmlbuilder.rb', line 243
def choice_multi_end
puts "</choice>"
end
|
#choice_single_begin ⇒ Object
231
232
233
|
# File 'lib/review/idgxmlbuilder.rb', line 231
def choice_single_begin
puts "<choice type='single'>"
end
|
#choice_single_end ⇒ Object
239
240
241
|
# File 'lib/review/idgxmlbuilder.rb', line 239
def choice_single_end
puts "</choice>"
end
|
#circle_begin(level, label, caption) ⇒ Object
805
806
807
|
# File 'lib/review/idgxmlbuilder.rb', line 805
def circle_begin(level, label, caption)
puts %Q[<title aid:pstyle="smallcircle">•#{compile_inline(caption)}</title>]
end
|
#circle_end(level) ⇒ Object
809
810
|
# File 'lib/review/idgxmlbuilder.rb', line 809
def circle_end(level)
end
|
#cmd(lines, caption = nil) ⇒ Object
400
401
402
|
# File 'lib/review/idgxmlbuilder.rb', line 400
def cmd(lines, caption = nil)
quotedlist lines, 'cmd', caption
end
|
#codelines_body(lines) ⇒ Object
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
# File 'lib/review/idgxmlbuilder.rb', line 348
def codelines_body(lines)
no = 1
lines.each do |line|
unless @book.config["listinfo"].nil?
print "<listinfo line=\"#{no}\""
print " begin=\"1\"" if no == 1
print " end=\"#{no}\"" if no == lines.size
print ">"
end
print detab(line)
print "\n"
print "</listinfo>" unless @book.config["listinfo"].nil?
no += 1
end
end
|
#column_begin(level, label, caption) ⇒ Object
823
824
825
|
# File 'lib/review/idgxmlbuilder.rb', line 823
def column_begin(level, label, caption)
common_column_begin("", caption)
end
|
#column_end(level) ⇒ Object
827
828
829
|
# File 'lib/review/idgxmlbuilder.rb', line 827
def column_end(level)
common_column_end("")
end
|
632
633
634
|
# File 'lib/review/idgxmlbuilder.rb', line 632
def (str)
print %Q(<!-- [Comment] #{escape_html(str)} -->)
end
|
#common_column_begin(type, caption) ⇒ Object
812
813
814
815
816
817
|
# File 'lib/review/idgxmlbuilder.rb', line 812
def common_column_begin(type, caption)
@column += 1
a_id = %Q[id="column-#{@column}"]
print "<#{type}column #{a_id}>"
puts %Q[<title aid:pstyle="#{type}column-title">#{compile_inline(caption)}</title>]
end
|
#common_column_end(type) ⇒ Object
819
820
821
|
# File 'lib/review/idgxmlbuilder.rb', line 819
def common_column_end(type)
puts "</#{type}column>"
end
|
#compile_href(url, label) ⇒ Object
663
664
665
|
# File 'lib/review/idgxmlbuilder.rb', line 663
def compile_href(url, label)
%Q[<a linkurl='#{escape_html(url)}'>#{label.nil? ? escape_html(url) : escape_html(label)}</a>]
end
|
#compile_kw(word, alt) ⇒ Object
648
649
650
651
652
653
654
655
656
657
658
659
660
661
|
# File 'lib/review/idgxmlbuilder.rb', line 648
def compile_kw(word, alt)
'<keyword>' +
if alt
then escape_html("#{word}(#{alt.strip})")
else escape_html(word)
end +
'</keyword>' +
%Q[<index value="#{escape_html(word)}" />] +
if alt
alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{escape_html(e.strip)}" />] }.join
else
""
end
end
|
#compile_ruby(base, ruby) ⇒ Object
644
645
646
|
# File 'lib/review/idgxmlbuilder.rb', line 644
def compile_ruby(base, ruby)
%Q[<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape_html(base.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rb><aid:rt>#{escape_html(ruby.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rt></aid:ruby></GroupRuby>]
end
|
#dd(lines) ⇒ Object
282
283
284
|
# File 'lib/review/idgxmlbuilder.rb', line 282
def dd(lines)
puts "<dd>#{lines.join.chomp}</dd>"
end
|
274
275
276
|
# File 'lib/review/idgxmlbuilder.rb', line 274
def dl_begin
puts '<dl>'
end
|
286
287
288
|
# File 'lib/review/idgxmlbuilder.rb', line 286
def dl_end
puts '</dl>'
end
|
278
279
280
|
# File 'lib/review/idgxmlbuilder.rb', line 278
def dt(line)
puts "<dt>#{line}</dt>"
end
|
1058
1059
1060
|
# File 'lib/review/idgxmlbuilder.rb', line 1058
def dtp(str)
print %Q(<?dtp #{str} ?>)
end
|
#edition_begin(level, label, caption) ⇒ Object
855
856
857
|
# File 'lib/review/idgxmlbuilder.rb', line 855
def edition_begin(level, label, caption)
common_column_begin("edition", caption)
end
|
#edition_end(level) ⇒ Object
859
860
861
|
# File 'lib/review/idgxmlbuilder.rb', line 859
def edition_end(level)
common_column_end("edition")
end
|
#emlist(lines, caption = nil, lang = nil) ⇒ Object
370
371
372
|
# File 'lib/review/idgxmlbuilder.rb', line 370
def emlist(lines, caption = nil, lang = nil)
quotedlist lines, 'emlist', caption
end
|
#emlistnum(lines, caption = nil, lang = nil) ⇒ Object
374
375
376
377
378
379
380
|
# File 'lib/review/idgxmlbuilder.rb', line 374
def emlistnum(lines, caption = nil, lang = nil)
_lines = []
lines.each_with_index do |line, i|
_lines << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
end
quotedlist _lines, 'emlistnum', caption
end
|
#error(msg) ⇒ Object
111
112
113
114
115
116
117
118
|
# File 'lib/review/idgxmlbuilder.rb', line 111
def error(msg)
if @no_error
@errors.push [@location.filename, @location.lineno, msg]
puts "----ERROR: #{escape_html(msg)}----"
else
$stderr.puts "#{@location}: error: #{msg}"
end
end
|
#error_messages ⇒ Object
124
125
126
127
128
129
130
131
132
|
# File 'lib/review/idgxmlbuilder.rb', line 124
def error_messages
return '' if @errors.empty?
"<h2>Syntax Errors</h2>\n" +
"<ul>\n" +
@errors.map {|file, line, msg|
"<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n"
}.join('') +
"</ul>\n"
end
|
#expert(lines) ⇒ Object
995
996
997
|
# File 'lib/review/idgxmlbuilder.rb', line 995
def expert(lines)
captionblock("expert", lines, nil)
end
|
53
54
55
|
# File 'lib/review/idgxmlbuilder.rb', line 53
def extname
'.xml'
end
|
#flushright(lines) ⇒ Object
895
896
897
898
899
900
901
|
# File 'lib/review/idgxmlbuilder.rb', line 895
def flushright(lines)
if @book.config["deprecated-blocklines"].nil?
puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
else
puts "<p align='right'>#{lines.join("\n")}</p>"
end
end
|
636
637
638
|
# File 'lib/review/idgxmlbuilder.rb', line 636
def (id, str)
end
|
#handle_metric(str) ⇒ Object
465
466
467
468
|
# File 'lib/review/idgxmlbuilder.rb', line 465
def handle_metric(str)
k, v = str.split('=', 2)
return %Q|#{k}=\"#{v.sub(/\A["']/, '').sub(/["']\Z/, '')}\"|
end
|
#headline(level, label, caption) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/review/idgxmlbuilder.rb', line 144
def headline(level, label, caption)
case level
when 1
unless @secttags.nil?
print "</sect4>" if @subsubsubsection > 0
print "</sect3>" if @subsubsection > 0
print "</sect2>" if @subsection > 0
print "</sect>" if @section > 0
end
print %Q(<chapter id="chap:#{@chapter.number}">) unless @secttags.nil?
@section = 0
@subsection = 0
@subsubsection = 0
@subsubsubsection = 0
when 2
unless @secttags.nil?
print "</sect4>" if @subsubsubsection > 0
print "</sect3>" if @subsubsection > 0
print "</sect2>" if @subsection > 0
print "</sect>" if @section > 0
end
@section += 1
print %Q(<sect id="sect:#{@chapter.number}.#{@section}">) unless @secttags.nil?
@subsection = 0
@subsubsection = 0
@subsubsubsection = 0
when 3
unless @secttags.nil?
print "</sect4>" if @subsubsubsection > 0
print "</sect3>" if @subsubsection > 0
print "</sect2>" if @subsection > 0
end
@subsection += 1
print %Q(<sect2 id="sect:#{@chapter.number}.#{@section}.#{@subsection}">) unless @secttags.nil?
@subsubsection = 0
@subsubsubsection = 0
when 4
unless @secttags.nil?
print "</sect4>" if @subsubsubsection > 0
print "</sect3>" if @subsubsection > 0
end
@subsubsection += 1
print %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) unless @secttags.nil?
@subsubsubsection = 0
when 5
unless @secttags.nil?
print "</sect4>" if @subsubsubsection > 0
end
@subsubsubsection += 1
print %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) unless @secttags.nil?
else
raise "caption level too deep or unsupported: #{level}"
end
prefix, anchor = headline_prefix(level)
label = label.nil? ? "" : " id=\"#{label}\""
toccaption = escape_html(compile_inline(caption.gsub(/@<fn>\{.+?\}/, '')).gsub(/<[^>]+>/, ''))
puts %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{prefix}#{toccaption}"?>)
end
|
#hood_begin(level, label, caption) ⇒ Object
847
848
849
|
# File 'lib/review/idgxmlbuilder.rb', line 847
def hood_begin(level, label, caption)
common_column_begin("hood", caption)
end
|
#hood_end(level) ⇒ Object
851
852
853
|
# File 'lib/review/idgxmlbuilder.rb', line 851
def hood_end(level)
common_column_end("hood")
end
|
1062
1063
1064
|
# File 'lib/review/idgxmlbuilder.rb', line 1062
def hr
print "<hr />"
end
|
#image_dummy(id, caption, lines) ⇒ Object
482
483
484
485
486
487
488
489
490
491
492
493
|
# File 'lib/review/idgxmlbuilder.rb', line 482
def image_dummy(id, caption, lines)
puts "<img>"
print %Q[<pre aid:pstyle="dummyimage">]
lines.each do |line|
print detab(line)
print "\n"
end
print %Q[</pre>]
id, caption
puts "</img>"
warn "no such image: #{id}"
end
|
#image_ext ⇒ Object
1191
1192
1193
|
# File 'lib/review/idgxmlbuilder.rb', line 1191
def image_ext
"eps"
end
|
495
496
497
498
499
500
501
|
# File 'lib/review/idgxmlbuilder.rb', line 495
def (id, caption)
if get_chap.nil?
puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
else
puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
end
end
|
#image_image(id, caption, metric = nil) ⇒ Object
474
475
476
477
478
479
480
|
# File 'lib/review/idgxmlbuilder.rb', line 474
def image_image(id, caption, metric=nil)
metrics = parse_metric("idgxml", metric)
puts "<img>"
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}"#{metrics} />]
id, caption
puts "</img>"
end
|
#important(lines, caption = nil) ⇒ Object
943
944
945
|
# File 'lib/review/idgxmlbuilder.rb', line 943
def important(lines, caption = nil)
captionblock("important", lines, caption)
end
|
#indepimage(id, caption = nil, metric = nil) ⇒ Object
Also known as:
numberlessimage
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
|
# File 'lib/review/idgxmlbuilder.rb', line 1035
def indepimage(id, caption=nil, metric=nil)
metrics = parse_metric("idgxml", metric)
puts "<img>"
begin
puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}"#{metrics} />]
rescue
warn %Q[no such image: #{id}]
end
puts %Q[<caption>#{compile_inline(caption)}</caption>] if caption.present?
puts "</img>"
end
|
#info(lines, caption = nil) ⇒ Object
931
932
933
|
# File 'lib/review/idgxmlbuilder.rb', line 931
def info(lines, caption = nil)
captionblock("info", lines, caption)
end
|
#inline_ami(str) ⇒ Object
715
716
717
|
# File 'lib/review/idgxmlbuilder.rb', line 715
def inline_ami(str)
%Q(<ami>#{escape_html(str)}</ami>)
end
|
#inline_b(str) ⇒ Object
723
724
725
|
# File 'lib/review/idgxmlbuilder.rb', line 723
def inline_b(str)
%Q(<b>#{escape_html(str)}</b>)
end
|
#inline_balloon(str) ⇒ Object
772
773
774
|
# File 'lib/review/idgxmlbuilder.rb', line 772
def inline_balloon(str)
%Q[<balloon>#{escape_html(str).gsub(/@maru\[(\d+)\]/) {|m| inline_maru($1)}}</balloon>]
end
|
#inline_bib(id) ⇒ Object
1168
1169
1170
|
# File 'lib/review/idgxmlbuilder.rb', line 1168
def inline_bib(id)
%Q(<span type='bibref' idref='#{id}'>[#{@chapter.bibpaper(id).number}]</span>)
end
|
#inline_bou(str) ⇒ Object
754
755
756
|
# File 'lib/review/idgxmlbuilder.rb', line 754
def inline_bou(str)
%Q[<bou>#{escape_html(str)}</bou>]
end
|
#inline_br(str) ⇒ Object
1078
1079
1080
|
# File 'lib/review/idgxmlbuilder.rb', line 1078
def inline_br(str)
"\n"
end
|
#inline_chap(id) ⇒ Object
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
|
# File 'lib/review/idgxmlbuilder.rb', line 1117
def inline_chap(id)
if @book.config["chapterlink"]
%Q(<link href="#{id}">#{@book.chapter_index.number(id)}</link>)
else
@book.chapter_index.number(id)
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_chapref(id) ⇒ Object
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
|
# File 'lib/review/idgxmlbuilder.rb', line 1095
def inline_chapref(id)
chs = ["", "「", "」"]
unless @book.config["chapref"].nil?
_chs = @book.config["chapref"].split(",")
if _chs.size != 3
error "--chapsplitter must have exactly 3 parameters with comma."
else
chs = _chs
end
else
end
s = "#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
if @book.config["chapterlink"]
%Q(<link href="#{id}">#{s}</link>)
else
s
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_code(str) ⇒ Object
1074
1075
1076
|
# File 'lib/review/idgxmlbuilder.rb', line 1074
def inline_code(str)
%Q[<tt type='inline-code'>#{escape_html(str)}</tt>]
end
|
#inline_column(id) ⇒ Object
319
320
321
322
323
324
325
326
327
328
|
# File 'lib/review/idgxmlbuilder.rb', line 319
def inline_column(id)
if @book.config["chapterlink"]
%Q(<link href="#{column_label(id)}">#{escape_html(@chapter.column(id).caption)}</link>)
else
escape_html(@chapter.column(id).caption)
end
rescue KeyError
error "unknown column: #{id}"
nofunc_text("[UnknownColumn:#{id}]")
end
|
#inline_dtp(str) ⇒ Object
1070
1071
1072
|
# File 'lib/review/idgxmlbuilder.rb', line 1070
def inline_dtp(str)
"<?dtp #{str} ?>"
end
|
#inline_fn(id) ⇒ Object
640
641
642
|
# File 'lib/review/idgxmlbuilder.rb', line 640
def inline_fn(id)
%Q[<footnote>#{compile_inline(@chapter.(id).content.strip)}</footnote>]
end
|
#inline_hd_chap(chap, id) ⇒ Object
1172
1173
1174
1175
1176
1177
1178
1179
1180
|
# File 'lib/review/idgxmlbuilder.rb', line 1172
def inline_hd_chap(chap, id)
if chap.number
n = chap.headline_index.number(id)
if @book.config["secnolevel"] >= n.split('.').size
return I18n.t("chapter_quote", "#{n} #{compile_inline(chap.headline(id).caption)}")
end
end
I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
end
|
#inline_hidx(str) ⇒ Object
711
712
713
|
# File 'lib/review/idgxmlbuilder.rb', line 711
def inline_hidx(str)
%Q(<index value="#{escape_html(str)}" />)
end
|
#inline_hint(str) ⇒ Object
679
680
681
682
683
684
685
|
# File 'lib/review/idgxmlbuilder.rb', line 679
def inline_hint(str)
if @book.config["nolf"].nil?
%Q[\n<hint>#{escape_html(str)}</hint>]
else
%Q[<hint>#{escape_html(str)}</hint>]
end
end
|
#inline_i(str) ⇒ Object
719
720
721
|
# File 'lib/review/idgxmlbuilder.rb', line 719
def inline_i(str)
%Q(<i>#{escape_html(str)}</i>)
end
|
#inline_icon(id) ⇒ Object
745
746
747
748
749
750
751
752
|
# File 'lib/review/idgxmlbuilder.rb', line 745
def inline_icon(id)
begin
%Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}" type="inline" />]
rescue
warn "no such icon image: #{id}"
""
end
end
|
#inline_idx(str) ⇒ Object
707
708
709
|
# File 'lib/review/idgxmlbuilder.rb', line 707
def inline_idx(str)
%Q(#{escape_html(str)}<index value="#{escape_html(str)}" />)
end
|
#inline_img(id) ⇒ Object
443
444
445
446
447
448
449
450
|
# File 'lib/review/idgxmlbuilder.rb', line 443
def inline_img(id)
chapter, id = (id)
if get_chap(chapter).nil?
"<span type='image'>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}</span>"
else
"<span type='image'>#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}</span>"
end
end
|
#inline_imgref(id) ⇒ Object
452
453
454
455
456
457
458
459
460
461
462
463
|
# File 'lib/review/idgxmlbuilder.rb', line 452
def inline_imgref(id)
chapter, id = (id)
if chapter.image(id).caption.blank?
inline_img(id)
else
if get_chap(chapter).nil?
"<span type='image'>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}#{I18n.t('image_quote', chapter.image(id).caption)}</span>"
else
"<span type='image'>#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}#{I18n.t('image_quote', chapter.image(id).caption)}</span>"
end
end
end
|
#inline_keytop(str) ⇒ Object
758
759
760
|
# File 'lib/review/idgxmlbuilder.rb', line 758
def inline_keytop(str)
%Q[<keytop>#{escape_html(str)}</keytop>]
end
|
#inline_labelref(idref) ⇒ Object
Also known as:
inline_ref
762
763
764
|
# File 'lib/review/idgxmlbuilder.rb', line 762
def inline_labelref(idref)
%Q[<ref idref='#{escape_html(idref)}'>「#{I18n.t("label_marker")}#{escape_html(idref)}」</ref>] end
|
#inline_list(id) ⇒ Object
330
331
332
333
334
335
336
337
|
# File 'lib/review/idgxmlbuilder.rb', line 330
def inline_list(id)
chapter, id = (id)
if get_chap(chapter).nil?
"<span type='list'>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [chapter.list(id).number])}</span>"
else
"<span type='list'>#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), chapter.list(id).number])}</span>"
end
end
|
#inline_m(str) ⇒ Object
780
781
782
783
|
# File 'lib/review/idgxmlbuilder.rb', line 780
def inline_m(str)
@texinlineequation += 1
%Q[<replace idref="texinline-#{@texinlineequation}"><pre>#{escape_html(str)}</pre></replace>]
end
|
#inline_maru(str) ⇒ Object
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
# File 'lib/review/idgxmlbuilder.rb', line 687
def inline_maru(str)
if str =~ /\A\d+\Z/
sprintf("&#x%x;", 9311 + str.to_i)
elsif str =~ /\A[A-Z]\Z/
begin
sprintf("&#x%x;", 9398 + str.codepoints.to_a[0] - 65)
rescue NoMethodError
sprintf("&#x%x;", 9398 + str[0] - 65)
end
elsif str =~ /\A[a-z]\Z/
begin
sprintf("&#x%x;", 9392 + str.codepoints.to_a[0] - 65)
rescue NoMethodError
sprintf("&#x%x;", 9392 + str[0] - 65)
end
else
raise "can't parse maru: #{str}"
end
end
|
768
769
770
|
# File 'lib/review/idgxmlbuilder.rb', line 768
def (idref)
%Q[<pageref idref='#{escape_html(idref)}'>●●</pageref>] end
|
#inline_raw(str) ⇒ Object
675
676
677
|
# File 'lib/review/idgxmlbuilder.rb', line 675
def inline_raw(str)
%Q[#{super(str).gsub("\\n", "\n")}]
end
|
#inline_recipe(id) ⇒ Object
1182
1183
1184
1185
|
# File 'lib/review/idgxmlbuilder.rb', line 1182
def inline_recipe(id)
%Q(<recipe idref="#{escape_html(id)}">[XXX]「#{escape_html(id)}」 p.XX</recipe>)
end
|
#inline_sub(str) ⇒ Object
671
672
673
|
# File 'lib/review/idgxmlbuilder.rb', line 671
def inline_sub(str)
%Q[<sub>#{escape_html(str)}</sub>]
end
|
#inline_sup(str) ⇒ Object
667
668
669
|
# File 'lib/review/idgxmlbuilder.rb', line 667
def inline_sup(str)
%Q[<sup>#{escape_html(str)}</sup>]
end
|
#inline_table(id) ⇒ Object
434
435
436
437
438
439
440
441
|
# File 'lib/review/idgxmlbuilder.rb', line 434
def inline_table(id)
chapter, id = (id)
if get_chap(chapter).nil?
"<span type='table'>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}</span>"
else
"<span type='table'>#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}</span>"
end
end
|
#inline_title(id) ⇒ Object
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
|
# File 'lib/review/idgxmlbuilder.rb', line 1128
def inline_title(id)
title = super
if @book.config["chapterlink"]
%Q(<link href="#{id}">#{title}</link>)
else
title
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_tt(str) ⇒ Object
727
728
729
|
# File 'lib/review/idgxmlbuilder.rb', line 727
def inline_tt(str)
%Q(<tt>#{escape_html(str)}</tt>)
end
|
#inline_ttb(str) ⇒ Object
Also known as:
inline_ttbold
731
732
733
|
# File 'lib/review/idgxmlbuilder.rb', line 731
def inline_ttb(str)
%Q(<tt style='bold'>#{escape_html(str)}</tt>)
end
|
#inline_tti(str) ⇒ Object
737
738
739
|
# File 'lib/review/idgxmlbuilder.rb', line 737
def inline_tti(str)
%Q(<tt style='italic'>#{escape_html(str)}</tt>)
end
|
#inline_u(str) ⇒ Object
741
742
743
|
# File 'lib/review/idgxmlbuilder.rb', line 741
def inline_u(str)
%Q(<underline>#{escape_html(str)}</underline>)
end
|
#inline_uchar(str) ⇒ Object
776
777
778
|
# File 'lib/review/idgxmlbuilder.rb', line 776
def inline_uchar(str)
%Q[&#x#{str};]
end
|
#insideout_begin(level, label, caption) ⇒ Object
863
864
865
|
# File 'lib/review/idgxmlbuilder.rb', line 863
def insideout_begin(level, label, caption)
common_column_begin("insideout", caption)
end
|
#insideout_end(level) ⇒ Object
867
868
869
|
# File 'lib/review/idgxmlbuilder.rb', line 867
def insideout_end(level)
common_column_end("insideout")
end
|
#insn(lines, caption = nil) ⇒ Object
1027
1028
1029
|
# File 'lib/review/idgxmlbuilder.rb', line 1027
def insn(lines, caption = nil)
syntaxblock("insn", lines, caption)
end
|
#label(id) ⇒ Object
1049
1050
1051
1052
|
# File 'lib/review/idgxmlbuilder.rb', line 1049
def label(id)
print "<label id='#{id}' />"
end
|
#linebreak ⇒ Object
789
790
791
792
|
# File 'lib/review/idgxmlbuilder.rb', line 789
def linebreak
puts "<br />"
end
|
#link(lines, caption = nil) ⇒ Object
959
960
961
|
# File 'lib/review/idgxmlbuilder.rb', line 959
def link(lines, caption = nil)
captionblock("link", lines, caption)
end
|
#list_body(id, lines, lang) ⇒ Object
364
365
366
367
368
|
# File 'lib/review/idgxmlbuilder.rb', line 364
def list_body(id, lines, lang)
print %Q(<pre>)
codelines_body(lines)
puts "</pre></codelist>"
end
|
339
340
341
342
343
344
345
346
|
# File 'lib/review/idgxmlbuilder.rb', line 339
def (id, caption, lang)
puts %Q[<codelist>]
if get_chap.nil?
puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
else
puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
end
end
|
#listnum_body(lines, lang) ⇒ Object
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
# File 'lib/review/idgxmlbuilder.rb', line 382
def listnum_body(lines, lang)
print %Q(<pre>)
no = 1
lines.each_with_index do |line, i|
unless @book.config["listinfo"].nil?
print "<listinfo line=\"#{no}\""
print " begin=\"1\"" if no == 1
print " end=\"#{no}\"" if no == lines.size
print ">"
end
print detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
print "\n"
print "</listinfo>" unless @book.config["listinfo"].nil?
no += 1
end
puts "</pre></codelist>"
end
|
#memo(lines, caption = nil) ⇒ Object
923
924
925
|
# File 'lib/review/idgxmlbuilder.rb', line 923
def memo(lines, caption = nil)
captionblock("memo", lines, caption)
end
|
120
121
122
|
# File 'lib/review/idgxmlbuilder.rb', line 120
def messages
error_messages() + warning_messages()
end
|
#nofunc_text(str) ⇒ Object
1187
1188
1189
|
# File 'lib/review/idgxmlbuilder.rb', line 1187
def nofunc_text(str)
escape_html(str)
end
|
785
786
787
|
# File 'lib/review/idgxmlbuilder.rb', line 785
def noindent
@noindent = true
end
|
#nonum_begin(level, label, caption) ⇒ Object
798
799
800
|
# File 'lib/review/idgxmlbuilder.rb', line 798
def nonum_begin(level, label, caption)
puts %Q[<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{escape_html(compile_inline(caption))}"?>]
end
|
#nonum_end(level) ⇒ Object
802
803
|
# File 'lib/review/idgxmlbuilder.rb', line 802
def nonum_end(level)
end
|
#note(lines, caption = nil) ⇒ Object
919
920
921
|
# File 'lib/review/idgxmlbuilder.rb', line 919
def note(lines, caption = nil)
captionblock("note", lines, caption)
end
|
#notice(lines, caption = nil) ⇒ Object
963
964
965
966
967
968
969
|
# File 'lib/review/idgxmlbuilder.rb', line 963
def notice(lines, caption = nil)
if caption.nil?
captionblock("notice", lines, nil)
else
captionblock("notice-t", lines, caption, "notice-title")
end
end
|
253
254
255
256
257
258
|
# File 'lib/review/idgxmlbuilder.rb', line 253
def ol_begin
puts '<ol>'
if !@ol_num
@ol_num = 1
end
end
|
265
266
267
268
|
# File 'lib/review/idgxmlbuilder.rb', line 265
def ol_end
puts '</ol>'
@ol_num = nil
end
|
#ol_item(lines, num) ⇒ Object
260
261
262
263
|
# File 'lib/review/idgxmlbuilder.rb', line 260
def ol_item(lines, num)
puts %Q(<li aid:pstyle="ol-item" olnum="#{@ol_num}" num="#{num}">#{lines.join.chomp}</li>)
@ol_num += 1
end
|
#olnum(num) ⇒ Object
270
271
272
|
# File 'lib/review/idgxmlbuilder.rb', line 270
def olnum(num)
@ol_num = num.to_i
end
|
#pagebreak ⇒ Object
794
795
796
|
# File 'lib/review/idgxmlbuilder.rb', line 794
def pagebreak
puts "<pagebreak />"
end
|
#paragraph(lines) ⇒ Object
290
291
292
293
294
295
296
297
298
299
300
301
|
# File 'lib/review/idgxmlbuilder.rb', line 290
def paragraph(lines)
if @noindent.nil?
if lines[0] =~ /\A(\t+)/
puts %Q(<p inlist="#{$1.size}">#{lines.join('').sub(/\A\t+/, "")}</p>)
else
puts "<p>#{lines.join}</p>"
end
else
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{lines.join}</p>)
@noindent = nil
end
end
|
#planning(lines, caption = nil) ⇒ Object
935
936
937
|
# File 'lib/review/idgxmlbuilder.rb', line 935
def planning(lines, caption = nil)
captionblock("planning", lines, caption)
end
|
#point(lines, caption = nil) ⇒ Object
971
972
973
974
975
976
977
|
# File 'lib/review/idgxmlbuilder.rb', line 971
def point(lines, caption = nil)
if caption.nil?
captionblock("point", lines, nil)
else
captionblock("point-t", lines, caption, "point-title")
end
end
|
#post_paragraph ⇒ Object
49
50
51
|
# File 'lib/review/idgxmlbuilder.rb', line 49
def post_paragraph
'</p>'
end
|
#practice(lines) ⇒ Object
991
992
993
|
# File 'lib/review/idgxmlbuilder.rb', line 991
def practice(lines)
captionblock("practice", lines, nil)
end
|
#pre_paragraph ⇒ Object
45
46
47
|
# File 'lib/review/idgxmlbuilder.rb', line 45
def pre_paragraph
'<p>'
end
|
#quote(lines) ⇒ Object
425
426
427
428
429
430
431
432
|
# File 'lib/review/idgxmlbuilder.rb', line 425
def quote(lines)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "<quote>#{blocked_lines.join("")}</quote>"
else
puts "<quote>#{lines.join("\n")}</quote>"
end
end
|
#rawblock(lines) ⇒ Object
1082
1083
1084
1085
1086
1087
1088
1089
|
# File 'lib/review/idgxmlbuilder.rb', line 1082
def rawblock(lines)
no = 1
lines.each do |l|
print l.gsub("<", "<").gsub(">", ">").gsub(""", "\"").gsub("&", "&")
print "\n" unless lines.length == no
no += 1
end
end
|
#read(lines) ⇒ Object
Also known as:
lead
303
304
305
306
307
308
309
|
# File 'lib/review/idgxmlbuilder.rb', line 303
def read(lines)
if @book.config["deprecated-blocklines"].nil?
puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
else
puts %Q[<p aid:pstyle="lead">#{lines.join}</p>]
end
end
|
#ref_begin(level, label, caption) ⇒ Object
871
872
873
874
875
876
877
|
# File 'lib/review/idgxmlbuilder.rb', line 871
def ref_begin(level, label, caption)
if !label.nil?
puts "<reference id='#{label}'>"
else
puts "<reference>"
end
end
|
#ref_end(level) ⇒ Object
879
880
881
|
# File 'lib/review/idgxmlbuilder.rb', line 879
def ref_end(level)
puts "</reference>"
end
|
#reference(lines) ⇒ Object
987
988
989
|
# File 'lib/review/idgxmlbuilder.rb', line 987
def reference(lines)
captionblock("reference", lines, nil)
end
|
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/review/idgxmlbuilder.rb', line 90
def result
s = ""
unless @secttags.nil?
s += "</sect4>" if @subsubsubsection > 0
s += "</sect3>" if @subsubsection > 0
s += "</sect2>" if @subsection > 0
s += "</sect>" if @section > 0
s += "</chapter>" if @chapter.number > 0
end
messages() + @output.string + s + "</#{@rootelement}>\n"
end
|
#result_metric(array) ⇒ Object
470
471
472
|
# File 'lib/review/idgxmlbuilder.rb', line 470
def result_metric(array)
" #{array.join(' ')}"
end
|
#security(lines, caption = nil) ⇒ Object
947
948
949
|
# File 'lib/review/idgxmlbuilder.rb', line 947
def security(lines, caption = nil)
captionblock("security", lines, caption)
end
|
#shoot(lines, caption = nil) ⇒ Object
979
980
981
982
983
984
985
|
# File 'lib/review/idgxmlbuilder.rb', line 979
def shoot(lines, caption = nil)
if caption.nil?
captionblock("shoot", lines, nil)
else
captionblock("shoot-t", lines, caption, "shoot-title")
end
end
|
#source_body(lines, lang) ⇒ Object
1145
1146
1147
1148
1149
|
# File 'lib/review/idgxmlbuilder.rb', line 1145
def source_body(lines, lang)
puts %Q[<pre>]
codelines_body(lines)
puts %Q[</pre></source>]
end
|
1140
1141
1142
1143
|
# File 'lib/review/idgxmlbuilder.rb', line 1140
def (caption)
puts %Q[<source>]
puts %Q[<caption>#{compile_inline(caption)}</caption>]
end
|
#sup_begin(level, label, caption) ⇒ Object
883
884
885
886
887
888
889
|
# File 'lib/review/idgxmlbuilder.rb', line 883
def sup_begin(level, label, caption)
if !label.nil?
puts "<supplement id='#{label}'>"
else
puts "<supplement>"
end
end
|
#sup_end(level) ⇒ Object
891
892
893
|
# File 'lib/review/idgxmlbuilder.rb', line 891
def sup_end(level)
puts "</supplement>"
end
|
#syntaxblock(type, lines, caption) ⇒ Object
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
|
# File 'lib/review/idgxmlbuilder.rb', line 999
def syntaxblock(type, lines, caption)
if caption.nil?
puts %Q[<#{type}>]
else
titleopentag = %Q[caption aid:pstyle="#{type}-title"]
titleclosetag = "caption"
if type == "insn"
titleopentag = %Q[floattitle type="insn"]
titleclosetag = "floattitle"
end
puts %Q[<#{type}><#{titleopentag}>#{compile_inline(caption)}</#{titleclosetag}>]
end
no = 1
lines.each do |line|
unless @book.config["listinfo"].nil?
print %Q[<listinfo line="#{no}"]
print %Q[ begin="1"] if no == 1
print %Q[ end="#{no}"] if no == lines.size
print %Q[>]
end
print detab(line)
print "\n"
print "</listinfo>" unless @book.config["listinfo"].nil?
no += 1
end
puts "</#{type}>"
end
|
#table(lines, id = nil, caption = nil) ⇒ Object
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
# File 'lib/review/idgxmlbuilder.rb', line 512
def table(lines, id = nil, caption = nil)
tablewidth = nil
col = 0
unless @book.config["tableopt"].nil?
tablewidth = @book.config["tableopt"].split(",")[0].to_f / 0.351 end
puts "<table>"
rows = []
sepidx = nil
lines.each_with_index do |line, idx|
if /\A[\=\-]{12}/ =~ line
sepidx ||= idx
next
end
if tablewidth.nil?
rows.push(line.gsub(/\t\.\t/, "\t\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\t").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ""))
else
rows.push(line.gsub(/\t\.\t/, "\tDUMMYCELLSPLITTER\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\tDUMMYCELLSPLITTER").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ""))
end
_col = rows[rows.length - 1].split(/\t/).length
col = _col if _col > col
end
cellwidth = []
unless tablewidth.nil?
if @tsize.nil?
col.times {|n| cellwidth[n] = tablewidth / col }
else
cellwidth = @tsize.split(/\s*,\s*/)
totallength = 0
cellwidth.size.times do |n|
cellwidth[n] = cellwidth[n].to_f / 0.351 totallength += cellwidth[n]
warn "total length exceeds limit for table: #{id}" if totallength > tablewidth
end
if cellwidth.size < col
cw = (tablewidth - totallength) / (col - cellwidth.size)
warn "auto cell sizing exceeds limit for table: #{id}" if cw <= 0
for i in cellwidth.size..(col - 1)
cellwidth[i] = cw
end
end
end
end
begin
id, caption unless caption.nil?
rescue KeyError
error "no such table: #{id}"
end
return if rows.empty?
if tablewidth.nil?
print "<tbody>"
else
print %Q[<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">]
end
if sepidx
sepidx.times do |y|
if tablewidth.nil?
puts %Q[<tr type="header">#{rows.shift}</tr>]
else
i = 0
rows.shift.split(/\t/).each_with_index do |cell, x|
print %Q[<td xyh="#{x + 1},#{y + 1},#{sepidx}" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
i += 1
end
end
end
end
trputs(tablewidth, rows, cellwidth, sepidx)
puts "</tbody></table>"
@tsize = nil
end
|
#table_begin(ncols) ⇒ Object
613
614
|
# File 'lib/review/idgxmlbuilder.rb', line 613
def table_begin(ncols)
end
|
#table_end ⇒ Object
628
629
630
|
# File 'lib/review/idgxmlbuilder.rb', line 628
def table_end
print "<?dtp tablerow last?>"
end
|
605
606
607
608
609
610
611
|
# File 'lib/review/idgxmlbuilder.rb', line 605
def (id, caption)
if get_chap.nil?
puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
else
puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
end
end
|
624
625
626
|
# File 'lib/review/idgxmlbuilder.rb', line 624
def td(str)
str
end
|
#term(lines) ⇒ Object
955
956
957
|
# File 'lib/review/idgxmlbuilder.rb', line 955
def term(lines)
captionblock("term", lines, nil)
end
|
#texequation(lines) ⇒ Object
503
504
505
506
507
508
509
510
|
# File 'lib/review/idgxmlbuilder.rb', line 503
def texequation(lines)
@texblockequation += 1
puts %Q[<replace idref="texblock-#{@texblockequation}">]
puts '<pre>'
puts "#{lines.join("\n")}"
puts '</pre>'
puts '</replace>'
end
|
#text(str) ⇒ Object
1091
1092
1093
|
# File 'lib/review/idgxmlbuilder.rb', line 1091
def text(str)
str
end
|
620
621
622
|
# File 'lib/review/idgxmlbuilder.rb', line 620
def th(str)
%Q[<?dtp tablerow header?>#{str}]
end
|
#tip(lines, caption = nil) ⇒ Object
927
928
929
|
# File 'lib/review/idgxmlbuilder.rb', line 927
def tip(lines, caption = nil)
captionblock("tip", lines, caption)
end
|
616
617
618
|
# File 'lib/review/idgxmlbuilder.rb', line 616
def tr(rows)
puts %Q[<tr>#{rows.join("\t")}</tr>]
end
|
#trputs(tablewidth, rows, cellwidth, sepidx) ⇒ Object
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
# File 'lib/review/idgxmlbuilder.rb', line 588
def trputs(tablewidth, rows, cellwidth, sepidx)
sepidx = 0 if sepidx.nil?
if tablewidth.nil?
lastline = rows.pop
rows.each {|row| puts %Q[<tr>#{row}</tr>] }
puts %Q[<tr type="lastline">#{lastline}</tr>] unless lastline.nil?
else
rows.each_with_index do |row, y|
i = 0
row.split(/\t/).each_with_index do |cell, x|
print %Q[<td xyh="#{x + 1},#{y + 1 + sepidx},#{sepidx}" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
i += 1
end
end
end
end
|
#tsize(str) ⇒ Object
1054
1055
1056
|
# File 'lib/review/idgxmlbuilder.rb', line 1054
def tsize(str)
@tsize = str
end
|
213
214
215
216
217
|
# File 'lib/review/idgxmlbuilder.rb', line 213
def ul_begin
level = block_given? ? yield : ""
level = nil if level == 1
puts "<ul#{level == 1 ? nil : level}>"
end
|
247
248
249
250
251
|
# File 'lib/review/idgxmlbuilder.rb', line 247
def ul_end
level = block_given? ? yield : ""
level = nil if level == 1
puts "</ul#{level}>"
end
|
#ul_item(lines) ⇒ Object
219
220
221
|
# File 'lib/review/idgxmlbuilder.rb', line 219
def ul_item(lines)
puts %Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>)
end
|
#ul_item_begin(lines) ⇒ Object
223
224
225
|
# File 'lib/review/idgxmlbuilder.rb', line 223
def ul_item_begin(lines)
print %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
end
|
#ul_item_end ⇒ Object
227
228
229
|
# File 'lib/review/idgxmlbuilder.rb', line 227
def ul_item_end
puts "</li>"
end
|
#warn(msg) ⇒ Object
102
103
104
105
106
107
108
109
|
# File 'lib/review/idgxmlbuilder.rb', line 102
def warn(msg)
if @no_error
@warns.push [@location.filename, @location.lineno, msg]
puts "----WARNING: #{escape_html(msg)}----"
else
$stderr.puts "#{@location}: warning: #{msg}"
end
end
|
#warning_messages ⇒ Object
134
135
136
137
138
139
140
141
142
|
# File 'lib/review/idgxmlbuilder.rb', line 134
def warning_messages
return '' if @warns.empty?
"<h2>Warnings</h2>\n" +
"<ul>\n" +
@warns.map {|file, line, msg|
"<li>#{escape_html(file)}:#{line}: #{escape_html(msg)}</li>\n"
}.join('') +
"</ul>\n"
end
|
#world_begin(level, label, caption) ⇒ Object
839
840
841
|
# File 'lib/review/idgxmlbuilder.rb', line 839
def world_begin(level, label, caption)
common_column_begin("world", caption)
end
|
#world_end(level) ⇒ Object
843
844
845
|
# File 'lib/review/idgxmlbuilder.rb', line 843
def world_end(level)
common_column_end("world")
end
|
#xcolumn_begin(level, label, caption) ⇒ Object
831
832
833
|
# File 'lib/review/idgxmlbuilder.rb', line 831
def xcolumn_begin(level, label, caption)
common_column_begin("x", caption)
end
|
#xcolumn_end(level) ⇒ Object
835
836
837
|
# File 'lib/review/idgxmlbuilder.rb', line 835
def xcolumn_end(level)
common_column_end("x")
end
|