Class: ReVIEW::IDGXMLBuilder
Constant Summary
Constants inherited
from Builder
Builder::CAPTION_TITLES
Instance Attribute Summary
Attributes inherited from Builder
#doc_status, #location
Attributes included from Loggable
#logger
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
-
#endnote_begin ⇒ Object
-
#endnote_end ⇒ Object
-
#endnote_item(id) ⇒ 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_del(str) ⇒ Object
-
#inline_dtp(str) ⇒ Object
-
#inline_em(str) ⇒ Object
-
#inline_endnote(id) ⇒ 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_ins(str) ⇒ 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_strong(str) ⇒ 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(lines, id, caption, lang = nil) ⇒ Object
-
#list_body(_id, lines, _lang) ⇒ Object
-
#list_header(id, caption, _lang) ⇒ Object
-
#listnum(lines, id, caption, lang = nil) ⇒ 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
-
#output_close_sect_tags(level) ⇒ Object
-
#pagebreak ⇒ Object
-
#paragraph(lines) ⇒ Object
-
#parse_table_rows(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
-
#solve_nest(s) ⇒ Object
-
#source(lines, caption = nil, lang = 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
-
#table_rows(sepidx, rows) ⇒ 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
#add_space?, #detab, #join_lines_to_paragraph, #split_paragraph
Methods inherited from Builder
#beginchild, #bind, #caption_top?, #check_nest, #check_nested_minicolumn, #check_printendnotes, #compile_inline, #detab, #embed, #endchild, #endnote, #escape, #extract_chapter_id, #firstlinenum, #get_chap, #graph, #graph_aafigure, #graph_blockdiag, #graph_gnuplot, #graph_graphviz, #graph_mermaid, #graph_plantuml, #highlight?, #image, #in_minicolumn?, #initialize, #inline_column, #inline_embed, #inline_hd, #inline_href, #inline_include, #inline_kw, #inline_ruby, #inline_sec, #inline_sectitle, #inline_tcy, #inline_w, #inline_wb, #line_num, #load_words, #minicolumn_block_name?, #over_secnolevel?, #parse_metric, #previous_list_type, #print, #printendnotes, #raw, #system_graph, #table_row_separator_regexp, #target_name, #tsize
Methods included from Loggable
#app_error, #debug, #error, #error!, #warn
Instance Method Details
#best(lines, caption = nil) ⇒ Object
1022
1023
1024
|
# File 'lib/review/idgxmlbuilder.rb', line 1022
def best(lines, caption = nil)
captionblock('best', lines, caption)
end
|
#bibpaper(lines, id, caption) ⇒ Object
1296
1297
1298
1299
1300
1301
|
# File 'lib/review/idgxmlbuilder.rb', line 1296
def bibpaper(lines, id, caption)
puts %Q(<bibitem id="bib-#{id}">)
(id, caption)
bibpaper_bibpaper(id, caption, lines) unless lines.empty?
puts '</bibitem>'
end
|
#bibpaper_bibpaper(_id, _caption, lines) ⇒ Object
1307
1308
1309
|
# File 'lib/review/idgxmlbuilder.rb', line 1307
def bibpaper_bibpaper(_id, _caption, lines)
print split_paragraph(lines).join
end
|
1303
1304
1305
|
# File 'lib/review/idgxmlbuilder.rb', line 1303
def (id, caption)
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>" if caption.present?
end
|
#blankline ⇒ Object
864
865
866
|
# File 'lib/review/idgxmlbuilder.rb', line 864
def blankline
puts '<p/>'
end
|
#box(lines, caption = nil) ⇒ Object
1158
1159
1160
|
# File 'lib/review/idgxmlbuilder.rb', line 1158
def box(lines, caption = nil)
syntaxblock('box', lines, caption)
end
|
#bpo(lines) ⇒ Object
1194
1195
1196
|
# File 'lib/review/idgxmlbuilder.rb', line 1194
def bpo(lines)
puts %Q(<bpo>#{lines.join("\n")}</bpo>)
end
|
#captionblock(type, lines, caption, specialstyle = nil) ⇒ Object
990
991
992
993
994
995
996
|
# File 'lib/review/idgxmlbuilder.rb', line 990
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
1035
1036
1037
1038
|
# File 'lib/review/idgxmlbuilder.rb', line 1035
def caution(lines, caption = nil)
check_nested_minicolumn
captionblock('caution', lines, caption)
end
|
#centering(lines) ⇒ Object
986
987
988
|
# File 'lib/review/idgxmlbuilder.rb', line 986
def centering(lines)
puts split_paragraph(lines).join.gsub('<p>', %Q(<p align='center'>))
end
|
#choice_multi_begin ⇒ Object
187
188
189
|
# File 'lib/review/idgxmlbuilder.rb', line 187
def choice_multi_begin
puts %Q(<choice type='multi'>)
end
|
#choice_multi_end ⇒ Object
195
196
197
|
# File 'lib/review/idgxmlbuilder.rb', line 195
def choice_multi_end
puts '</choice>'
end
|
#choice_single_begin ⇒ Object
183
184
185
|
# File 'lib/review/idgxmlbuilder.rb', line 183
def choice_single_begin
puts %Q(<choice type='single'>)
end
|
#choice_single_end ⇒ Object
191
192
193
|
# File 'lib/review/idgxmlbuilder.rb', line 191
def choice_single_end
puts '</choice>'
end
|
#circle_begin(_level, _label, caption) ⇒ Object
892
893
894
|
# File 'lib/review/idgxmlbuilder.rb', line 892
def circle_begin(_level, _label, caption)
puts %Q(<title aid:pstyle="smallcircle">•#{compile_inline(caption)}</title>)
end
|
#circle_end(level) ⇒ Object
896
897
|
# File 'lib/review/idgxmlbuilder.rb', line 896
def circle_end(level)
end
|
#cmd(lines, caption = nil) ⇒ Object
355
356
357
|
# File 'lib/review/idgxmlbuilder.rb', line 355
def cmd(lines, caption = nil)
quotedlist(lines, 'cmd', caption)
end
|
#codelines_body(lines) ⇒ Object
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/review/idgxmlbuilder.rb', line 289
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
910
911
912
|
# File 'lib/review/idgxmlbuilder.rb', line 910
def column_begin(_level, _label, caption)
common_column_begin('', caption)
end
|
#column_end(_level) ⇒ Object
914
915
916
|
# File 'lib/review/idgxmlbuilder.rb', line 914
def column_end(_level)
common_column_end('')
end
|
650
651
652
653
654
655
656
657
|
# File 'lib/review/idgxmlbuilder.rb', line 650
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
899
900
901
902
903
904
|
# File 'lib/review/idgxmlbuilder.rb', line 899
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
906
907
908
|
# File 'lib/review/idgxmlbuilder.rb', line 906
def common_column_end(type)
puts "</#{type}column>"
end
|
#compile_href(url, label) ⇒ Object
715
716
717
|
# File 'lib/review/idgxmlbuilder.rb', line 715
def compile_href(url, label)
%Q(<a linkurl='#{escape(url)}'>#{label.nil? ? escape(url) : escape(label)}</a>)
end
|
#compile_kw(word, alt) ⇒ Object
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
|
# File 'lib/review/idgxmlbuilder.rb', line 699
def compile_kw(word, alt)
'<keyword>' +
if alt
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
695
696
697
|
# File 'lib/review/idgxmlbuilder.rb', line 695
def compile_ruby(base, ruby)
%Q(<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape(base)}</aid:rb><aid:rt>#{escape(ruby)}</aid:rt></aid:ruby></GroupRuby>)
end
|
#dd(lines) ⇒ Object
232
233
234
|
# File 'lib/review/idgxmlbuilder.rb', line 232
def dd(lines)
puts "<dd>#{join_lines_to_paragraph(lines).chomp}</dd>"
end
|
224
225
226
|
# File 'lib/review/idgxmlbuilder.rb', line 224
def dl_begin
puts '<dl>'
end
|
236
237
238
|
# File 'lib/review/idgxmlbuilder.rb', line 236
def dl_end
puts '</dl>'
end
|
228
229
230
|
# File 'lib/review/idgxmlbuilder.rb', line 228
def dt(line)
puts "<dt>#{line}</dt>"
end
|
1186
1187
1188
|
# File 'lib/review/idgxmlbuilder.rb', line 1186
def dtp(str)
print %Q(<?dtp #{str} ?>)
end
|
#edition_begin(_level, _label, caption) ⇒ Object
942
943
944
|
# File 'lib/review/idgxmlbuilder.rb', line 942
def edition_begin(_level, _label, caption)
common_column_begin('edition', caption)
end
|
#edition_end(_level) ⇒ Object
946
947
948
|
# File 'lib/review/idgxmlbuilder.rb', line 946
def edition_end(_level)
common_column_end('edition')
end
|
#emlist(lines, caption = nil, _lang = nil) ⇒ Object
317
318
319
|
# File 'lib/review/idgxmlbuilder.rb', line 317
def emlist(lines, caption = nil, _lang = nil)
quotedlist(lines, 'emlist', caption)
end
|
#emlistnum(lines, caption = nil, _lang = nil) ⇒ Object
321
322
323
324
325
326
327
328
|
# File 'lib/review/idgxmlbuilder.rb', line 321
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
628
629
630
|
# File 'lib/review/idgxmlbuilder.rb', line 628
def emtable(lines, caption = nil)
table(lines, nil, caption)
end
|
#endnote_begin ⇒ Object
683
684
685
|
# File 'lib/review/idgxmlbuilder.rb', line 683
def endnote_begin
puts '<endnotes>'
end
|
#endnote_end ⇒ Object
687
688
689
|
# File 'lib/review/idgxmlbuilder.rb', line 687
def endnote_end
puts '</endnotes>'
end
|
#endnote_item(id) ⇒ Object
691
692
693
|
# File 'lib/review/idgxmlbuilder.rb', line 691
def endnote_item(id)
puts %Q(<endnote id='endnoteb-#{normalize_id(id)}'><span type='endnotenumber'>(#{@chapter.endnote(id).number})</span>\t#{compile_inline(@chapter.endnote(id).content)}</endnote>)
end
|
#expert(lines) ⇒ Object
1086
1087
1088
|
# File 'lib/review/idgxmlbuilder.rb', line 1086
def expert(lines)
captionblock('expert', lines, nil)
end
|
45
46
47
|
# File 'lib/review/idgxmlbuilder.rb', line 45
def extname
'.xml'
end
|
#flushright(lines) ⇒ Object
982
983
984
|
# File 'lib/review/idgxmlbuilder.rb', line 982
def flushright(lines)
puts split_paragraph(lines).join.gsub('<p>', %Q(<p align='right'>))
end
|
667
668
669
|
# File 'lib/review/idgxmlbuilder.rb', line 667
def (id, str)
end
|
#handle_metric(str) ⇒ Object
414
415
416
417
|
# File 'lib/review/idgxmlbuilder.rb', line 414
def handle_metric(str)
k, v = str.split('=', 2)
%Q(#{k}="#{v.sub(/\A["']/, '').sub(/["']\Z/, '')}")
end
|
#headline(level, label, caption) ⇒ Object
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
|
# File 'lib/review/idgxmlbuilder.rb', line 108
def headline(level, label, caption)
output_close_sect_tags(level)
case level
when 1
print %Q(<chapter id="chap:#{@chapter.number}">) if @secttags
@section = 0
@subsection = 0
@subsubsection = 0
@subsubsubsection = 0
when 2
@section += 1
print %Q(<sect id="sect:#{@chapter.number}.#{@section}">) if @secttags
@subsection = 0
@subsubsection = 0
@subsubsubsection = 0
when 3
@subsection += 1
print %Q(<sect2 id="sect:#{@chapter.number}.#{@section}.#{@subsection}">) if @secttags
@subsubsection = 0
@subsubsubsection = 0
when 4
@subsubsection += 1
print %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) if @secttags
@subsubsubsection = 0
when 5
@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
934
935
936
|
# File 'lib/review/idgxmlbuilder.rb', line 934
def hood_begin(_level, _label, caption)
common_column_begin('hood', caption)
end
|
#hood_end(_level) ⇒ Object
938
939
940
|
# File 'lib/review/idgxmlbuilder.rb', line 938
def hood_end(_level)
common_column_end('hood')
end
|
1190
1191
1192
|
# File 'lib/review/idgxmlbuilder.rb', line 1190
def hr
print '<hr />'
end
|
#image_dummy(id, caption, lines) ⇒ Object
432
433
434
435
436
437
438
439
440
441
442
443
444
|
# File 'lib/review/idgxmlbuilder.rb', line 432
def image_dummy(id, caption, lines)
puts '<img>'
(id, caption) if caption_top?('image')
print %Q(<pre aid:pstyle="dummyimage">)
lines.each do |line|
print detab(line)
print "\n"
end
print '</pre>'
(id, caption) unless caption_top?('image')
puts '</img>'
warn "image not bound: #{id}", location: location
end
|
#image_ext ⇒ Object
1337
1338
1339
|
# File 'lib/review/idgxmlbuilder.rb', line 1337
def image_ext
'eps'
end
|
446
447
448
449
450
451
452
453
454
|
# File 'lib/review/idgxmlbuilder.rb', line 446
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
423
424
425
426
427
428
429
430
|
# File 'lib/review/idgxmlbuilder.rb', line 423
def image_image(id, caption, metric = nil)
metrics = parse_metric('idgxml', metric)
puts '<img>'
(id, caption) if caption_top?('image')
puts %Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A./}, '')}"#{metrics} />)
(id, caption) unless caption_top?('image')
puts '</img>'
end
|
#imgtable(lines, id, caption = nil, metric = nil) ⇒ Object
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
# File 'lib/review/idgxmlbuilder.rb', line 632
def imgtable(lines, id, caption = nil, metric = nil)
if @chapter.image_bound?(id)
metrics = parse_metric('idgxml', metric)
puts '<table>'
if caption_top?('table') && caption.present?
(id, caption)
end
puts %Q(<imgtable><Image href="file://#{@chapter.image(id).path.sub(%r{\A./}, '')}"#{metrics} /></imgtable>)
if !caption_top?('table') && caption.present?
(id, caption)
end
puts '</table>'
else
warn "image not bound: #{id}", location: location if @strict
image_dummy(id, caption, lines)
end
end
|
#important(lines, caption = nil) ⇒ Object
1026
1027
1028
1029
|
# File 'lib/review/idgxmlbuilder.rb', line 1026
def important(lines, caption = nil)
check_nested_minicolumn
captionblock('important', lines, caption)
end
|
#indepimage(_lines, id, caption = nil, metric = nil) ⇒ Object
Also known as:
numberlessimage
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
|
# File 'lib/review/idgxmlbuilder.rb', line 1162
def indepimage(_lines, id, caption = nil, metric = nil)
metrics = parse_metric('idgxml', metric)
puts '<img>'
if caption_top?('image') && caption.present?
puts %Q(<caption>#{compile_inline(caption)}</caption>)
end
begin
puts %Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A\./}, '')}"#{metrics} />)
rescue StandardError
warn %Q(image not bound: #{id}), location: location
end
if !caption_top?('image') && caption.present?
puts %Q(<caption>#{compile_inline(caption)}</caption>)
end
puts '</img>'
end
|
#info(lines, caption = nil) ⇒ Object
1013
1014
1015
1016
|
# File 'lib/review/idgxmlbuilder.rb', line 1013
def info(lines, caption = nil)
check_nested_minicolumn
captionblock('info', lines, caption)
end
|
#inline_ami(str) ⇒ Object
767
768
769
|
# File 'lib/review/idgxmlbuilder.rb', line 767
def inline_ami(str)
%Q(<ami>#{escape(str)}</ami>)
end
|
#inline_b(str) ⇒ Object
775
776
777
|
# File 'lib/review/idgxmlbuilder.rb', line 775
def inline_b(str)
%Q(<b>#{escape(str)}</b>)
end
|
#inline_balloon(str) ⇒ Object
840
841
842
|
# File 'lib/review/idgxmlbuilder.rb', line 840
def inline_balloon(str)
%Q(<balloon>#{escape(str).gsub(/@maru\[(\d+)\]/) { inline_maru($1) }}</balloon>)
end
|
#inline_bib(id) ⇒ Object
1311
1312
1313
1314
1315
|
# File 'lib/review/idgxmlbuilder.rb', line 1311
def inline_bib(id)
%Q(<span type='bibref' idref='#{id}'>[#{@chapter.bibpaper(id).number}]</span>)
rescue KeyError
app_error "unknown bib: #{id}"
end
|
#inline_bou(str) ⇒ Object
822
823
824
|
# File 'lib/review/idgxmlbuilder.rb', line 822
def inline_bou(str)
%Q(<bou>#{escape(str)}</bou>)
end
|
#inline_br(_str) ⇒ Object
1206
1207
1208
|
# File 'lib/review/idgxmlbuilder.rb', line 1206
def inline_br(_str)
"\n"
end
|
#inline_chap(id) ⇒ Object
1253
1254
1255
1256
1257
1258
1259
1260
1261
|
# File 'lib/review/idgxmlbuilder.rb', line 1253
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
app_error "unknown chapter: #{id}"
end
|
#inline_chapref(id) ⇒ Object
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
|
# File 'lib/review/idgxmlbuilder.rb', line 1223
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
chs = chs2
else
app_error '--chapsplitter must have exactly 3 parameters with comma.'
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
app_error "unknown chapter: #{id}"
end
|
#inline_code(str) ⇒ Object
1202
1203
1204
|
# File 'lib/review/idgxmlbuilder.rb', line 1202
def inline_code(str)
%Q(<tt type='inline-code'>#{escape(str)}</tt>)
end
|
#inline_column_chap(chapter, id) ⇒ Object
265
266
267
268
269
270
271
272
273
|
# File 'lib/review/idgxmlbuilder.rb', line 265
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
app_error "unknown column: #{id}"
end
|
659
660
661
662
663
664
665
|
# File 'lib/review/idgxmlbuilder.rb', line 659
def (str)
if @book.config['draft']
%Q(<msg>#{escape(str)}</msg>)
else
''
end
end
|
#inline_del(str) ⇒ Object
809
810
811
|
# File 'lib/review/idgxmlbuilder.rb', line 809
def inline_del(str)
%Q(<del>#{escape(str)}</del>)
end
|
#inline_dtp(str) ⇒ Object
1198
1199
1200
|
# File 'lib/review/idgxmlbuilder.rb', line 1198
def inline_dtp(str)
"<?dtp #{str} ?>"
end
|
#inline_em(str) ⇒ Object
779
780
781
|
# File 'lib/review/idgxmlbuilder.rb', line 779
def inline_em(str)
%Q(<em>#{escape(str)}</em>)
end
|
#inline_endnote(id) ⇒ Object
677
678
679
680
681
|
# File 'lib/review/idgxmlbuilder.rb', line 677
def inline_endnote(id)
%Q(<span type='endnoteref' idref='endnoteb-#{normalize_id(id)}'>(#{@chapter.endnote(id).number})</span>)
rescue KeyError
app_error "unknown endnote: #{id}"
end
|
#inline_eq(id) ⇒ Object
399
400
401
|
# File 'lib/review/idgxmlbuilder.rb', line 399
def inline_eq(id)
"<span type='eq'>#{super(id)}</span>"
end
|
#inline_fn(id) ⇒ Object
671
672
673
674
675
|
# File 'lib/review/idgxmlbuilder.rb', line 671
def inline_fn(id)
%Q(<footnote>#{compile_inline(@chapter.(id).content.strip)}</footnote>)
rescue KeyError
app_error "unknown footnote: #{id}"
end
|
#inline_hd_chap(chap, id) ⇒ Object
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
|
# File 'lib/review/idgxmlbuilder.rb', line 1317
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
app_error "unknown headline: #{id}"
end
|
#inline_hidx(str) ⇒ Object
763
764
765
|
# File 'lib/review/idgxmlbuilder.rb', line 763
def inline_hidx(str)
%Q(<index value="#{escape(str)}" />)
end
|
#inline_hint(str) ⇒ Object
731
732
733
734
735
736
737
|
# File 'lib/review/idgxmlbuilder.rb', line 731
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
771
772
773
|
# File 'lib/review/idgxmlbuilder.rb', line 771
def inline_i(str)
%Q(<i>#{escape(str)}</i>)
end
|
#inline_icon(id) ⇒ Object
813
814
815
816
817
818
819
820
|
# File 'lib/review/idgxmlbuilder.rb', line 813
def inline_icon(id)
begin
%Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A\./}, '')}" type="inline" />)
rescue StandardError
warn "image not bound: #{id}", location: location
''
end
end
|
#inline_idx(str) ⇒ Object
759
760
761
|
# File 'lib/review/idgxmlbuilder.rb', line 759
def inline_idx(str)
%Q(#{escape(str)}<index value="#{escape(str)}" />)
end
|
#inline_img(id) ⇒ Object
395
396
397
|
# File 'lib/review/idgxmlbuilder.rb', line 395
def inline_img(id)
"<span type='image'>#{super(id)}</span>"
end
|
#inline_imgref(id) ⇒ Object
403
404
405
406
407
408
409
410
411
412
|
# File 'lib/review/idgxmlbuilder.rb', line 403
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_ins(str) ⇒ Object
805
806
807
|
# File 'lib/review/idgxmlbuilder.rb', line 805
def inline_ins(str)
%Q(<ins>#{escape(str)}</ins>)
end
|
#inline_keytop(str) ⇒ Object
826
827
828
|
# File 'lib/review/idgxmlbuilder.rb', line 826
def inline_keytop(str)
%Q(<keytop>#{escape(str)}</keytop>)
end
|
#inline_labelref(idref) ⇒ Object
Also known as:
inline_ref
830
831
832
|
# File 'lib/review/idgxmlbuilder.rb', line 830
def inline_labelref(idref)
%Q(<ref idref='#{escape(idref)}'>「#{I18n.t('label_marker')}#{escape(idref)}」</ref>) end
|
#inline_list(id) ⇒ Object
275
276
277
|
# File 'lib/review/idgxmlbuilder.rb', line 275
def inline_list(id)
"<span type='list'>#{super(id)}</span>"
end
|
#inline_m(str) ⇒ Object
848
849
850
851
852
853
854
855
856
857
858
|
# File 'lib/review/idgxmlbuilder.rb', line 848
def inline_m(str)
@texinlineequation += 1
if @book.config['math_format'] == 'imgmath'
math_str = '$' + str + '$'
key = Digest::SHA256.hexdigest(str)
img_path = @img_math.defer_math_image(math_str, key)
%Q(<inlineequation><Image href="file://#{img_path}" type="inline" /></inlineequation>)
else
%Q(<replace idref="texinline-#{@texinlineequation}"><pre>#{escape(str)}</pre></replace>)
end
end
|
#inline_maru(str) ⇒ Object
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
|
# File 'lib/review/idgxmlbuilder.rb', line 739
def inline_maru(str)
if /\A\d+\Z/.match?(str)
sprintf('&#x%x;', 9311 + str.to_i)
elsif /\A[A-Z]\Z/.match?(str)
begin
sprintf('&#x%x;', 9398 + str.codepoints.to_a[0] - 65)
rescue NoMethodError
sprintf('&#x%x;', 9398 + str[0] - 65)
end
elsif /\A[a-z]\Z/.match?(str)
begin
sprintf('&#x%x;', 9392 + str.codepoints.to_a[0] - 65)
rescue NoMethodError
sprintf('&#x%x;', 9392 + str[0] - 65)
end
else
app_error "can't parse maru: #{str}"
end
end
|
836
837
838
|
# File 'lib/review/idgxmlbuilder.rb', line 836
def (idref)
%Q(<pageref idref='#{escape(idref)}'>●●</pageref>) end
|
#inline_raw(str) ⇒ Object
727
728
729
|
# File 'lib/review/idgxmlbuilder.rb', line 727
def inline_raw(str)
super(str).gsub('\\n', "\n")
end
|
#inline_recipe(id) ⇒ Object
1328
1329
1330
1331
|
# File 'lib/review/idgxmlbuilder.rb', line 1328
def inline_recipe(id)
%Q(<recipe idref="#{escape(id)}">[XXX]「#{escape(id)}」 p.XX</recipe>)
end
|
#inline_strong(str) ⇒ Object
783
784
785
|
# File 'lib/review/idgxmlbuilder.rb', line 783
def inline_strong(str)
%Q(<strong>#{escape(str)}</strong>)
end
|
#inline_sub(str) ⇒ Object
723
724
725
|
# File 'lib/review/idgxmlbuilder.rb', line 723
def inline_sub(str)
%Q(<sub>#{escape(str)}</sub>)
end
|
#inline_sup(str) ⇒ Object
719
720
721
|
# File 'lib/review/idgxmlbuilder.rb', line 719
def inline_sup(str)
%Q(<sup>#{escape(str)}</sup>)
end
|
#inline_table(id) ⇒ Object
391
392
393
|
# File 'lib/review/idgxmlbuilder.rb', line 391
def inline_table(id)
"<span type='table'>#{super(id)}</span>"
end
|
#inline_title(id) ⇒ Object
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
|
# File 'lib/review/idgxmlbuilder.rb', line 1263
def inline_title(id)
title = super
if @book.config['chapterlink']
%Q(<link href="#{id}">#{title}</link>)
else
title
end
rescue KeyError
app_error "unknown chapter: #{id}"
end
|
#inline_tt(str) ⇒ Object
787
788
789
|
# File 'lib/review/idgxmlbuilder.rb', line 787
def inline_tt(str)
%Q(<tt>#{escape(str)}</tt>)
end
|
#inline_ttb(str) ⇒ Object
Also known as:
inline_ttbold
791
792
793
|
# File 'lib/review/idgxmlbuilder.rb', line 791
def inline_ttb(str)
%Q(<tt style='bold'>#{escape(str)}</tt>)
end
|
#inline_tti(str) ⇒ Object
797
798
799
|
# File 'lib/review/idgxmlbuilder.rb', line 797
def inline_tti(str)
%Q(<tt style='italic'>#{escape(str)}</tt>)
end
|
#inline_u(str) ⇒ Object
801
802
803
|
# File 'lib/review/idgxmlbuilder.rb', line 801
def inline_u(str)
%Q(<underline>#{escape(str)}</underline>)
end
|
#inline_uchar(str) ⇒ Object
844
845
846
|
# File 'lib/review/idgxmlbuilder.rb', line 844
def inline_uchar(str)
%Q(&#x#{str};)
end
|
#insideout_begin(_level, _label, caption) ⇒ Object
950
951
952
|
# File 'lib/review/idgxmlbuilder.rb', line 950
def insideout_begin(_level, _label, caption)
common_column_begin('insideout', caption)
end
|
#insideout_end(_level) ⇒ Object
954
955
956
|
# File 'lib/review/idgxmlbuilder.rb', line 954
def insideout_end(_level)
common_column_end('insideout')
end
|
#insn(lines, caption = nil) ⇒ Object
1154
1155
1156
|
# File 'lib/review/idgxmlbuilder.rb', line 1154
def insn(lines, caption = nil)
syntaxblock('insn', lines, caption)
end
|
#label(id) ⇒ Object
1181
1182
1183
1184
|
# File 'lib/review/idgxmlbuilder.rb', line 1181
def label(id)
print "<label id='#{id}' />"
end
|
#link(lines, caption = nil) ⇒ Object
1049
1050
1051
|
# File 'lib/review/idgxmlbuilder.rb', line 1049
def link(lines, caption = nil)
captionblock('link', lines, caption)
end
|
#list(lines, id, caption, lang = nil) ⇒ Object
305
306
307
308
309
|
# File 'lib/review/idgxmlbuilder.rb', line 305
def list(lines, id, caption, lang = nil)
puts '<codelist>'
super(lines, id, caption, lang)
puts '</codelist>'
end
|
#list_body(_id, lines, _lang) ⇒ Object
311
312
313
314
315
|
# File 'lib/review/idgxmlbuilder.rb', line 311
def list_body(_id, lines, _lang)
print '<pre>'
codelines_body(lines)
print '</pre>'
end
|
279
280
281
282
283
284
285
286
287
|
# File 'lib/review/idgxmlbuilder.rb', line 279
def (id, caption, _lang)
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(lines, id, caption, lang = nil) ⇒ Object
330
331
332
333
334
|
# File 'lib/review/idgxmlbuilder.rb', line 330
def listnum(lines, id, caption, lang = nil)
puts '<codelist>'
super(lines, id, caption, lang)
puts '</codelist>'
end
|
#listnum_body(lines, _lang) ⇒ Object
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
# File 'lib/review/idgxmlbuilder.rb', line 336
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
print '</pre>'
end
|
#memo(lines, caption = nil) ⇒ Object
1003
1004
1005
1006
|
# File 'lib/review/idgxmlbuilder.rb', line 1003
def memo(lines, caption = nil)
check_nested_minicolumn
captionblock('memo', lines, caption)
end
|
#nodisp_begin(level, label, caption) ⇒ Object
886
887
|
# File 'lib/review/idgxmlbuilder.rb', line 886
def nodisp_begin(level, label, caption)
end
|
#nodisp_end(level) ⇒ Object
889
890
|
# File 'lib/review/idgxmlbuilder.rb', line 889
def nodisp_end(level)
end
|
#nofunc_text(str) ⇒ Object
1333
1334
1335
|
# File 'lib/review/idgxmlbuilder.rb', line 1333
def nofunc_text(str)
escape(str)
end
|
860
861
862
|
# File 'lib/review/idgxmlbuilder.rb', line 860
def noindent
@noindent = true
end
|
#nonum_begin(level, _label, caption) ⇒ Object
872
873
874
|
# File 'lib/review/idgxmlbuilder.rb', line 872
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
876
877
|
# File 'lib/review/idgxmlbuilder.rb', line 876
def nonum_end(level)
end
|
#note(lines, caption = nil) ⇒ Object
998
999
1000
1001
|
# File 'lib/review/idgxmlbuilder.rb', line 998
def note(lines, caption = nil)
check_nested_minicolumn
captionblock('note', lines, caption)
end
|
#notice(lines, caption = nil) ⇒ Object
1053
1054
1055
1056
1057
1058
1059
1060
|
# File 'lib/review/idgxmlbuilder.rb', line 1053
def notice(lines, caption = nil)
check_nested_minicolumn
if caption
captionblock('notice-t', lines, caption, 'notice-title')
else
captionblock('notice', lines, nil)
end
end
|
#notoc_begin(level, _label, caption) ⇒ Object
879
880
881
|
# File 'lib/review/idgxmlbuilder.rb', line 879
def notoc_begin(level, _label, caption)
puts %Q(<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title>)
end
|
#notoc_end(level) ⇒ Object
883
884
|
# File 'lib/review/idgxmlbuilder.rb', line 883
def notoc_end(level)
end
|
205
206
207
208
|
# File 'lib/review/idgxmlbuilder.rb', line 205
def ol_begin
puts '<ol>'
@ol_num ||= 1 end
|
215
216
217
218
|
# File 'lib/review/idgxmlbuilder.rb', line 215
def ol_end
puts '</ol>'
@ol_num = nil
end
|
#ol_item(lines, num) ⇒ Object
210
211
212
213
|
# File 'lib/review/idgxmlbuilder.rb', line 210
def ol_item(lines, num)
puts %Q(<li aid:pstyle="ol-item" olnum="#{@ol_num}" num="#{num}">#{join_lines_to_paragraph(lines).chomp}</li>)
@ol_num += 1
end
|
#olnum(num) ⇒ Object
220
221
222
|
# File 'lib/review/idgxmlbuilder.rb', line 220
def olnum(num)
@ol_num = num.to_i
end
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/review/idgxmlbuilder.rb', line 152
def output_close_sect_tags(level)
if @secttags
if level <= 5 && @subsubsubsection > 0
print '</sect4>'
end
if level <= 4 && @subsubsection > 0
print '</sect3>'
end
if level <= 3 && @subsection > 0
print '</sect2>'
end
if level <= 2 && @section > 0
print '</sect>'
end
end
end
|
#pagebreak ⇒ Object
868
869
870
|
# File 'lib/review/idgxmlbuilder.rb', line 868
def pagebreak
puts '<pagebreak />'
end
|
#paragraph(lines) ⇒ Object
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/review/idgxmlbuilder.rb', line 240
def paragraph(lines)
if @noindent.nil?
if lines[0] =~ /\A(\t+)/
puts %Q(<p inlist="#{$1.size}">#{join_lines_to_paragraph(lines).sub(/\A\t+/, '')}</p>)
else
puts "<p>#{join_lines_to_paragraph(lines)}</p>"
end
else
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{join_lines_to_paragraph(lines)}</p>)
@noindent = nil
end
end
|
#parse_table_rows(lines) ⇒ Object
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
# File 'lib/review/idgxmlbuilder.rb', line 526
def parse_table_rows(lines)
sepidx = nil
rows = []
lines.each_with_index do |line, idx|
if /\A[=-]{12}/.match?(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(table_row_separator_regexp).length
@col = col2 if col2 > @col
end
app_error 'no rows in the table' if rows.empty?
[sepidx, rows]
end
|
#planning(lines, caption = nil) ⇒ Object
1018
1019
1020
|
# File 'lib/review/idgxmlbuilder.rb', line 1018
def planning(lines, caption = nil)
captionblock('planning', lines, caption)
end
|
#point(lines, caption = nil) ⇒ Object
1062
1063
1064
1065
1066
1067
1068
|
# File 'lib/review/idgxmlbuilder.rb', line 1062
def point(lines, caption = nil)
if caption
captionblock('point-t', lines, caption, 'point-title')
else
captionblock('point', lines, nil)
end
end
|
#post_paragraph ⇒ Object
41
42
43
|
# File 'lib/review/idgxmlbuilder.rb', line 41
def post_paragraph
'</p>'
end
|
#practice(lines) ⇒ Object
1082
1083
1084
|
# File 'lib/review/idgxmlbuilder.rb', line 1082
def practice(lines)
captionblock('practice', lines, nil)
end
|
#pre_paragraph ⇒ Object
37
38
39
|
# File 'lib/review/idgxmlbuilder.rb', line 37
def pre_paragraph
'<p>'
end
|
#puts(arg) ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/review/idgxmlbuilder.rb', line 72
def puts(arg)
if @book.config['nolf'].present?
print arg
else
super
end
end
|
#quote(lines) ⇒ Object
386
387
388
389
|
# File 'lib/review/idgxmlbuilder.rb', line 386
def quote(lines)
blocked_lines = split_paragraph(lines)
puts "<quote>#{blocked_lines.join}</quote>"
end
|
#rawblock(lines) ⇒ Object
1210
1211
1212
1213
1214
1215
1216
1217
|
# File 'lib/review/idgxmlbuilder.rb', line 1210
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
253
254
255
|
# File 'lib/review/idgxmlbuilder.rb', line 253
def read(lines)
puts %Q(<lead>#{split_paragraph(lines).join}</lead>)
end
|
#ref_begin(_level, label, _caption) ⇒ Object
958
959
960
961
962
963
964
|
# File 'lib/review/idgxmlbuilder.rb', line 958
def ref_begin(_level, label, _caption)
if label
puts "<reference id='#{label}'>"
else
puts '<reference>'
end
end
|
#ref_end(_level) ⇒ Object
966
967
968
|
# File 'lib/review/idgxmlbuilder.rb', line 966
def ref_end(_level)
puts '</reference>'
end
|
#reference(lines) ⇒ Object
1078
1079
1080
|
# File 'lib/review/idgxmlbuilder.rb', line 1078
def reference(lines)
captionblock('reference', lines, nil)
end
|
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/review/idgxmlbuilder.rb', line 80
def result
check_printendnotes
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>'
end
solve_nest(@output.string) + s + "</#{@rootelement}>\n"
end
|
#result_metric(array) ⇒ Object
419
420
421
|
# File 'lib/review/idgxmlbuilder.rb', line 419
def result_metric(array)
" #{array.join(' ')}"
end
|
#security(lines, caption = nil) ⇒ Object
1031
1032
1033
|
# File 'lib/review/idgxmlbuilder.rb', line 1031
def security(lines, caption = nil)
captionblock('security', lines, caption)
end
|
#shoot(lines, caption = nil) ⇒ Object
1070
1071
1072
1073
1074
1075
1076
|
# File 'lib/review/idgxmlbuilder.rb', line 1070
def shoot(lines, caption = nil)
if caption
captionblock('shoot-t', lines, caption, 'shoot-title')
else
captionblock('shoot', lines, nil)
end
end
|
#solve_nest(s) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/review/idgxmlbuilder.rb', line 94
def solve_nest(s)
check_nest
s.gsub("</dd></dl>\x01→dl←\x01", '').
gsub("\x01→/dl←\x01", "</dd></dl>←END\x01").
gsub("</li></ul>\x01→ul←\x01", '').
gsub("\x01→/ul←\x01", "</li></ul>←END\x01").
gsub("</li></ol>\x01→ol←\x01", '').
gsub("\x01→/ol←\x01", "</li></ol>←END\x01").
gsub("</dl>←END\x01<dl>", '').
gsub("</ul>←END\x01<ul>", '').
gsub("</ol>←END\x01<ol>", '').
gsub("←END\x01", '')
end
|
#source(lines, caption = nil, lang = nil) ⇒ Object
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
|
# File 'lib/review/idgxmlbuilder.rb', line 1274
def source(lines, caption = nil, lang = nil)
puts '<source>'
if caption_top?('list')
(caption)
end
source_body(lines, lang)
unless caption_top?('list')
(caption)
end
puts '</source>'
end
|
#source_body(lines, _lang) ⇒ Object
1290
1291
1292
1293
1294
|
# File 'lib/review/idgxmlbuilder.rb', line 1290
def source_body(lines, _lang)
puts '<pre>'
codelines_body(lines)
print '</pre>'
end
|
1286
1287
1288
|
# File 'lib/review/idgxmlbuilder.rb', line 1286
def (caption)
puts %Q(<caption>#{compile_inline(caption)}</caption>) if caption.present?
end
|
#sup_begin(_level, label, _caption) ⇒ Object
970
971
972
973
974
975
976
|
# File 'lib/review/idgxmlbuilder.rb', line 970
def sup_begin(_level, label, _caption)
if label
puts "<supplement id='#{label}'>"
else
puts '<supplement>'
end
end
|
#sup_end(_level) ⇒ Object
978
979
980
|
# File 'lib/review/idgxmlbuilder.rb', line 978
def sup_end(_level)
puts '</supplement>'
end
|
#syntaxblock(type, lines, caption) ⇒ Object
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
|
# File 'lib/review/idgxmlbuilder.rb', line 1117
def syntaxblock(type, lines, caption)
captionstr = nil
if caption.present?
titleopentag = %Q(caption aid:pstyle="#{type}-title")
titleclosetag = 'caption'
if type == 'insn'
titleopentag = %Q(floattitle type="insn")
titleclosetag = 'floattitle'
end
captionstr = %Q(<#{titleopentag}>#{compile_inline(caption)}</#{titleclosetag}>)
end
print "<#{type}>"
if caption_top?('list')
puts captionstr
else
puts ''
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
unless caption_top?('list')
print captionstr
end
puts "</#{type}>"
end
|
#table(lines, id = nil, caption = nil) ⇒ Object
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
521
522
523
524
|
# File 'lib/review/idgxmlbuilder.rb', line 492
def table(lines, id = nil, caption = nil)
@tablewidth = nil
if @book.config['tableopt']
@tablewidth = @book.config['tableopt'].split(',')[0].to_f / @book.config['pt_to_mm_unit'].to_f end
@col = 0
sepidx, rows = parse_table_rows(lines)
puts '<table>'
begin
if caption_top?('table') && caption.present?
(id, caption)
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
@table_id = id
table_rows(sepidx, rows)
puts '</tbody>'
if !caption_top?('table') && caption.present?
(id, caption)
end
rescue KeyError
app_error "no such table: #{id}"
end
puts '</table>'
@tsize = nil
end
|
#table_begin(ncols) ⇒ Object
610
611
|
# File 'lib/review/idgxmlbuilder.rb', line 610
def table_begin(ncols)
end
|
#table_end ⇒ Object
625
626
|
# File 'lib/review/idgxmlbuilder.rb', line 625
def table_end
end
|
600
601
602
603
604
605
606
607
608
|
# File 'lib/review/idgxmlbuilder.rb', line 600
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
|
#table_rows(sepidx, rows) ⇒ Object
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
|
# File 'lib/review/idgxmlbuilder.rb', line 546
def table_rows(sepidx, rows)
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: #{@table_id}", location: location if totallength > @tablewidth
end
if cellwidth.size < @col
cw = (@tablewidth - totallength) / (@col - cellwidth.size)
warn "auto cell sizing exceeds limit for table: #{@table_id}", location: location if cw <= 0
(cellwidth.size..(@col - 1)).each { |i| cellwidth[i] = cw }
end
end
end
if sepidx
sepidx.times do |y|
if @tablewidth.nil?
puts %Q(<tr type="header">#{rows.shift}</tr>)
else
i = 0
rows.shift.split(table_row_separator_regexp).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)
end
|
621
622
623
|
# File 'lib/review/idgxmlbuilder.rb', line 621
def td(str)
str
end
|
#term(lines) ⇒ Object
1045
1046
1047
|
# File 'lib/review/idgxmlbuilder.rb', line 1045
def term(lines)
captionblock('term', lines, nil)
end
|
#texequation(lines, id = nil, caption = '') ⇒ Object
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
|
# File 'lib/review/idgxmlbuilder.rb', line 456
def texequation(lines, id = nil, caption = '')
@texblockequation += 1
caption_str = nil
if id
puts '<equationblock>'
caption_str = if get_chap.nil?
%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
%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
puts caption_str if caption_top?('equation')
end
if @book.config['math_format'] == 'imgmath'
fontsize = @book.config['imgmath_options']['fontsize'].to_f
lineheight = @book.config['imgmath_options']['lineheight'].to_f
math_str = "\\begin{equation*}\n\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont\n#{lines.join("\n")}\n\\end{equation*}\n"
key = Digest::SHA256.hexdigest(math_str)
img_path = @img_math.defer_math_image(math_str, key)
puts '<equationimage>'
puts %Q(<Image href="file://#{img_path}" />)
puts '</equationimage>'
else
puts %Q(<replace idref="texblock-#{@texblockequation}">)
puts '<pre>'
puts lines.join("\n")
puts '</pre>'
puts '</replace>'
end
if id
puts caption_str unless caption_top?('equation')
puts '</equationblock>'
end
end
|
#text(str) ⇒ Object
1219
1220
1221
|
# File 'lib/review/idgxmlbuilder.rb', line 1219
def text(str)
str
end
|
617
618
619
|
# File 'lib/review/idgxmlbuilder.rb', line 617
def th(str)
%Q(<?dtp tablerow header?>#{str})
end
|
#tip(lines, caption = nil) ⇒ Object
1008
1009
1010
1011
|
# File 'lib/review/idgxmlbuilder.rb', line 1008
def tip(lines, caption = nil)
check_nested_minicolumn
captionblock('tip', lines, caption)
end
|
613
614
615
|
# File 'lib/review/idgxmlbuilder.rb', line 613
def tr(rows)
puts %Q(<tr>#{rows.join("\t")}</tr>)
end
|
#trputs(tablewidth, rows, cellwidth, sepidx) ⇒ Object
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
|
# File 'lib/review/idgxmlbuilder.rb', line 583
def trputs(tablewidth, rows, cellwidth, sepidx)
sepidx = 0 if sepidx.nil?
if tablewidth
rows.each_with_index do |row, y|
i = 0
row.split(table_row_separator_regexp).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
|
169
170
171
172
173
|
# File 'lib/review/idgxmlbuilder.rb', line 169
def ul_begin
level = block_given? ? yield : ''
level = nil if level == 1
puts "<ul#{level == 1 ? nil : level}>"
end
|
199
200
201
202
203
|
# File 'lib/review/idgxmlbuilder.rb', line 199
def ul_end
level = block_given? ? yield : ''
level = nil if level == 1
puts "</ul#{level}>"
end
|
#ul_item_begin(lines) ⇒ Object
175
176
177
|
# File 'lib/review/idgxmlbuilder.rb', line 175
def ul_item_begin(lines)
print %Q(<li aid:pstyle="ul-item">#{join_lines_to_paragraph(lines).chomp})
end
|
#ul_item_end ⇒ Object
179
180
181
|
# File 'lib/review/idgxmlbuilder.rb', line 179
def ul_item_end
puts '</li>'
end
|
#warning(lines, caption = nil) ⇒ Object
1040
1041
1042
1043
|
# File 'lib/review/idgxmlbuilder.rb', line 1040
def warning(lines, caption = nil)
check_nested_minicolumn
captionblock('warning', lines, caption)
end
|
#world_begin(_level, _label, caption) ⇒ Object
926
927
928
|
# File 'lib/review/idgxmlbuilder.rb', line 926
def world_begin(_level, _label, caption)
common_column_begin('world', caption)
end
|
#world_end(_level) ⇒ Object
930
931
932
|
# File 'lib/review/idgxmlbuilder.rb', line 930
def world_end(_level)
common_column_end('world')
end
|
#xcolumn_begin(_level, _label, caption) ⇒ Object
918
919
920
|
# File 'lib/review/idgxmlbuilder.rb', line 918
def xcolumn_begin(_level, _label, caption)
common_column_begin('x', caption)
end
|
#xcolumn_end(_level) ⇒ Object
922
923
924
|
# File 'lib/review/idgxmlbuilder.rb', line 922
def xcolumn_end(_level)
common_column_end('x')
end
|