Class: ReVIEW::IDGXMLBuilder
Constant Summary
Constants included
from HTMLUtils
HTMLUtils::ESC
Constants inherited
from Builder
Builder::CAPTION_TITLES
Instance Attribute Summary
Attributes inherited from Builder
#doc_status
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
-
#blankline ⇒ 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(lines, comment = nil) ⇒ 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
-
#emtable(lines, caption = nil) ⇒ 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
-
#imgtable(lines, id, caption = nil, metric = nil) ⇒ Object
-
#important(lines, caption = nil) ⇒ Object
-
#indepimage(_lines, 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_chap(chapter, id) ⇒ Object
-
#inline_comment(str) ⇒ Object
-
#inline_dtp(str) ⇒ Object
-
#inline_eq(id) ⇒ 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
-
#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
-
#nodisp_begin(level, label, caption) ⇒ Object
-
#nodisp_end(level) ⇒ 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
-
#notoc_begin(level, _label, caption) ⇒ Object
-
#notoc_end(level) ⇒ 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
-
#puts(arg) ⇒ 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, id = nil, caption = '') ⇒ Object
-
#text(str) ⇒ Object
-
#th(str) ⇒ Object
-
#tip(lines, caption = nil) ⇒ Object
-
#tr(rows) ⇒ Object
-
#trputs(tablewidth, rows, cellwidth, sepidx) ⇒ Object
-
#ul_begin ⇒ Object
-
#ul_end ⇒ Object
-
#ul_item_begin(lines) ⇒ Object
-
#ul_item_end ⇒ Object
-
#warning(lines, caption = nil) ⇒ 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, #escape_comment, #highlight, #highlight?, #highlight_pygments, #highlight_rouge, #normalize_id, #strip_html, #unescape
Methods included from TextUtils
#detab, #split_paragraph
Methods inherited from Builder
#bind, #compile_inline, #detab, #embed, #error, #escape, #extract_chapter_id, #firstlinenum, #get_chap, #graph, #graph_aafigure, #graph_blockdiag, #graph_gnuplot, #graph_graphviz, #graph_plantuml, #image, #initialize, #inline_column, #inline_embed, #inline_hd, #inline_href, #inline_include, #inline_kw, #inline_ruby, #inline_tcy, #inline_w, #inline_wb, #line_num, #list, #listnum, #load_words, #over_secnolevel?, #parse_metric, #print, #raw, #source, #system_graph, #target_name, #tsize, #unescape, #warn
Instance Method Details
#best(lines, caption = nil) ⇒ Object
910
911
912
|
# File 'lib/review/idgxmlbuilder.rb', line 910
def best(lines, caption = nil)
captionblock('best', lines, caption)
end
|
#bibpaper(lines, id, caption) ⇒ Object
1129
1130
1131
1132
1133
|
# File 'lib/review/idgxmlbuilder.rb', line 1129
def bibpaper(lines, id, caption)
id, caption
bibpaper_bibpaper id, caption, lines unless lines.empty?
puts '</bibitem>'
end
|
#bibpaper_bibpaper(_id, _caption, lines) ⇒ Object
1140
1141
1142
|
# File 'lib/review/idgxmlbuilder.rb', line 1140
def bibpaper_bibpaper(_id, _caption, lines)
print split_paragraph(lines).join
end
|
1135
1136
1137
1138
|
# File 'lib/review/idgxmlbuilder.rb', line 1135
def (id, caption)
puts %Q(<bibitem id="bib-#{id}">)
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>" if caption.present?
end
|
#blankline ⇒ Object
756
757
758
|
# File 'lib/review/idgxmlbuilder.rb', line 756
def blankline
puts '<p/>'
end
|
#box(lines, caption = nil) ⇒ Object
1007
1008
1009
|
# File 'lib/review/idgxmlbuilder.rb', line 1007
def box(lines, caption = nil)
syntaxblock('box', lines, caption)
end
|
#bpo(lines) ⇒ Object
1038
1039
1040
|
# File 'lib/review/idgxmlbuilder.rb', line 1038
def bpo(lines)
puts %Q(<bpo>#{lines.join("\n")}</bpo>)
end
|
#captionblock(type, lines, caption, specialstyle = nil) ⇒ Object
882
883
884
885
886
887
888
|
# File 'lib/review/idgxmlbuilder.rb', line 882
def captionblock(type, lines, caption, specialstyle = nil)
print "<#{type}>"
style = specialstyle.nil? ? "#{type}-title" : specialstyle
puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" if caption.present?
blocked_lines = split_paragraph(lines)
puts "#{blocked_lines.join}</#{type}>"
end
|
#caution(lines, caption = nil) ⇒ Object
922
923
924
|
# File 'lib/review/idgxmlbuilder.rb', line 922
def caution(lines, caption = nil)
captionblock('caution', lines, caption)
end
|
#centering(lines) ⇒ Object
878
879
880
|
# File 'lib/review/idgxmlbuilder.rb', line 878
def centering(lines)
puts split_paragraph(lines).join.gsub('<p>', %Q(<p align='center'>))
end
|
#choice_multi_begin ⇒ Object
179
180
181
|
# File 'lib/review/idgxmlbuilder.rb', line 179
def choice_multi_begin
puts %Q(<choice type='multi'>)
end
|
#choice_multi_end ⇒ Object
187
188
189
|
# File 'lib/review/idgxmlbuilder.rb', line 187
def choice_multi_end
puts '</choice>'
end
|
#choice_single_begin ⇒ Object
175
176
177
|
# File 'lib/review/idgxmlbuilder.rb', line 175
def choice_single_begin
puts %Q(<choice type='single'>)
end
|
#choice_single_end ⇒ Object
183
184
185
|
# File 'lib/review/idgxmlbuilder.rb', line 183
def choice_single_end
puts '</choice>'
end
|
#circle_begin(_level, _label, caption) ⇒ Object
784
785
786
|
# File 'lib/review/idgxmlbuilder.rb', line 784
def circle_begin(_level, _label, caption)
puts %Q(<title aid:pstyle="smallcircle">•#{compile_inline(caption)}</title>)
end
|
#circle_end(level) ⇒ Object
788
789
|
# File 'lib/review/idgxmlbuilder.rb', line 788
def circle_end(level)
end
|
#cmd(lines, caption = nil) ⇒ Object
335
336
337
|
# File 'lib/review/idgxmlbuilder.rb', line 335
def cmd(lines, caption = nil)
quotedlist lines, 'cmd', caption
end
|
#codelines_body(lines) ⇒ Object
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
# File 'lib/review/idgxmlbuilder.rb', line 281
def codelines_body(lines)
no = 1
lines.each do |line|
if @book.config['listinfo']
print %Q(<listinfo line="#{no}")
print %Q( begin="1") if no == 1
print %Q( end="#{no}") if no == lines.size
print '>'
end
print detab(line)
print "\n"
print '</listinfo>' if @book.config['listinfo']
no += 1
end
end
|
#column_begin(_level, _label, caption) ⇒ Object
802
803
804
|
# File 'lib/review/idgxmlbuilder.rb', line 802
def column_begin(_level, _label, caption)
common_column_begin('', caption)
end
|
#column_end(_level) ⇒ Object
806
807
808
|
# File 'lib/review/idgxmlbuilder.rb', line 806
def column_end(_level)
common_column_end('')
end
|
585
586
587
588
589
590
591
|
# File 'lib/review/idgxmlbuilder.rb', line 585
def (lines, = nil)
return unless @book.config['draft']
lines ||= []
lines.unshift escape() unless .blank?
str = lines.join("\n")
print "<msg>#{str}</msg>"
end
|
#common_column_begin(type, caption) ⇒ Object
791
792
793
794
795
796
|
# File 'lib/review/idgxmlbuilder.rb', line 791
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><?dtp level="9" section="#{escape(compile_inline(caption))}"?>)
end
|
#common_column_end(type) ⇒ Object
798
799
800
|
# File 'lib/review/idgxmlbuilder.rb', line 798
def common_column_end(type)
puts "</#{type}column>"
end
|
#compile_href(url, label) ⇒ Object
630
631
632
|
# File 'lib/review/idgxmlbuilder.rb', line 630
def compile_href(url, label)
%Q(<a linkurl='#{escape(url)}'>#{label.nil? ? escape(url) : escape(label)}</a>)
end
|
#compile_kw(word, alt) ⇒ Object
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
# File 'lib/review/idgxmlbuilder.rb', line 615
def compile_kw(word, alt)
'<keyword>' +
if alt
then escape("#{word}(#{alt.strip})")
else escape(word)
end +
'</keyword>' +
%Q(<index value="#{escape(word)}" />) +
if alt
alt.split(/\s*,\s*/).collect! { |e| %Q(<index value="#{escape(e.strip)}" />) }.join
else
''
end
end
|
#compile_ruby(base, ruby) ⇒ Object
611
612
613
|
# File 'lib/review/idgxmlbuilder.rb', line 611
def compile_ruby(base, ruby)
%Q(<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape(base.strip)}</aid:rb><aid:rt>#{escape(ruby.strip)}</aid:rt></aid:ruby></GroupRuby>)
end
|
#dd(lines) ⇒ Object
224
225
226
|
# File 'lib/review/idgxmlbuilder.rb', line 224
def dd(lines)
puts "<dd>#{lines.join.chomp}</dd>"
end
|
216
217
218
|
# File 'lib/review/idgxmlbuilder.rb', line 216
def dl_begin
puts '<dl>'
end
|
228
229
230
|
# File 'lib/review/idgxmlbuilder.rb', line 228
def dl_end
puts '</dl>'
end
|
220
221
222
|
# File 'lib/review/idgxmlbuilder.rb', line 220
def dt(line)
puts "<dt>#{line}</dt>"
end
|
1030
1031
1032
|
# File 'lib/review/idgxmlbuilder.rb', line 1030
def dtp(str)
print %Q(<?dtp #{str} ?>)
end
|
#edition_begin(_level, _label, caption) ⇒ Object
834
835
836
|
# File 'lib/review/idgxmlbuilder.rb', line 834
def edition_begin(_level, _label, caption)
common_column_begin('edition', caption)
end
|
#edition_end(_level) ⇒ Object
838
839
840
|
# File 'lib/review/idgxmlbuilder.rb', line 838
def edition_end(_level)
common_column_end('edition')
end
|
#emlist(lines, caption = nil, _lang = nil) ⇒ Object
303
304
305
|
# File 'lib/review/idgxmlbuilder.rb', line 303
def emlist(lines, caption = nil, _lang = nil)
quotedlist lines, 'emlist', caption
end
|
#emlistnum(lines, caption = nil, _lang = nil) ⇒ Object
307
308
309
310
311
312
313
314
|
# File 'lib/review/idgxmlbuilder.rb', line 307
def emlistnum(lines, caption = nil, _lang = nil)
lines2 = []
first_line_num = line_num
lines.each_with_index do |line, i|
lines2 << detab(%Q(<span type='lineno'>) + (i + first_line_num).to_s.rjust(2) + ': </span>' + line)
end
quotedlist lines2, 'emlistnum', caption
end
|
#emtable(lines, caption = nil) ⇒ Object
568
569
570
|
# File 'lib/review/idgxmlbuilder.rb', line 568
def emtable(lines, caption = nil)
table(lines, nil, caption)
end
|
#expert(lines) ⇒ Object
970
971
972
|
# File 'lib/review/idgxmlbuilder.rb', line 970
def expert(lines)
captionblock('expert', lines, nil)
end
|
43
44
45
|
# File 'lib/review/idgxmlbuilder.rb', line 43
def extname
'.xml'
end
|
#flushright(lines) ⇒ Object
874
875
876
|
# File 'lib/review/idgxmlbuilder.rb', line 874
def flushright(lines)
puts split_paragraph(lines).join.gsub('<p>', %Q(<p align='right'>))
end
|
601
602
603
|
# File 'lib/review/idgxmlbuilder.rb', line 601
def (id, str)
end
|
#handle_metric(str) ⇒ Object
388
389
390
391
|
# File 'lib/review/idgxmlbuilder.rb', line 388
def handle_metric(str)
k, v = str.split('=', 2)
%Q(#{k}="#{v.sub(/\A["']/, '').sub(/["']\Z/, '')}")
end
|
#headline(level, label, caption) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/review/idgxmlbuilder.rb', line 93
def headline(level, label, caption)
case level
when 1
if @secttags
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}">) if @secttags
@section = 0
@subsection = 0
@subsubsection = 0
@subsubsubsection = 0
when 2
if @secttags
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}">) if @secttags
@subsection = 0
@subsubsection = 0
@subsubsubsection = 0
when 3
if @secttags
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}">) if @secttags
@subsubsection = 0
@subsubsubsection = 0
when 4
if @secttags
print '</sect4>' if @subsubsubsection > 0
print '</sect3>' if @subsubsection > 0
end
@subsubsection += 1
print %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) if @secttags
@subsubsubsection = 0
when 5
print '</sect4>' if @secttags && @subsubsubsection > 0
@subsubsubsection += 1
print %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) if @secttags
when 6 else
raise "caption level too deep or unsupported: #{level}"
end
prefix, _anchor = headline_prefix(level)
label = label.nil? ? '' : %Q( id="#{label}")
toccaption = escape(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
826
827
828
|
# File 'lib/review/idgxmlbuilder.rb', line 826
def hood_begin(_level, _label, caption)
common_column_begin('hood', caption)
end
|
#hood_end(_level) ⇒ Object
830
831
832
|
# File 'lib/review/idgxmlbuilder.rb', line 830
def hood_end(_level)
common_column_end('hood')
end
|
1034
1035
1036
|
# File 'lib/review/idgxmlbuilder.rb', line 1034
def hr
print '<hr />'
end
|
#image_dummy(id, caption, lines) ⇒ Object
405
406
407
408
409
410
411
412
413
414
415
416
|
# File 'lib/review/idgxmlbuilder.rb', line 405
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 '</pre>'
id, caption
puts '</img>'
warn "image not bound: #{id}"
end
|
#image_ext ⇒ Object
1170
1171
1172
|
# File 'lib/review/idgxmlbuilder.rb', line 1170
def image_ext
'eps'
end
|
418
419
420
421
422
423
424
425
|
# File 'lib/review/idgxmlbuilder.rb', line 418
def (id, caption)
return true unless caption.present?
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
397
398
399
400
401
402
403
|
# File 'lib/review/idgxmlbuilder.rb', line 397
def image_image(id, caption, metric = nil)
metrics = parse_metric('idgxml', metric)
puts '<img>'
puts %Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A./}, '')}"#{metrics} />)
id, caption
puts '</img>'
end
|
#imgtable(lines, id, caption = nil, metric = nil) ⇒ Object
572
573
574
575
576
577
578
579
580
581
582
583
|
# File 'lib/review/idgxmlbuilder.rb', line 572
def imgtable(lines, id, caption = nil, metric = nil)
if @chapter.image(id).bound?
metrics = parse_metric('idgxml', metric)
puts '<table>'
id, caption if caption.present?
puts %Q(<imgtable><Image href="file://#{@chapter.image(id).path.sub(%r{\A./}, '')}"#{metrics} /></imgtable>)
puts '</table>'
else
warn "image not bound: #{id}" if @strict
image_dummy id, caption, lines
end
end
|
#important(lines, caption = nil) ⇒ Object
914
915
916
|
# File 'lib/review/idgxmlbuilder.rb', line 914
def important(lines, caption = nil)
captionblock('important', lines, caption)
end
|
#indepimage(_lines, id, caption = nil, metric = nil) ⇒ Object
Also known as:
numberlessimage
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
|
# File 'lib/review/idgxmlbuilder.rb', line 1011
def indepimage(_lines, id, caption = nil, metric = nil)
metrics = parse_metric('idgxml', metric)
puts '<img>'
begin
puts %Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A\./}, '')}"#{metrics} />)
rescue
warn %Q(image not bound: #{id})
end
puts %Q(<caption>#{compile_inline(caption)}</caption>) if caption.present?
puts '</img>'
end
|
#info(lines, caption = nil) ⇒ Object
902
903
904
|
# File 'lib/review/idgxmlbuilder.rb', line 902
def info(lines, caption = nil)
captionblock('info', lines, caption)
end
|
#inline_ami(str) ⇒ Object
682
683
684
|
# File 'lib/review/idgxmlbuilder.rb', line 682
def inline_ami(str)
%Q(<ami>#{escape(str)}</ami>)
end
|
#inline_b(str) ⇒ Object
690
691
692
|
# File 'lib/review/idgxmlbuilder.rb', line 690
def inline_b(str)
%Q(<b>#{escape(str)}</b>)
end
|
#inline_balloon(str) ⇒ Object
739
740
741
|
# File 'lib/review/idgxmlbuilder.rb', line 739
def inline_balloon(str)
%Q(<balloon>#{escape(str).gsub(/@maru\[(\d+)\]/) { inline_maru($1) }}</balloon>)
end
|
#inline_bib(id) ⇒ Object
1144
1145
1146
1147
1148
|
# File 'lib/review/idgxmlbuilder.rb', line 1144
def inline_bib(id)
%Q(<span type='bibref' idref='#{id}'>[#{@chapter.bibpaper(id).number}]</span>)
rescue KeyError
error "unknown bib: #{id}"
end
|
#inline_bou(str) ⇒ Object
721
722
723
|
# File 'lib/review/idgxmlbuilder.rb', line 721
def inline_bou(str)
%Q(<bou>#{escape(str)}</bou>)
end
|
#inline_br(_str) ⇒ Object
1050
1051
1052
|
# File 'lib/review/idgxmlbuilder.rb', line 1050
def inline_br(_str)
"\n"
end
|
#inline_chap(id) ⇒ Object
1097
1098
1099
1100
1101
1102
1103
1104
1105
|
# File 'lib/review/idgxmlbuilder.rb', line 1097
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}"
end
|
#inline_chapref(id) ⇒ Object
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
|
# File 'lib/review/idgxmlbuilder.rb', line 1067
def inline_chapref(id)
if @book.config.check_version('2', exception: false)
chs = ['', '「', '」']
if @book.config['chapref']
chs2 = @book.config['chapref'].split(',')
if chs2.size != 3
error '--chapsplitter must have exactly 3 parameters with comma.'
else
chs = chs2
end
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
else
title = super
if @book.config['chapterlink']
%Q(<link href="#{id}">#{title}</link>)
else
title
end
end
rescue KeyError
error "unknown chapter: #{id}"
end
|
#inline_code(str) ⇒ Object
1046
1047
1048
|
# File 'lib/review/idgxmlbuilder.rb', line 1046
def inline_code(str)
%Q(<tt type='inline-code'>#{escape(str)}</tt>)
end
|
#inline_column_chap(chapter, id) ⇒ Object
257
258
259
260
261
262
263
264
265
|
# File 'lib/review/idgxmlbuilder.rb', line 257
def inline_column_chap(chapter, id)
if @book.config['chapterlink']
%Q(<link href="#{column_label(id, chapter)}">#{I18n.t('column', compile_inline(chapter.column(id).caption))}</link>)
else
I18n.t('column', compile_inline(chapter.column(id).caption))
end
rescue KeyError
error "unknown column: #{id}"
end
|
593
594
595
596
597
598
599
|
# File 'lib/review/idgxmlbuilder.rb', line 593
def (str)
if @book.config['draft']
%Q(<msg>#{escape(str)}</msg>)
else
''
end
end
|
#inline_dtp(str) ⇒ Object
1042
1043
1044
|
# File 'lib/review/idgxmlbuilder.rb', line 1042
def inline_dtp(str)
"<?dtp #{str} ?>"
end
|
#inline_eq(id) ⇒ Object
373
374
375
|
# File 'lib/review/idgxmlbuilder.rb', line 373
def inline_eq(id)
"<span type='eq'>#{super(id)}</span>"
end
|
#inline_fn(id) ⇒ Object
605
606
607
608
609
|
# File 'lib/review/idgxmlbuilder.rb', line 605
def inline_fn(id)
%Q(<footnote>#{compile_inline(@chapter.(id).content.strip)}</footnote>)
rescue KeyError
error "unknown footnote: #{id}"
end
|
#inline_hd_chap(chap, id) ⇒ Object
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
|
# File 'lib/review/idgxmlbuilder.rb', line 1150
def inline_hd_chap(chap, id)
n = chap.headline_index.number(id)
if n.present? && chap.number && over_secnolevel?(n)
I18n.t('hd_quote', [n, compile_inline(chap.headline(id).caption)])
else
I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
end
rescue KeyError
error "unknown headline: #{id}"
end
|
#inline_hidx(str) ⇒ Object
678
679
680
|
# File 'lib/review/idgxmlbuilder.rb', line 678
def inline_hidx(str)
%Q(<index value="#{escape(str)}" />)
end
|
#inline_hint(str) ⇒ Object
646
647
648
649
650
651
652
|
# File 'lib/review/idgxmlbuilder.rb', line 646
def inline_hint(str)
if @book.config['nolf']
%Q(<hint>#{escape(str)}</hint>)
else
%Q(\n<hint>#{escape(str)}</hint>)
end
end
|
#inline_i(str) ⇒ Object
686
687
688
|
# File 'lib/review/idgxmlbuilder.rb', line 686
def inline_i(str)
%Q(<i>#{escape(str)}</i>)
end
|
#inline_icon(id) ⇒ Object
712
713
714
715
716
717
718
719
|
# File 'lib/review/idgxmlbuilder.rb', line 712
def inline_icon(id)
begin
%Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A\./}, '')}" type="inline" />)
rescue
warn "image not bound: #{id}"
''
end
end
|
#inline_idx(str) ⇒ Object
674
675
676
|
# File 'lib/review/idgxmlbuilder.rb', line 674
def inline_idx(str)
%Q(#{escape(str)}<index value="#{escape(str)}" />)
end
|
#inline_img(id) ⇒ Object
369
370
371
|
# File 'lib/review/idgxmlbuilder.rb', line 369
def inline_img(id)
"<span type='image'>#{super(id)}</span>"
end
|
#inline_imgref(id) ⇒ Object
377
378
379
380
381
382
383
384
385
386
|
# File 'lib/review/idgxmlbuilder.rb', line 377
def inline_imgref(id)
chapter, id = (id)
if chapter.image(id).caption.blank?
inline_img(id)
elsif 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
|
#inline_keytop(str) ⇒ Object
725
726
727
|
# File 'lib/review/idgxmlbuilder.rb', line 725
def inline_keytop(str)
%Q(<keytop>#{escape(str)}</keytop>)
end
|
#inline_labelref(idref) ⇒ Object
Also known as:
inline_ref
729
730
731
|
# File 'lib/review/idgxmlbuilder.rb', line 729
def inline_labelref(idref)
%Q(<ref idref='#{escape(idref)}'>「#{I18n.t('label_marker')}#{escape(idref)}」</ref>) end
|
#inline_list(id) ⇒ Object
267
268
269
|
# File 'lib/review/idgxmlbuilder.rb', line 267
def inline_list(id)
"<span type='list'>#{super(id)}</span>"
end
|
#inline_m(str) ⇒ Object
747
748
749
750
|
# File 'lib/review/idgxmlbuilder.rb', line 747
def inline_m(str)
@texinlineequation += 1
%Q(<replace idref="texinline-#{@texinlineequation}"><pre>#{escape(str)}</pre></replace>)
end
|
#inline_maru(str) ⇒ Object
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
|
# File 'lib/review/idgxmlbuilder.rb', line 654
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
error "can't parse maru: #{str}"
end
end
|
735
736
737
|
# File 'lib/review/idgxmlbuilder.rb', line 735
def (idref)
%Q(<pageref idref='#{escape(idref)}'>●●</pageref>) end
|
#inline_raw(str) ⇒ Object
642
643
644
|
# File 'lib/review/idgxmlbuilder.rb', line 642
def inline_raw(str)
super(str).gsub('\\n', "\n")
end
|
#inline_recipe(id) ⇒ Object
1161
1162
1163
1164
|
# File 'lib/review/idgxmlbuilder.rb', line 1161
def inline_recipe(id)
%Q(<recipe idref="#{escape(id)}">[XXX]「#{escape(id)}」 p.XX</recipe>)
end
|
#inline_sub(str) ⇒ Object
638
639
640
|
# File 'lib/review/idgxmlbuilder.rb', line 638
def inline_sub(str)
%Q(<sub>#{escape(str)}</sub>)
end
|
#inline_sup(str) ⇒ Object
634
635
636
|
# File 'lib/review/idgxmlbuilder.rb', line 634
def inline_sup(str)
%Q(<sup>#{escape(str)}</sup>)
end
|
#inline_table(id) ⇒ Object
365
366
367
|
# File 'lib/review/idgxmlbuilder.rb', line 365
def inline_table(id)
"<span type='table'>#{super(id)}</span>"
end
|
#inline_title(id) ⇒ Object
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
|
# File 'lib/review/idgxmlbuilder.rb', line 1107
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}"
end
|
#inline_tt(str) ⇒ Object
694
695
696
|
# File 'lib/review/idgxmlbuilder.rb', line 694
def inline_tt(str)
%Q(<tt>#{escape(str)}</tt>)
end
|
#inline_ttb(str) ⇒ Object
Also known as:
inline_ttbold
698
699
700
|
# File 'lib/review/idgxmlbuilder.rb', line 698
def inline_ttb(str)
%Q(<tt style='bold'>#{escape(str)}</tt>)
end
|
#inline_tti(str) ⇒ Object
704
705
706
|
# File 'lib/review/idgxmlbuilder.rb', line 704
def inline_tti(str)
%Q(<tt style='italic'>#{escape(str)}</tt>)
end
|
#inline_u(str) ⇒ Object
708
709
710
|
# File 'lib/review/idgxmlbuilder.rb', line 708
def inline_u(str)
%Q(<underline>#{escape(str)}</underline>)
end
|
#inline_uchar(str) ⇒ Object
743
744
745
|
# File 'lib/review/idgxmlbuilder.rb', line 743
def inline_uchar(str)
%Q(&#x#{str};)
end
|
#insideout_begin(_level, _label, caption) ⇒ Object
842
843
844
|
# File 'lib/review/idgxmlbuilder.rb', line 842
def insideout_begin(_level, _label, caption)
common_column_begin('insideout', caption)
end
|
#insideout_end(_level) ⇒ Object
846
847
848
|
# File 'lib/review/idgxmlbuilder.rb', line 846
def insideout_end(_level)
common_column_end('insideout')
end
|
#insn(lines, caption = nil) ⇒ Object
1003
1004
1005
|
# File 'lib/review/idgxmlbuilder.rb', line 1003
def insn(lines, caption = nil)
syntaxblock('insn', lines, caption)
end
|
#label(id) ⇒ Object
1025
1026
1027
1028
|
# File 'lib/review/idgxmlbuilder.rb', line 1025
def label(id)
print "<label id='#{id}' />"
end
|
#link(lines, caption = nil) ⇒ Object
934
935
936
|
# File 'lib/review/idgxmlbuilder.rb', line 934
def link(lines, caption = nil)
captionblock('link', lines, caption)
end
|
#list_body(_id, lines, _lang) ⇒ Object
297
298
299
300
301
|
# File 'lib/review/idgxmlbuilder.rb', line 297
def list_body(_id, lines, _lang)
print '<pre>'
codelines_body(lines)
puts '</pre></codelist>'
end
|
271
272
273
274
275
276
277
278
279
|
# File 'lib/review/idgxmlbuilder.rb', line 271
def (id, caption, _lang)
puts '<codelist>'
return true unless caption.present?
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
# File 'lib/review/idgxmlbuilder.rb', line 316
def listnum_body(lines, _lang)
print '<pre>'
no = 1
first_line_num = line_num
lines.each_with_index do |line, i|
if @book.config['listinfo']
print %Q(<listinfo line="#{no}")
print %Q( begin="1") if no == 1
print %Q( end="#{no}") if no == lines.size
print '>'
end
print detab(%Q(<span type='lineno'>) + (i + first_line_num).to_s.rjust(2) + ': </span>' + line)
print "\n"
print '</listinfo>' if @book.config['listinfo']
no += 1
end
puts '</pre></codelist>'
end
|
#memo(lines, caption = nil) ⇒ Object
894
895
896
|
# File 'lib/review/idgxmlbuilder.rb', line 894
def memo(lines, caption = nil)
captionblock('memo', lines, caption)
end
|
#nodisp_begin(level, label, caption) ⇒ Object
778
779
|
# File 'lib/review/idgxmlbuilder.rb', line 778
def nodisp_begin(level, label, caption)
end
|
#nodisp_end(level) ⇒ Object
781
782
|
# File 'lib/review/idgxmlbuilder.rb', line 781
def nodisp_end(level)
end
|
#nofunc_text(str) ⇒ Object
1166
1167
1168
|
# File 'lib/review/idgxmlbuilder.rb', line 1166
def nofunc_text(str)
escape(str)
end
|
752
753
754
|
# File 'lib/review/idgxmlbuilder.rb', line 752
def noindent
@noindent = true
end
|
#nonum_begin(level, _label, caption) ⇒ Object
764
765
766
|
# File 'lib/review/idgxmlbuilder.rb', line 764
def nonum_begin(level, _label, caption)
puts %Q(<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{escape(compile_inline(caption))}"?>)
end
|
#nonum_end(level) ⇒ Object
768
769
|
# File 'lib/review/idgxmlbuilder.rb', line 768
def nonum_end(level)
end
|
#note(lines, caption = nil) ⇒ Object
890
891
892
|
# File 'lib/review/idgxmlbuilder.rb', line 890
def note(lines, caption = nil)
captionblock('note', lines, caption)
end
|
#notice(lines, caption = nil) ⇒ Object
938
939
940
941
942
943
944
|
# File 'lib/review/idgxmlbuilder.rb', line 938
def notice(lines, caption = nil)
if caption
captionblock('notice-t', lines, caption, 'notice-title')
else
captionblock('notice', lines, nil)
end
end
|
#notoc_begin(level, _label, caption) ⇒ Object
771
772
773
|
# File 'lib/review/idgxmlbuilder.rb', line 771
def notoc_begin(level, _label, caption)
puts %Q(<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title>)
end
|
#notoc_end(level) ⇒ Object
775
776
|
# File 'lib/review/idgxmlbuilder.rb', line 775
def notoc_end(level)
end
|
197
198
199
200
|
# File 'lib/review/idgxmlbuilder.rb', line 197
def ol_begin
puts '<ol>'
@ol_num ||= 1
end
|
207
208
209
210
|
# File 'lib/review/idgxmlbuilder.rb', line 207
def ol_end
puts '</ol>'
@ol_num = nil
end
|
#ol_item(lines, num) ⇒ Object
202
203
204
205
|
# File 'lib/review/idgxmlbuilder.rb', line 202
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
212
213
214
|
# File 'lib/review/idgxmlbuilder.rb', line 212
def olnum(num)
@ol_num = num.to_i
end
|
#pagebreak ⇒ Object
760
761
762
|
# File 'lib/review/idgxmlbuilder.rb', line 760
def pagebreak
puts '<pagebreak />'
end
|
#paragraph(lines) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
|
# File 'lib/review/idgxmlbuilder.rb', line 232
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
906
907
908
|
# File 'lib/review/idgxmlbuilder.rb', line 906
def planning(lines, caption = nil)
captionblock('planning', lines, caption)
end
|
#point(lines, caption = nil) ⇒ Object
946
947
948
949
950
951
952
|
# File 'lib/review/idgxmlbuilder.rb', line 946
def point(lines, caption = nil)
if caption
captionblock('point-t', lines, caption, 'point-title')
else
captionblock('point', lines, nil)
end
end
|
#post_paragraph ⇒ Object
39
40
41
|
# File 'lib/review/idgxmlbuilder.rb', line 39
def post_paragraph
'</p>'
end
|
#practice(lines) ⇒ Object
966
967
968
|
# File 'lib/review/idgxmlbuilder.rb', line 966
def practice(lines)
captionblock('practice', lines, nil)
end
|
#pre_paragraph ⇒ Object
35
36
37
|
# File 'lib/review/idgxmlbuilder.rb', line 35
def pre_paragraph
'<p>'
end
|
#puts(arg) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/review/idgxmlbuilder.rb', line 73
def puts(arg)
if @book.config['nolf'].present?
print arg
else
super
end
end
|
#quote(lines) ⇒ Object
360
361
362
363
|
# File 'lib/review/idgxmlbuilder.rb', line 360
def quote(lines)
blocked_lines = split_paragraph(lines)
puts "<quote>#{blocked_lines.join}</quote>"
end
|
#rawblock(lines) ⇒ Object
1054
1055
1056
1057
1058
1059
1060
1061
|
# File 'lib/review/idgxmlbuilder.rb', line 1054
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
245
246
247
|
# File 'lib/review/idgxmlbuilder.rb', line 245
def read(lines)
puts %Q(<lead>#{split_paragraph(lines).join}</lead>)
end
|
#ref_begin(_level, label, _caption) ⇒ Object
850
851
852
853
854
855
856
|
# File 'lib/review/idgxmlbuilder.rb', line 850
def ref_begin(_level, label, _caption)
if label
puts "<reference id='#{label}'>"
else
puts '<reference>'
end
end
|
#ref_end(_level) ⇒ Object
858
859
860
|
# File 'lib/review/idgxmlbuilder.rb', line 858
def ref_end(_level)
puts '</reference>'
end
|
#reference(lines) ⇒ Object
962
963
964
|
# File 'lib/review/idgxmlbuilder.rb', line 962
def reference(lines)
captionblock('reference', lines, nil)
end
|
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/review/idgxmlbuilder.rb', line 81
def result
s = ''
if @secttags
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
@output.string + s + "</#{@rootelement}>\n"
end
|
#result_metric(array) ⇒ Object
393
394
395
|
# File 'lib/review/idgxmlbuilder.rb', line 393
def result_metric(array)
" #{array.join(' ')}"
end
|
#security(lines, caption = nil) ⇒ Object
918
919
920
|
# File 'lib/review/idgxmlbuilder.rb', line 918
def security(lines, caption = nil)
captionblock('security', lines, caption)
end
|
#shoot(lines, caption = nil) ⇒ Object
954
955
956
957
958
959
960
|
# File 'lib/review/idgxmlbuilder.rb', line 954
def shoot(lines, caption = nil)
if caption
captionblock('shoot-t', lines, caption, 'shoot-title')
else
captionblock('shoot', lines, nil)
end
end
|
#source_body(lines, _lang) ⇒ Object
1123
1124
1125
1126
1127
|
# File 'lib/review/idgxmlbuilder.rb', line 1123
def source_body(lines, _lang)
puts '<pre>'
codelines_body(lines)
puts '</pre></source>'
end
|
1118
1119
1120
1121
|
# File 'lib/review/idgxmlbuilder.rb', line 1118
def (caption)
puts '<source>'
puts %Q(<caption>#{compile_inline(caption)}</caption>) if caption.present?
end
|
#sup_begin(_level, label, _caption) ⇒ Object
862
863
864
865
866
867
868
|
# File 'lib/review/idgxmlbuilder.rb', line 862
def sup_begin(_level, label, _caption)
if label
puts "<supplement id='#{label}'>"
else
puts '<supplement>'
end
end
|
#sup_end(_level) ⇒ Object
870
871
872
|
# File 'lib/review/idgxmlbuilder.rb', line 870
def sup_end(_level)
puts '</supplement>'
end
|
#syntaxblock(type, lines, caption) ⇒ Object
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
|
# File 'lib/review/idgxmlbuilder.rb', line 974
def syntaxblock(type, lines, caption)
if caption.present?
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}>)
else
puts "<#{type}>"
end
no = 1
lines.each do |line|
if @book.config['listinfo']
print %Q(<listinfo line="#{no}")
print %Q( begin="1") if no == 1
print %Q( end="#{no}") if no == lines.size
print '>'
end
print detab(line)
print "\n"
print '</listinfo>' if @book.config['listinfo']
no += 1
end
puts "</#{type}>"
end
|
#table(lines, id = nil, caption = nil) ⇒ Object
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
# File 'lib/review/idgxmlbuilder.rb', line 449
def table(lines, id = nil, caption = nil)
tablewidth = @book.config['tableopt'] ? @book.config['tableopt'].split(',')[0].to_f / @book.config['pt_to_mm_unit'].to_f : nil
col = 0
rows = []
sepidx = nil
lines.each_with_index do |line, idx|
if /\A[\=\-]{12}/ =~ line
sepidx ||= idx
next
end
if tablewidth
rows.push(line.gsub(/\t\.\t/, "\tDUMMYCELLSPLITTER\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\tDUMMYCELLSPLITTER").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ''))
else
rows.push(line.gsub(/\t\.\t/, "\t\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\t").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ''))
end
col2 = rows[rows.length - 1].split(/\t/).length
col = col2 if col2 > col
end
error 'no rows in the table' if rows.empty?
puts '<table>'
cellwidth = []
if tablewidth
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 / @book.config['pt_to_mm_unit'].to_f
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
(cellwidth.size..(col - 1)).each { |i| cellwidth[i] = cw }
end
end
end
begin
id, caption if caption.present?
rescue KeyError
error "no such table: #{id}"
end
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('%.3f', 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
549
550
|
# File 'lib/review/idgxmlbuilder.rb', line 549
def table_begin(ncols)
end
|
#table_end ⇒ Object
564
565
566
|
# File 'lib/review/idgxmlbuilder.rb', line 564
def table_end
print '<?dtp tablerow last?>'
end
|
539
540
541
542
543
544
545
546
547
|
# File 'lib/review/idgxmlbuilder.rb', line 539
def (id, caption)
if id.nil?
puts %Q(<caption>#{compile_inline(caption)}</caption>)
elsif get_chap
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>)
else
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>)
end
end
|
560
561
562
|
# File 'lib/review/idgxmlbuilder.rb', line 560
def td(str)
str
end
|
#term(lines) ⇒ Object
930
931
932
|
# File 'lib/review/idgxmlbuilder.rb', line 930
def term(lines)
captionblock('term', lines, nil)
end
|
#texequation(lines, id = nil, caption = '') ⇒ Object
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
# File 'lib/review/idgxmlbuilder.rb', line 427
def texequation(lines, id = nil, caption = '')
@texblockequation += 1
if id
puts '<equationblock>'
if get_chap.nil?
puts %Q(<caption>#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}</caption>)
else
puts %Q(<caption>#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}</caption>)
end
end
puts %Q(<replace idref="texblock-#{@texblockequation}">)
puts '<pre>'
puts lines.join("\n")
puts '</pre>'
puts '</replace>'
if id
puts '</equationblock>'
end
end
|
#text(str) ⇒ Object
1063
1064
1065
|
# File 'lib/review/idgxmlbuilder.rb', line 1063
def text(str)
str
end
|
556
557
558
|
# File 'lib/review/idgxmlbuilder.rb', line 556
def th(str)
%Q(<?dtp tablerow header?>#{str})
end
|
#tip(lines, caption = nil) ⇒ Object
898
899
900
|
# File 'lib/review/idgxmlbuilder.rb', line 898
def tip(lines, caption = nil)
captionblock('tip', lines, caption)
end
|
552
553
554
|
# File 'lib/review/idgxmlbuilder.rb', line 552
def tr(rows)
puts %Q(<tr>#{rows.join("\t")}</tr>)
end
|
#trputs(tablewidth, rows, cellwidth, sepidx) ⇒ Object
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
# File 'lib/review/idgxmlbuilder.rb', line 522
def trputs(tablewidth, rows, cellwidth, sepidx)
sepidx = 0 if sepidx.nil?
if tablewidth
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('%.3f', cellwidth[i])}">#{cell.sub('DUMMYCELLSPLITTER', '')}</td>)
i += 1
end
end
else
lastline = rows.pop
rows.each { |row| puts "<tr>#{row}</tr>" }
puts %Q(<tr type="lastline">#{lastline}</tr>) if lastline
end
end
|
161
162
163
164
165
|
# File 'lib/review/idgxmlbuilder.rb', line 161
def ul_begin
level = block_given? ? yield : ''
level = nil if level == 1
puts "<ul#{level == 1 ? nil : level}>"
end
|
191
192
193
194
195
|
# File 'lib/review/idgxmlbuilder.rb', line 191
def ul_end
level = block_given? ? yield : ''
level = nil if level == 1
puts "</ul#{level}>"
end
|
#ul_item_begin(lines) ⇒ Object
167
168
169
|
# File 'lib/review/idgxmlbuilder.rb', line 167
def ul_item_begin(lines)
print %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
end
|
#ul_item_end ⇒ Object
171
172
173
|
# File 'lib/review/idgxmlbuilder.rb', line 171
def ul_item_end
puts '</li>'
end
|
#warning(lines, caption = nil) ⇒ Object
926
927
928
|
# File 'lib/review/idgxmlbuilder.rb', line 926
def warning(lines, caption = nil)
captionblock('warning', lines, caption)
end
|
#world_begin(_level, _label, caption) ⇒ Object
818
819
820
|
# File 'lib/review/idgxmlbuilder.rb', line 818
def world_begin(_level, _label, caption)
common_column_begin('world', caption)
end
|
#world_end(_level) ⇒ Object
822
823
824
|
# File 'lib/review/idgxmlbuilder.rb', line 822
def world_end(_level)
common_column_end('world')
end
|
#xcolumn_begin(_level, _label, caption) ⇒ Object
810
811
812
|
# File 'lib/review/idgxmlbuilder.rb', line 810
def xcolumn_begin(_level, _label, caption)
common_column_begin('x', caption)
end
|
#xcolumn_end(_level) ⇒ Object
814
815
816
|
# File 'lib/review/idgxmlbuilder.rb', line 814
def xcolumn_end(_level)
common_column_end('x')
end
|