Class: ReVIEW::IDGXMLBuilder

Inherits:
Builder show all
Includes:
HTMLUtils, TextUtils
Defined in:
lib/review/idgxmlbuilder.rb

Constant Summary

Constants included from HTMLUtils

HTMLUtils::ESC

Constants inherited from Builder

Builder::CAPTION_TITLES

Instance Method Summary collapse

Methods included from HTMLUtils

#escape_comment, #escape_html, #highlight, #highlight?, #normalize_id, #strip_html, #unescape_html

Methods included from TextUtils

#detab, #split_paragraph

Methods inherited from Builder

#bind, #compile_inline, #detab, #extract_chapter_id, #get_chap, #graph, #image, #include, #initialize, #inline_column, #inline_hd, #inline_href, #inline_include, #inline_kw, #inline_ruby, #inline_tcy, #list, #listnum, #parse_metric, #print, #raw, #source, #target_name

Constructor Details

This class inherits a constructor from ReVIEW::Builder

Instance Method Details

#best(lines, caption = nil) ⇒ Object



929
930
931
# File 'lib/review/idgxmlbuilder.rb', line 929

def best(lines, caption = nil)
  captionblock("best", lines, caption)
end

#bibpaper(lines, id, caption) ⇒ Object



1145
1146
1147
1148
1149
1150
1151
# File 'lib/review/idgxmlbuilder.rb', line 1145

def bibpaper(lines, id, caption)
  bibpaper_header id, caption
  unless lines.empty?
    bibpaper_bibpaper id, caption, lines
  end
  puts %Q(</bibitem>)
end

#bibpaper_bibpaper(id, caption, lines) ⇒ Object



1158
1159
1160
# File 'lib/review/idgxmlbuilder.rb', line 1158

def bibpaper_bibpaper(id, caption, lines)
    print split_paragraph(lines).join("")
end

#bibpaper_header(id, caption) ⇒ Object



1153
1154
1155
1156
# File 'lib/review/idgxmlbuilder.rb', line 1153

def bibpaper_header(id, caption)
  puts %Q(<bibitem id="bib-#{id}">)
  puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>"
end

#box(lines, caption = nil) ⇒ Object



1025
1026
1027
# File 'lib/review/idgxmlbuilder.rb', line 1025

def box(lines, caption = nil)
  syntaxblock("box", lines, caption)
end

#bpo(lines) ⇒ Object



1060
1061
1062
# File 'lib/review/idgxmlbuilder.rb', line 1060

def bpo(lines)
  puts %Q[<bpo>#{lines.join("\n")}</bpo>]
end

#captionblock(type, lines, caption, specialstyle = nil) ⇒ Object



901
902
903
904
905
906
907
# File 'lib/review/idgxmlbuilder.rb', line 901

def captionblock(type, lines, caption, specialstyle = nil)
  print "<#{type}>"
  style = specialstyle.nil? ? "#{type}-title" : specialstyle
  puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
  blocked_lines = split_paragraph(lines)
  puts "#{blocked_lines.join}</#{type}>"
end

#caution(lines, caption = nil) ⇒ Object



941
942
943
# File 'lib/review/idgxmlbuilder.rb', line 941

def caution(lines, caption = nil)
  captionblock("caution", lines, caption)
end

#centering(lines) ⇒ Object



897
898
899
# File 'lib/review/idgxmlbuilder.rb', line 897

def centering(lines)
  puts split_paragraph(lines).join.gsub("<p>", "<p align='center'>")
end

#choice_multi_beginObject



231
232
233
# File 'lib/review/idgxmlbuilder.rb', line 231

def choice_multi_begin
  puts "<choice type='multi'>"
end

#choice_multi_endObject



239
240
241
# File 'lib/review/idgxmlbuilder.rb', line 239

def choice_multi_end
  puts "</choice>"
end

#choice_single_beginObject



227
228
229
# File 'lib/review/idgxmlbuilder.rb', line 227

def choice_single_begin
  puts "<choice type='single'>"
end

#choice_single_endObject



235
236
237
# File 'lib/review/idgxmlbuilder.rb', line 235

def choice_single_end
  puts "</choice>"
end

#circle_begin(level, label, caption) ⇒ Object



803
804
805
# File 'lib/review/idgxmlbuilder.rb', line 803

def circle_begin(level, label, caption)
  puts %Q[<title aid:pstyle="smallcircle">&#x2022;#{compile_inline(caption)}</title>]
end

#circle_end(level) ⇒ Object



807
808
# File 'lib/review/idgxmlbuilder.rb', line 807

def circle_end(level)
end

#cmd(lines, caption = nil) ⇒ Object



389
390
391
# File 'lib/review/idgxmlbuilder.rb', line 389

def cmd(lines, caption = nil)
  quotedlist lines, 'cmd', caption
end

#codelines_body(lines) ⇒ Object



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/review/idgxmlbuilder.rb', line 337

def codelines_body(lines)
  no = 1
  lines.each do |line|
    unless @book.config["listinfo"].nil?
      print "<listinfo line=\"#{no}\""
      print " begin=\"1\"" if no == 1
      print " end=\"#{no}\"" if no == lines.size
      print ">"
    end
    print detab(line)
    print "\n"
    print "</listinfo>" unless @book.config["listinfo"].nil?
    no += 1
  end
end

#column_begin(level, label, caption) ⇒ Object



821
822
823
# File 'lib/review/idgxmlbuilder.rb', line 821

def column_begin(level, label, caption)
  common_column_begin("", caption)
end

#column_end(level) ⇒ Object



825
826
827
# File 'lib/review/idgxmlbuilder.rb', line 825

def column_end(level)
  common_column_end("")
end

#comment(str) ⇒ Object



630
631
632
# File 'lib/review/idgxmlbuilder.rb', line 630

def comment(str)
  print %Q(<!-- [Comment] #{escape_html(str)} -->)
end

#common_column_begin(type, caption) ⇒ Object



810
811
812
813
814
815
# File 'lib/review/idgxmlbuilder.rb', line 810

def common_column_begin(type, caption)
  @column += 1
  a_id = %Q[id="column-#{@column}"]
  print "<#{type}column #{a_id}>"
  puts %Q[<title aid:pstyle="#{type}column-title">#{compile_inline(caption)}</title>]
end

#common_column_end(type) ⇒ Object



817
818
819
# File 'lib/review/idgxmlbuilder.rb', line 817

def common_column_end(type)
  puts "</#{type}column>"
end

#compile_href(url, label) ⇒ Object



661
662
663
# File 'lib/review/idgxmlbuilder.rb', line 661

def compile_href(url, label)
  %Q[<a linkurl='#{escape_html(url)}'>#{label.nil? ? escape_html(url) : escape_html(label)}</a>]
end

#compile_kw(word, alt) ⇒ Object



646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'lib/review/idgxmlbuilder.rb', line 646

def compile_kw(word, alt)
  '<keyword>' +
    if alt
    then escape_html("#{word}#{alt.strip}")
    else escape_html(word)
    end +
  '</keyword>' +
    %Q[<index value="#{escape_html(word)}" />] +
    if alt
      alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{escape_html(e.strip)}" />] }.join
    else
      ""
    end
end

#compile_ruby(base, ruby) ⇒ Object



642
643
644
# File 'lib/review/idgxmlbuilder.rb', line 642

def compile_ruby(base, ruby)
  %Q[<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape_html(base.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rb><aid:rt>#{escape_html(ruby.sub(/\A\s+/, "").sub(/\s+$/, ""))}</aid:rt></aid:ruby></GroupRuby>]
end

#dd(lines) ⇒ Object



278
279
280
# File 'lib/review/idgxmlbuilder.rb', line 278

def dd(lines)
  puts "<dd>#{lines.join.chomp}</dd>"
end

#dl_beginObject



270
271
272
# File 'lib/review/idgxmlbuilder.rb', line 270

def dl_begin
  puts '<dl>'
end

#dl_endObject



282
283
284
# File 'lib/review/idgxmlbuilder.rb', line 282

def dl_end
  puts '</dl>'
end

#dt(line) ⇒ Object



274
275
276
# File 'lib/review/idgxmlbuilder.rb', line 274

def dt(line)
  puts "<dt>#{line}</dt>"
end

#dtp(str) ⇒ Object



1052
1053
1054
# File 'lib/review/idgxmlbuilder.rb', line 1052

def dtp(str)
  print %Q(<?dtp #{str} ?>)
end

#edition_begin(level, label, caption) ⇒ Object



853
854
855
# File 'lib/review/idgxmlbuilder.rb', line 853

def edition_begin(level, label, caption)
  common_column_begin("edition", caption)
end

#edition_end(level) ⇒ Object



857
858
859
# File 'lib/review/idgxmlbuilder.rb', line 857

def edition_end(level)
  common_column_end("edition")
end

#emlist(lines, caption = nil, lang = nil) ⇒ Object



359
360
361
# File 'lib/review/idgxmlbuilder.rb', line 359

def emlist(lines, caption = nil, lang = nil)
  quotedlist lines, 'emlist', caption
end

#emlistnum(lines, caption = nil, lang = nil) ⇒ Object



363
364
365
366
367
368
369
# File 'lib/review/idgxmlbuilder.rb', line 363

def emlistnum(lines, caption = nil, lang = nil)
  _lines = []
  lines.each_with_index do |line, i|
    _lines << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
  end
  quotedlist _lines, 'emlistnum', caption
end

#error(msg) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/review/idgxmlbuilder.rb', line 107

def error(msg)
  if @no_error
    @errors.push [@location.filename, @location.lineno, msg]
    puts "----ERROR: #{escape_html(msg)}----"
  else
    $stderr.puts "#{@location}: error: #{msg}"
  end
end

#error_messagesObject



120
121
122
123
124
125
126
127
128
# File 'lib/review/idgxmlbuilder.rb', line 120

def error_messages
  return '' if @errors.empty?
  "<h2>Syntax Errors</h2>\n" +
  "<ul>\n" +
  @errors.map {|file, line, msg|
    "<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n"
  }.join('') +
  "</ul>\n"
end

#expert(lines) ⇒ Object



989
990
991
# File 'lib/review/idgxmlbuilder.rb', line 989

def expert(lines)
  captionblock("expert", lines, nil)
end

#extnameObject



47
48
49
# File 'lib/review/idgxmlbuilder.rb', line 47

def extname
  '.xml'
end

#flushright(lines) ⇒ Object



893
894
895
# File 'lib/review/idgxmlbuilder.rb', line 893

def flushright(lines)
  puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
end

#footnote(id, str) ⇒ Object



634
635
636
# File 'lib/review/idgxmlbuilder.rb', line 634

def footnote(id, str)
  # see inline_fn
end

#handle_metric(str) ⇒ Object



450
451
452
453
# File 'lib/review/idgxmlbuilder.rb', line 450

def handle_metric(str)
  k, v = str.split('=', 2)
  return %Q|#{k}=\"#{v.sub(/\A["']/, '').sub(/["']\Z/, '')}\"|
end

#headline(level, label, caption) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/review/idgxmlbuilder.rb', line 140

def headline(level, label, caption)
  case level
  when 1
    unless @secttags.nil?
      print "</sect4>" if @subsubsubsection > 0
      print "</sect3>" if @subsubsection > 0
      print "</sect2>" if @subsection > 0
      print "</sect>" if @section > 0
    end

    print %Q(<chapter id="chap:#{@chapter.number}">) unless @secttags.nil?

    @section = 0
    @subsection = 0
    @subsubsection = 0
    @subsubsubsection = 0
  when 2
    unless @secttags.nil?
      print "</sect4>" if @subsubsubsection > 0
      print "</sect3>" if @subsubsection > 0
      print "</sect2>" if @subsection > 0
      print "</sect>" if @section > 0
    end
    @section += 1
    print %Q(<sect id="sect:#{@chapter.number}.#{@section}">) unless @secttags.nil?
  
    @subsection = 0
    @subsubsection = 0
    @subsubsubsection = 0
  when 3
    unless @secttags.nil?
      print "</sect4>" if @subsubsubsection > 0
      print "</sect3>" if @subsubsection > 0
      print "</sect2>" if @subsection > 0
    end

    @subsection += 1
    print %Q(<sect2 id="sect:#{@chapter.number}.#{@section}.#{@subsection}">) unless @secttags.nil?

    @subsubsection = 0
    @subsubsubsection = 0
  when 4
    unless @secttags.nil?
      print "</sect4>" if @subsubsubsection > 0
      print "</sect3>" if @subsubsection > 0
    end

    @subsubsection += 1
    print %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) unless @secttags.nil?

    @subsubsubsection = 0
  when 5
    unless @secttags.nil?
      print "</sect4>" if @subsubsubsection > 0
    end

    @subsubsubsection += 1
    print %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) unless @secttags.nil?
  else
    raise "caption level too deep or unsupported: #{level}"
  end

  prefix, anchor = headline_prefix(level)

  label = label.nil? ? "" : " id=\"#{label}\""
  toccaption = escape_html(compile_inline(caption.gsub(/@<fn>\{.+?\}/, '')).gsub(/<[^>]+>/, ''))
  puts %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{prefix}#{toccaption}"?>)
end

#hood_begin(level, label, caption) ⇒ Object



845
846
847
# File 'lib/review/idgxmlbuilder.rb', line 845

def hood_begin(level, label, caption)
  common_column_begin("hood", caption)
end

#hood_end(level) ⇒ Object



849
850
851
# File 'lib/review/idgxmlbuilder.rb', line 849

def hood_end(level)
  common_column_end("hood")
end

#hrObject



1056
1057
1058
# File 'lib/review/idgxmlbuilder.rb', line 1056

def hr
  print "<hr />"
end

#image_dummy(id, caption, lines) ⇒ Object



467
468
469
470
471
472
473
474
475
476
477
478
# File 'lib/review/idgxmlbuilder.rb', line 467

def image_dummy(id, caption, lines)
  puts "<img>"
  print %Q[<pre aid:pstyle="dummyimage">]
  lines.each do |line|
    print detab(line)
    print "\n"
  end
  print %Q[</pre>]
  image_header id, caption
  puts "</img>"
  warn "no such image: #{id}"
end

#image_extObject



1185
1186
1187
# File 'lib/review/idgxmlbuilder.rb', line 1185

def image_ext
  "eps"
end

#image_header(id, caption) ⇒ Object



480
481
482
483
484
485
486
# File 'lib/review/idgxmlbuilder.rb', line 480

def image_header(id, caption)
  if get_chap.nil?
    puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
  else
    puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
  end
end

#image_image(id, caption, metric = nil) ⇒ Object



459
460
461
462
463
464
465
# File 'lib/review/idgxmlbuilder.rb', line 459

def image_image(id, caption, metric=nil)
  metrics = parse_metric("idgxml", metric)
  puts "<img>"
  puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}"#{metrics} />]
  image_header id, caption
  puts "</img>"
end

#imgtable(lines, id, caption = nil, metric = nil) ⇒ Object



617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/review/idgxmlbuilder.rb', line 617

def imgtable(lines, id, caption = nil, metric = nil)
  if @chapter.image(id).bound?
    metrics = parse_metric("idgxml", metric)
    puts "<table>"
    table_header id, caption
    puts %Q[<imgtable><Image href="file://#{@chapter.image(id).path.sub(/\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



933
934
935
# File 'lib/review/idgxmlbuilder.rb', line 933

def important(lines, caption = nil)
  captionblock("important", lines, caption)
end

#indepimage(id, caption = nil, metric = nil) ⇒ Object Also known as: numberlessimage



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
# File 'lib/review/idgxmlbuilder.rb', line 1029

def indepimage(id, caption=nil, metric=nil)
  metrics = parse_metric("idgxml", metric)
  puts "<img>"
  begin
    puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}"#{metrics} />]
  rescue
    warn %Q[no such image: #{id}]
  end
  puts %Q[<caption>#{compile_inline(caption)}</caption>] if caption.present?
  puts "</img>"
end

#info(lines, caption = nil) ⇒ Object



921
922
923
# File 'lib/review/idgxmlbuilder.rb', line 921

def info(lines, caption = nil)
  captionblock("info", lines, caption)
end

#inline_ami(str) ⇒ Object



713
714
715
# File 'lib/review/idgxmlbuilder.rb', line 713

def inline_ami(str)
  %Q(<ami>#{escape_html(str)}</ami>)
end

#inline_b(str) ⇒ Object



721
722
723
# File 'lib/review/idgxmlbuilder.rb', line 721

def inline_b(str)
  %Q(<b>#{escape_html(str)}</b>)
end

#inline_balloon(str) ⇒ Object



770
771
772
# File 'lib/review/idgxmlbuilder.rb', line 770

def inline_balloon(str)
  %Q[<balloon>#{escape_html(str).gsub(/@maru\[(\d+)\]/) {|m| inline_maru($1)}}</balloon>]
end

#inline_bib(id) ⇒ Object



1162
1163
1164
# File 'lib/review/idgxmlbuilder.rb', line 1162

def inline_bib(id)
  %Q(<span type='bibref' idref='#{id}'>[#{@chapter.bibpaper(id).number}]</span>)
end

#inline_bou(str) ⇒ Object



752
753
754
# File 'lib/review/idgxmlbuilder.rb', line 752

def inline_bou(str)
  %Q[<bou>#{escape_html(str)}</bou>]
end

#inline_br(str) ⇒ Object



1072
1073
1074
# File 'lib/review/idgxmlbuilder.rb', line 1072

def inline_br(str)
  "\n"
end

#inline_chap(id) ⇒ Object



1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
# File 'lib/review/idgxmlbuilder.rb', line 1111

def inline_chap(id)
  if @book.config["chapterlink"]
    %Q(<link href="#{id}">#{@book.chapter_index.number(id)}</link>)
  else
    @book.chapter_index.number(id)
  end
rescue KeyError
  error "unknown chapter: #{id}"
  nofunc_text("[UnknownChapter:#{id}]")
end

#inline_chapref(id) ⇒ Object



1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
# File 'lib/review/idgxmlbuilder.rb', line 1089

def inline_chapref(id)
  chs = ["", "", ""]
  unless @book.config["chapref"].nil?
    _chs = @book.config["chapref"].split(",")
    if _chs.size != 3
      error "--chapsplitter must have exactly 3 parameters with comma."
    else
      chs = _chs
    end
  else
  end
  s = "#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
  if @book.config["chapterlink"]
    %Q(<link href="#{id}">#{s}</link>)
  else
    s
  end
rescue KeyError
  error "unknown chapter: #{id}"
  nofunc_text("[UnknownChapter:#{id}]")
end

#inline_code(str) ⇒ Object



1068
1069
1070
# File 'lib/review/idgxmlbuilder.rb', line 1068

def inline_code(str)
  %Q[<tt type='inline-code'>#{escape_html(str)}</tt>]
end

#inline_column_chap(chapter, id) ⇒ Object



311
312
313
314
315
316
317
# File 'lib/review/idgxmlbuilder.rb', line 311

def inline_column_chap(chapter, id)
  if @book.config["chapterlink"]
    %Q(<link href="#{column_label(id)}">#{escape_html(chapter.column(id).caption)}</link>)
  else
    escape_html(chapter.column(id).caption)
  end
end

#inline_dtp(str) ⇒ Object



1064
1065
1066
# File 'lib/review/idgxmlbuilder.rb', line 1064

def inline_dtp(str)
  "<?dtp #{str} ?>"
end

#inline_fn(id) ⇒ Object



638
639
640
# File 'lib/review/idgxmlbuilder.rb', line 638

def inline_fn(id)
  %Q[<footnote>#{compile_inline(@chapter.footnote(id).content.strip)}</footnote>]
end

#inline_hd_chap(chap, id) ⇒ Object



1166
1167
1168
1169
1170
1171
1172
1173
1174
# File 'lib/review/idgxmlbuilder.rb', line 1166

def inline_hd_chap(chap, id)
  if chap.number
    n = chap.headline_index.number(id)
    if @book.config["secnolevel"] >= n.split('.').size
      return I18n.t("chapter_quote", "#{n} #{compile_inline(chap.headline(id).caption)}")
    end
  end
  I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
end

#inline_hidx(str) ⇒ Object



709
710
711
# File 'lib/review/idgxmlbuilder.rb', line 709

def inline_hidx(str)
  %Q(<index value="#{escape_html(str)}" />)
end

#inline_hint(str) ⇒ Object



677
678
679
680
681
682
683
# File 'lib/review/idgxmlbuilder.rb', line 677

def inline_hint(str)
  if @book.config["nolf"].nil?
    %Q[\n<hint>#{escape_html(str)}</hint>]
  else
    %Q[<hint>#{escape_html(str)}</hint>]
  end
end

#inline_i(str) ⇒ Object



717
718
719
# File 'lib/review/idgxmlbuilder.rb', line 717

def inline_i(str)
  %Q(<i>#{escape_html(str)}</i>)
end

#inline_icon(id) ⇒ Object



743
744
745
746
747
748
749
750
# File 'lib/review/idgxmlbuilder.rb', line 743

def inline_icon(id)
  begin
    %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}" type="inline" />]
  rescue
    warn "no such icon image: #{id}"
    ""
  end
end

#inline_idx(str) ⇒ Object



705
706
707
# File 'lib/review/idgxmlbuilder.rb', line 705

def inline_idx(str)
  %Q(#{escape_html(str)}<index value="#{escape_html(str)}" />)
end

#inline_img(id) ⇒ Object



428
429
430
431
432
433
434
435
# File 'lib/review/idgxmlbuilder.rb', line 428

def inline_img(id)
  chapter, id = extract_chapter_id(id)
  if get_chap(chapter).nil?
    "<span type='image'>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}</span>"
  else
    "<span type='image'>#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}</span>"
  end
end

#inline_imgref(id) ⇒ Object



437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/review/idgxmlbuilder.rb', line 437

def inline_imgref(id)
  chapter, id = extract_chapter_id(id)
  if chapter.image(id).caption.blank?
    inline_img(id)
  else
    if get_chap(chapter).nil?
      "<span type='image'>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}#{I18n.t('image_quote', chapter.image(id).caption)}</span>"
    else
      "<span type='image'>#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}#{I18n.t('image_quote', chapter.image(id).caption)}</span>"
    end
  end
end

#inline_keytop(str) ⇒ Object



756
757
758
# File 'lib/review/idgxmlbuilder.rb', line 756

def inline_keytop(str)
  %Q[<keytop>#{escape_html(str)}</keytop>]
end

#inline_labelref(idref) ⇒ Object Also known as: inline_ref



760
761
762
# File 'lib/review/idgxmlbuilder.rb', line 760

def inline_labelref(idref)
  %Q[<ref idref='#{escape_html(idref)}'>「#{I18n.t("label_marker")}#{escape_html(idref)}」</ref>] # FIXME:節名とタイトルも込みで要出力
end

#inline_list(id) ⇒ Object



319
320
321
322
323
324
325
326
# File 'lib/review/idgxmlbuilder.rb', line 319

def inline_list(id)
  chapter, id = extract_chapter_id(id)
  if get_chap(chapter).nil?
    "<span type='list'>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [chapter.list(id).number])}</span>"
  else
    "<span type='list'>#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), chapter.list(id).number])}</span>"
  end
end

#inline_m(str) ⇒ Object



778
779
780
781
# File 'lib/review/idgxmlbuilder.rb', line 778

def inline_m(str)
  @texinlineequation += 1
  %Q[<replace idref="texinline-#{@texinlineequation}"><pre>#{escape_html(str)}</pre></replace>]
end

#inline_maru(str) ⇒ Object



685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
# File 'lib/review/idgxmlbuilder.rb', line 685

def inline_maru(str)
  if str =~ /\A\d+\Z/
    sprintf("&#x%x;", 9311 + str.to_i)
  elsif str =~ /\A[A-Z]\Z/
    begin
      sprintf("&#x%x;", 9398 + str.codepoints.to_a[0] - 65)
    rescue NoMethodError
      sprintf("&#x%x;", 9398 + str[0] - 65)
    end
  elsif str =~ /\A[a-z]\Z/
    begin
      sprintf("&#x%x;", 9392 + str.codepoints.to_a[0] - 65)
    rescue NoMethodError
      sprintf("&#x%x;", 9392 + str[0] - 65)
    end
  else
    raise "can't parse maru: #{str}"
  end
end

#inline_pageref(idref) ⇒ Object



766
767
768
# File 'lib/review/idgxmlbuilder.rb', line 766

def inline_pageref(idref)
  %Q[<pageref idref='#{escape_html(idref)}'>●●</pageref>] # ページ番号を参照
end

#inline_raw(str) ⇒ Object



673
674
675
# File 'lib/review/idgxmlbuilder.rb', line 673

def inline_raw(str)
  %Q[#{super(str).gsub("\\n", "\n")}]
end

#inline_recipe(id) ⇒ Object



1176
1177
1178
1179
# File 'lib/review/idgxmlbuilder.rb', line 1176

def inline_recipe(id)
  # FIXME
  %Q(<recipe idref="#{escape_html(id)}">[XXX]「#{escape_html(id)}」 p.XX</recipe>)
end

#inline_sub(str) ⇒ Object



669
670
671
# File 'lib/review/idgxmlbuilder.rb', line 669

def inline_sub(str)
  %Q[<sub>#{escape_html(str)}</sub>]
end

#inline_sup(str) ⇒ Object



665
666
667
# File 'lib/review/idgxmlbuilder.rb', line 665

def inline_sup(str)
  %Q[<sup>#{escape_html(str)}</sup>]
end

#inline_table(id) ⇒ Object



419
420
421
422
423
424
425
426
# File 'lib/review/idgxmlbuilder.rb', line 419

def inline_table(id)
  chapter, id = extract_chapter_id(id)
  if get_chap(chapter).nil?
    "<span type='table'>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}</span>"
  else
    "<span type='table'>#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}</span>"
  end
end

#inline_title(id) ⇒ Object



1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
# File 'lib/review/idgxmlbuilder.rb', line 1122

def inline_title(id)
  title = super
  if @book.config["chapterlink"]
    %Q(<link href="#{id}">#{title}</link>)
  else
    title
  end
rescue KeyError
  error "unknown chapter: #{id}"
  nofunc_text("[UnknownChapter:#{id}]")
end

#inline_tt(str) ⇒ Object



725
726
727
# File 'lib/review/idgxmlbuilder.rb', line 725

def inline_tt(str)
  %Q(<tt>#{escape_html(str)}</tt>)
end

#inline_ttb(str) ⇒ Object Also known as: inline_ttbold



729
730
731
# File 'lib/review/idgxmlbuilder.rb', line 729

def inline_ttb(str)
  %Q(<tt style='bold'>#{escape_html(str)}</tt>)
end

#inline_tti(str) ⇒ Object



735
736
737
# File 'lib/review/idgxmlbuilder.rb', line 735

def inline_tti(str)
  %Q(<tt style='italic'>#{escape_html(str)}</tt>)
end

#inline_u(str) ⇒ Object



739
740
741
# File 'lib/review/idgxmlbuilder.rb', line 739

def inline_u(str)
  %Q(<underline>#{escape_html(str)}</underline>)
end

#inline_uchar(str) ⇒ Object



774
775
776
# File 'lib/review/idgxmlbuilder.rb', line 774

def inline_uchar(str)
  %Q[&#x#{str};]
end

#insideout_begin(level, label, caption) ⇒ Object



861
862
863
# File 'lib/review/idgxmlbuilder.rb', line 861

def insideout_begin(level, label, caption)
  common_column_begin("insideout", caption)
end

#insideout_end(level) ⇒ Object



865
866
867
# File 'lib/review/idgxmlbuilder.rb', line 865

def insideout_end(level)
  common_column_end("insideout")
end

#insn(lines, caption = nil) ⇒ Object



1021
1022
1023
# File 'lib/review/idgxmlbuilder.rb', line 1021

def insn(lines, caption = nil)
  syntaxblock("insn", lines, caption)
end

#label(id) ⇒ Object



1043
1044
1045
1046
# File 'lib/review/idgxmlbuilder.rb', line 1043

def label(id)
  # FIXME
  print "<label id='#{id}' />"
end

#linebreakObject



787
788
789
790
# File 'lib/review/idgxmlbuilder.rb', line 787

def linebreak
  # FIXME:pが閉じちゃってるので一度戻らないといけないが、難しい…。
  puts "<br />"
end


953
954
955
# File 'lib/review/idgxmlbuilder.rb', line 953

def link(lines, caption = nil)
  captionblock("link", lines, caption)
end

#list_body(id, lines, lang) ⇒ Object



353
354
355
356
357
# File 'lib/review/idgxmlbuilder.rb', line 353

def list_body(id, lines, lang)
  print %Q(<pre>)
  codelines_body(lines)
  puts "</pre></codelist>"
end

#list_header(id, caption, lang) ⇒ Object



328
329
330
331
332
333
334
335
# File 'lib/review/idgxmlbuilder.rb', line 328

def list_header(id, caption, lang)
  puts %Q[<codelist>]
  if get_chap.nil?
    puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
  else
    puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
  end
end

#listnum_body(lines, lang) ⇒ Object



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/review/idgxmlbuilder.rb', line 371

def listnum_body(lines, lang)
  print %Q(<pre>)
  no = 1
  lines.each_with_index do |line, i|
    unless @book.config["listinfo"].nil?
      print "<listinfo line=\"#{no}\""
      print " begin=\"1\"" if no == 1
      print " end=\"#{no}\"" if no == lines.size
      print ">"
    end
    print detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
    print "\n"
    print "</listinfo>" unless @book.config["listinfo"].nil?
    no += 1
  end
  puts "</pre></codelist>"
end

#memo(lines, caption = nil) ⇒ Object



913
914
915
# File 'lib/review/idgxmlbuilder.rb', line 913

def memo(lines, caption = nil)
  captionblock("memo", lines, caption)
end

#messagesObject



116
117
118
# File 'lib/review/idgxmlbuilder.rb', line 116

def messages
  error_messages() + warning_messages()
end

#nofunc_text(str) ⇒ Object



1181
1182
1183
# File 'lib/review/idgxmlbuilder.rb', line 1181

def nofunc_text(str)
  escape_html(str)
end

#noindentObject



783
784
785
# File 'lib/review/idgxmlbuilder.rb', line 783

def noindent
  @noindent = true
end

#nonum_begin(level, label, caption) ⇒ Object



796
797
798
# File 'lib/review/idgxmlbuilder.rb', line 796

def nonum_begin(level, label, caption)
  puts %Q[<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{escape_html(compile_inline(caption))}"?>]
end

#nonum_end(level) ⇒ Object



800
801
# File 'lib/review/idgxmlbuilder.rb', line 800

def nonum_end(level)
end

#note(lines, caption = nil) ⇒ Object



909
910
911
# File 'lib/review/idgxmlbuilder.rb', line 909

def note(lines, caption = nil)
  captionblock("note", lines, caption)
end

#notice(lines, caption = nil) ⇒ Object



957
958
959
960
961
962
963
# File 'lib/review/idgxmlbuilder.rb', line 957

def notice(lines, caption = nil)
  if caption.nil?
    captionblock("notice", lines, nil)
  else
    captionblock("notice-t", lines, caption, "notice-title")
  end
end

#ol_beginObject



249
250
251
252
253
254
# File 'lib/review/idgxmlbuilder.rb', line 249

def ol_begin
  puts '<ol>'
  if !@ol_num
    @ol_num = 1
  end
end

#ol_endObject



261
262
263
264
# File 'lib/review/idgxmlbuilder.rb', line 261

def ol_end
  puts '</ol>'
  @ol_num = nil
end

#ol_item(lines, num) ⇒ Object



256
257
258
259
# File 'lib/review/idgxmlbuilder.rb', line 256

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



266
267
268
# File 'lib/review/idgxmlbuilder.rb', line 266

def olnum(num)
  @ol_num = num.to_i
end

#pagebreakObject



792
793
794
# File 'lib/review/idgxmlbuilder.rb', line 792

def pagebreak
  puts "<pagebreak />"
end

#paragraph(lines) ⇒ Object



286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/review/idgxmlbuilder.rb', line 286

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



925
926
927
# File 'lib/review/idgxmlbuilder.rb', line 925

def planning(lines, caption = nil)
  captionblock("planning", lines, caption)
end

#point(lines, caption = nil) ⇒ Object



965
966
967
968
969
970
971
# File 'lib/review/idgxmlbuilder.rb', line 965

def point(lines, caption = nil)
  if caption.nil?
    captionblock("point", lines, nil)
  else
    captionblock("point-t", lines, caption, "point-title")
  end
end

#post_paragraphObject



43
44
45
# File 'lib/review/idgxmlbuilder.rb', line 43

def post_paragraph
  '</p>'
end

#practice(lines) ⇒ Object



985
986
987
# File 'lib/review/idgxmlbuilder.rb', line 985

def practice(lines)
  captionblock("practice", lines, nil)
end

#pre_paragraphObject



39
40
41
# File 'lib/review/idgxmlbuilder.rb', line 39

def pre_paragraph
  '<p>'
end

#puts(arg) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/review/idgxmlbuilder.rb', line 78

def puts(arg)
  if @book.config["nolf"].present?
    print arg
  else
    super
  end
end

#quote(lines) ⇒ Object



414
415
416
417
# File 'lib/review/idgxmlbuilder.rb', line 414

def quote(lines)
  blocked_lines = split_paragraph(lines)
  puts "<quote>#{blocked_lines.join("")}</quote>"
end

#rawblock(lines) ⇒ Object



1076
1077
1078
1079
1080
1081
1082
1083
# File 'lib/review/idgxmlbuilder.rb', line 1076

def rawblock(lines)
  no = 1
  lines.each do |l|
    print l.gsub("&lt;", "<").gsub("&gt;", ">").gsub("&quot;", "\"").gsub("&amp;", "&")
    print "\n" unless lines.length == no
    no += 1
  end
end

#read(lines) ⇒ Object Also known as: lead



299
300
301
# File 'lib/review/idgxmlbuilder.rb', line 299

def read(lines)
  puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
end

#ref_begin(level, label, caption) ⇒ Object



869
870
871
872
873
874
875
# File 'lib/review/idgxmlbuilder.rb', line 869

def ref_begin(level, label, caption)
  if !label.nil?
    puts "<reference id='#{label}'>"
  else
    puts "<reference>"
  end
end

#ref_end(level) ⇒ Object



877
878
879
# File 'lib/review/idgxmlbuilder.rb', line 877

def ref_end(level)
  puts "</reference>"
end

#reference(lines) ⇒ Object



981
982
983
# File 'lib/review/idgxmlbuilder.rb', line 981

def reference(lines)
  captionblock("reference", lines, nil)
end

#resultObject



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/review/idgxmlbuilder.rb', line 86

def result
  s = ""
  unless @secttags.nil?
    s += "</sect4>" if @subsubsubsection > 0
    s += "</sect3>" if @subsubsection > 0
    s += "</sect2>" if @subsection > 0
    s += "</sect>" if @section > 0
    s += "</chapter>" if @chapter.number > 0
  end
  messages() + @output.string + s + "</#{@rootelement}>\n"
end

#result_metric(array) ⇒ Object



455
456
457
# File 'lib/review/idgxmlbuilder.rb', line 455

def result_metric(array)
  " #{array.join(' ')}"
end

#security(lines, caption = nil) ⇒ Object



937
938
939
# File 'lib/review/idgxmlbuilder.rb', line 937

def security(lines, caption = nil)
  captionblock("security", lines, caption)
end

#shoot(lines, caption = nil) ⇒ Object



973
974
975
976
977
978
979
# File 'lib/review/idgxmlbuilder.rb', line 973

def shoot(lines, caption = nil)
  if caption.nil?
    captionblock("shoot", lines, nil)
  else
    captionblock("shoot-t", lines, caption, "shoot-title")
  end
end

#source_body(lines, lang) ⇒ Object



1139
1140
1141
1142
1143
# File 'lib/review/idgxmlbuilder.rb', line 1139

def source_body(lines, lang)
  puts %Q[<pre>]
  codelines_body(lines)
  puts %Q[</pre></source>]
end

#source_header(caption) ⇒ Object



1134
1135
1136
1137
# File 'lib/review/idgxmlbuilder.rb', line 1134

def source_header(caption)
  puts %Q[<source>]
  puts %Q[<caption>#{compile_inline(caption)}</caption>]
end

#sup_begin(level, label, caption) ⇒ Object



881
882
883
884
885
886
887
# File 'lib/review/idgxmlbuilder.rb', line 881

def sup_begin(level, label, caption)
  if !label.nil?
    puts "<supplement id='#{label}'>"
  else
    puts "<supplement>"
  end
end

#sup_end(level) ⇒ Object



889
890
891
# File 'lib/review/idgxmlbuilder.rb', line 889

def sup_end(level)
  puts "</supplement>"
end

#syntaxblock(type, lines, caption) ⇒ Object



993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# File 'lib/review/idgxmlbuilder.rb', line 993

def syntaxblock(type, lines, caption)
  if caption.nil?
    puts %Q[<#{type}>]
  else
    titleopentag = %Q[caption aid:pstyle="#{type}-title"]
    titleclosetag = "caption"
    if type == "insn"
      titleopentag = %Q[floattitle type="insn"]
      titleclosetag = "floattitle"
    end
    puts %Q[<#{type}><#{titleopentag}>#{compile_inline(caption)}</#{titleclosetag}>]
  end
  no = 1
  lines.each do |line|
    unless @book.config["listinfo"].nil?
      print %Q[<listinfo line="#{no}"]
      print %Q[ begin="1"] if no == 1
      print %Q[ end="#{no}"] if no == lines.size
      print %Q[>]
    end
    print detab(line)
    print "\n"
    print "</listinfo>" unless @book.config["listinfo"].nil?
    no += 1
  end
  puts "</#{type}>"
end

#table(lines, id = nil, caption = nil) ⇒ Object



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
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File 'lib/review/idgxmlbuilder.rb', line 497

def table(lines, id = nil, caption = nil)
  tablewidth = nil
  col = 0
  if @book.config["tableopt"]
    tablewidth = @book.config["tableopt"].split(",")[0].to_f / @book.config["pt_to_mm_unit"].to_f
  end
  puts "<table>"
  rows = []
  sepidx = nil
  lines.each_with_index do |line, idx|
    if /\A[\=\-]{12}/ =~ line
      sepidx ||= idx
      next
    end
    if tablewidth.nil?
      rows.push(line.gsub(/\t\.\t/, "\t\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\t").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ""))
    else
      rows.push(line.gsub(/\t\.\t/, "\tDUMMYCELLSPLITTER\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\tDUMMYCELLSPLITTER").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ""))
    end
    _col = rows[rows.length - 1].split(/\t/).length
    col = _col if _col > col
  end

  cellwidth = []
  unless tablewidth.nil?
    if @tsize.nil?
      col.times {|n| cellwidth[n] = tablewidth / col }
    else
      cellwidth = @tsize.split(/\s*,\s*/)
      totallength = 0
      cellwidth.size.times do |n|
        cellwidth[n] = cellwidth[n].to_f / @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
        for i in cellwidth.size..(col - 1)
          cellwidth[i] = cw
        end
      end
    end
  end

  begin
    table_header id, caption unless caption.nil?
  rescue KeyError
    error "no such table: #{id}"
  end
  return if rows.empty?

  if tablewidth.nil?
    print "<tbody>"
  else
    print %Q[<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">]
  end

  if sepidx
    sepidx.times do |y|
      if tablewidth.nil?
        puts %Q[<tr type="header">#{rows.shift}</tr>]
      else
        i = 0
        rows.shift.split(/\t/).each_with_index do |cell, x|
          print %Q[<td xyh="#{x + 1},#{y + 1},#{sepidx}" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.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



598
599
# File 'lib/review/idgxmlbuilder.rb', line 598

def table_begin(ncols)
end

#table_endObject



613
614
615
# File 'lib/review/idgxmlbuilder.rb', line 613

def table_end
  print "<?dtp tablerow last?>"
end

#table_header(id, caption) ⇒ Object



590
591
592
593
594
595
596
# File 'lib/review/idgxmlbuilder.rb', line 590

def table_header(id, caption)
  if get_chap.nil?
  puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
  else
    puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
  end
end

#td(str) ⇒ Object



609
610
611
# File 'lib/review/idgxmlbuilder.rb', line 609

def td(str)
  str
end

#term(lines) ⇒ Object



949
950
951
# File 'lib/review/idgxmlbuilder.rb', line 949

def term(lines)
  captionblock("term", lines, nil)
end

#texequation(lines) ⇒ Object



488
489
490
491
492
493
494
495
# File 'lib/review/idgxmlbuilder.rb', line 488

def texequation(lines)
  @texblockequation += 1
  puts %Q[<replace idref="texblock-#{@texblockequation}">]
  puts '<pre>'
  puts "#{lines.join("\n")}"
  puts '</pre>'
  puts '</replace>'
end

#text(str) ⇒ Object



1085
1086
1087
# File 'lib/review/idgxmlbuilder.rb', line 1085

def text(str)
  str
end

#th(str) ⇒ Object



605
606
607
# File 'lib/review/idgxmlbuilder.rb', line 605

def th(str)
  %Q[<?dtp tablerow header?>#{str}]
end

#tip(lines, caption = nil) ⇒ Object



917
918
919
# File 'lib/review/idgxmlbuilder.rb', line 917

def tip(lines, caption = nil)
  captionblock("tip", lines, caption)
end

#tr(rows) ⇒ Object



601
602
603
# File 'lib/review/idgxmlbuilder.rb', line 601

def tr(rows)
  puts %Q[<tr>#{rows.join("\t")}</tr>]
end

#trputs(tablewidth, rows, cellwidth, sepidx) ⇒ Object



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/review/idgxmlbuilder.rb', line 573

def trputs(tablewidth, rows, cellwidth, sepidx)
  sepidx = 0 if sepidx.nil?
  if tablewidth.nil?
    lastline = rows.pop
    rows.each {|row| puts %Q[<tr>#{row}</tr>] }
    puts %Q[<tr type="lastline">#{lastline}</tr>] unless lastline.nil?
  else
    rows.each_with_index do |row, y|
      i = 0
      row.split(/\t/).each_with_index do |cell, x|
        print %Q[<td xyh="#{x + 1},#{y + 1 + sepidx},#{sepidx}" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.3f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
        i += 1
      end
    end
  end
end

#tsize(str) ⇒ Object



1048
1049
1050
# File 'lib/review/idgxmlbuilder.rb', line 1048

def tsize(str)
  @tsize = str
end

#ul_beginObject



209
210
211
212
213
# File 'lib/review/idgxmlbuilder.rb', line 209

def ul_begin
  level = block_given? ? yield : ""
  level = nil if level == 1
  puts "<ul#{level == 1 ? nil : level}>"
end

#ul_endObject



243
244
245
246
247
# File 'lib/review/idgxmlbuilder.rb', line 243

def ul_end
  level = block_given? ? yield : ""
  level = nil if level == 1
  puts "</ul#{level}>"
end

#ul_item(lines) ⇒ Object



215
216
217
# File 'lib/review/idgxmlbuilder.rb', line 215

def ul_item(lines)
  puts %Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>)
end

#ul_item_begin(lines) ⇒ Object



219
220
221
# File 'lib/review/idgxmlbuilder.rb', line 219

def ul_item_begin(lines)
  print %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
end

#ul_item_endObject



223
224
225
# File 'lib/review/idgxmlbuilder.rb', line 223

def ul_item_end
  puts "</li>"
end

#warn(msg) ⇒ Object



98
99
100
101
102
103
104
105
# File 'lib/review/idgxmlbuilder.rb', line 98

def warn(msg)
  if @no_error
    @warns.push [@location.filename, @location.lineno, msg]
    puts "----WARNING: #{escape_html(msg)}----"
  else
    $stderr.puts "#{@location}: warning: #{msg}"
  end
end

#warning(lines, caption = nil) ⇒ Object



945
946
947
# File 'lib/review/idgxmlbuilder.rb', line 945

def warning(lines, caption = nil)
  captionblock("warning", lines, caption)
end

#warning_messagesObject



130
131
132
133
134
135
136
137
138
# File 'lib/review/idgxmlbuilder.rb', line 130

def warning_messages
  return '' if @warns.empty?
  "<h2>Warnings</h2>\n" +
  "<ul>\n" +
  @warns.map {|file, line, msg|
    "<li>#{escape_html(file)}:#{line}: #{escape_html(msg)}</li>\n"
  }.join('') +
  "</ul>\n"
end

#world_begin(level, label, caption) ⇒ Object



837
838
839
# File 'lib/review/idgxmlbuilder.rb', line 837

def world_begin(level, label, caption)
  common_column_begin("world", caption)
end

#world_end(level) ⇒ Object



841
842
843
# File 'lib/review/idgxmlbuilder.rb', line 841

def world_end(level)
  common_column_end("world")
end

#xcolumn_begin(level, label, caption) ⇒ Object



829
830
831
# File 'lib/review/idgxmlbuilder.rb', line 829

def xcolumn_begin(level, label, caption)
  common_column_begin("x", caption)
end

#xcolumn_end(level) ⇒ Object



833
834
835
# File 'lib/review/idgxmlbuilder.rb', line 833

def xcolumn_end(level)
  common_column_end("x")
end