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_html, #highlight, #strip_html, #unescape_html

Methods included from TextUtils

#convert_inencoding, #convert_outencoding, #detab, #split_paragraph

Methods inherited from Builder

#bind, #compile_inline, #detab, #entries, #extract_chapter_id, #find_pathes, #get_chap, #graph, #image, #include, #initialize, #inline_hd, #inline_href, #inline_include, #inline_kw, #inline_ruby, #list, #listnum, #parse_metric, #print, #puts, #raw, #source

Constructor Details

This class inherits a constructor from ReVIEW::Builder

Instance Method Details

#best(lines, caption = nil) ⇒ Object



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

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

#bibpaper(lines, id, caption) ⇒ Object



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

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



1165
1166
1167
# File 'lib/review/idgxmlbuilder.rb', line 1165

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

#bibpaper_header(id, caption) ⇒ Object



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

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



1032
1033
1034
# File 'lib/review/idgxmlbuilder.rb', line 1032

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

#bpo(lines) ⇒ Object



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

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

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



908
909
910
911
912
913
914
915
916
917
918
# File 'lib/review/idgxmlbuilder.rb', line 908

def captionblock(type, lines, caption, specialstyle = nil)
  print "<#{type}>"
  style = specialstyle.nil? ? "#{type}-title" : specialstyle
  puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
  if ReVIEW.book.param["deprecated-blocklines"].nil?
    blocked_lines = split_paragraph(lines)
    puts "#{blocked_lines.join}</#{type}>"
  else
    puts "#{lines.join("\n")}</#{type}>"
  end
end

#caution(lines, caption = nil) ⇒ Object



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

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

#centering(lines) ⇒ Object



904
905
906
# File 'lib/review/idgxmlbuilder.rb', line 904

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

#choice_multi_beginObject



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

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

#choice_multi_endObject



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

def choice_multi_end
  puts "</choice>"
end

#choice_single_beginObject



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

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

#choice_single_endObject



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

def choice_single_end
  puts "</choice>"
end

#circle_begin(level, label, caption) ⇒ Object



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

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

#circle_end(level) ⇒ Object



812
813
# File 'lib/review/idgxmlbuilder.rb', line 812

def circle_end(level)
end

#cmd(lines, caption = nil) ⇒ Object



409
410
411
# File 'lib/review/idgxmlbuilder.rb', line 409

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

#codelines_body(lines) ⇒ Object



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/review/idgxmlbuilder.rb', line 357

def codelines_body(lines)
  no = 1
  lines.each do |line|
    unless ReVIEW.book.param["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 ReVIEW.book.param["listinfo"].nil?
    no += 1
  end
end

#column_begin(level, label, caption) ⇒ Object



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

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

#column_end(level) ⇒ Object



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

def column_end(level)
  common_column_end("")
end

#comment(str) ⇒ Object



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

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

#common_column_begin(type, caption) ⇒ Object



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

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

#common_column_end(type) ⇒ Object



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

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

#compile_href(url, label) ⇒ Object



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

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



650
651
652
653
654
655
656
657
658
659
660
661
662
663
# File 'lib/review/idgxmlbuilder.rb', line 650

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



646
647
648
# File 'lib/review/idgxmlbuilder.rb', line 646

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



308
309
310
# File 'lib/review/idgxmlbuilder.rb', line 308

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

#dl_beginObject



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

def dl_begin
  puts '<dl>'
end

#dl_endObject



312
313
314
# File 'lib/review/idgxmlbuilder.rb', line 312

def dl_end
  puts '</dl>'
end

#dt(line) ⇒ Object



304
305
306
# File 'lib/review/idgxmlbuilder.rb', line 304

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

#dtp(str) ⇒ Object



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

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

#edition_begin(level, label, caption) ⇒ Object



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

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

#edition_end(level) ⇒ Object



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

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

#emlist(lines, caption = nil) ⇒ Object



379
380
381
# File 'lib/review/idgxmlbuilder.rb', line 379

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

#emlistnum(lines, caption = nil) ⇒ Object



383
384
385
386
387
388
389
# File 'lib/review/idgxmlbuilder.rb', line 383

def emlistnum(lines, caption = 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



104
105
106
107
108
109
110
111
# File 'lib/review/idgxmlbuilder.rb', line 104

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



117
118
119
120
121
122
123
124
125
# File 'lib/review/idgxmlbuilder.rb', line 117

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



996
997
998
# File 'lib/review/idgxmlbuilder.rb', line 996

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

#extnameObject



53
54
55
# File 'lib/review/idgxmlbuilder.rb', line 53

def extname
  '.xml'
end

#flushright(lines) ⇒ Object



896
897
898
899
900
901
902
# File 'lib/review/idgxmlbuilder.rb', line 896

def flushright(lines)
  if ReVIEW.book.param["deprecated-blocklines"].nil?
    puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
  else
    puts "<p align='right'>#{lines.join("\n")}</p>"
  end
end

#footnote(id, str) ⇒ Object



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

def footnote(id, str)
  # see inline_fn
end

#handle_metric(str) ⇒ Object



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

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

#headline(level, label, caption) ⇒ Object



137
138
139
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/review/idgxmlbuilder.rb', line 137

def headline(level, label, caption)
  prefix = ""
  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?

    if @chapter.number.blank?
      prefix = ""
    else
      placeholder = if @chapter.is_a? ReVIEW::Book::Part
                      level = 0
                      'part'
                    elsif @chapter.on_POSTDEF?
                      'appendix'
                    else
                      'chapter'
                    end
      prefix = "#{I18n.t(placeholder, @chapter.number)}#{I18n.t("chapter_postfix")}"
    end
    @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?
    if ReVIEW.book.param["secnolevel"] >= 2
      if @chapter.number.blank? or @chapter.on_POSTDEF?
        prefix = ""
      else
        prefix = "#{@chapter.number}.#{@section}#{I18n.t("chapter_postfix")}"
      end
    end

    @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?
    if ReVIEW.book.param["secnolevel"] >= 3
      if @chapter.number.blank? or @chapter.on_POSTDEF?
        prefix = ""
      else
        prefix = "#{@chapter.number}.#{@section}.#{@subsection}#{I18n.t("chapter_postfix")}"
      end
    end

    @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? 
    if ReVIEW.book.param["secnolevel"] >= 4
      if @chapter.number.blank? or @chapter.on_POSTDEF?
        prefix = ""
      else
        prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}#{I18n.t("chapter_postfix")}"
      end
    end

    @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?
    if ReVIEW.book.param["secnolevel"] >= 5
      if @chapter.number.blank? or @chapter.on_POSTDEF?
        prefix = ""
      else
        prefix = "#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}#{I18n.t("chapter_postfix")}"
      end
    end

  else
    raise "caption level too deep or unsupported: #{level}"
  end

  prefix = "" if (level.to_i > ReVIEW.book.param["secnolevel"])
  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



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

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

#hood_end(level) ⇒ Object



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

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

#hrObject



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

def hr
  print "<hr />"
end

#image_dummy(id, caption, lines) ⇒ Object



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/review/idgxmlbuilder.rb', line 478

def image_dummy(id, caption, lines)
  if ReVIEW.book.param["subdirmode"]
    warn "image file not exist: images/#{@chapter.id}/#{id}.eps" unless File.exist?("images/#{@chapter.id}/#{id}.eps")
  elsif ReVIEW.book.param["singledirmode"]
    warn "image file not exist: images/#{@chapter.id}/#{id}.eps" unless File.exist?("images/#{id}.eps")
  else
    warn "image file not exist: images/#{@chapter.id}-#{id}.eps" unless File.exist?("images/#{@chapter.id}-#{id}.eps")
  end
  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>"
end

#image_extObject



1192
1193
1194
# File 'lib/review/idgxmlbuilder.rb', line 1192

def image_ext
  "eps"
end

#image_header(id, caption) ⇒ Object



497
498
499
500
501
502
503
# File 'lib/review/idgxmlbuilder.rb', line 497

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



470
471
472
473
474
475
476
# File 'lib/review/idgxmlbuilder.rb', line 470

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

#important(lines, caption = nil) ⇒ Object



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

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

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



1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
# File 'lib/review/idgxmlbuilder.rb', line 1036

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.nil? && !caption.empty?
  puts "</img>"
end

#info(lines, caption = nil) ⇒ Object



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

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

#inline_ami(str) ⇒ Object



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

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

#inline_b(str) ⇒ Object



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

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

#inline_balloon(str) ⇒ Object



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

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

#inline_bib(id) ⇒ Object



1169
1170
1171
# File 'lib/review/idgxmlbuilder.rb', line 1169

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

#inline_bou(str) ⇒ Object



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

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

#inline_br(str) ⇒ Object



1079
1080
1081
# File 'lib/review/idgxmlbuilder.rb', line 1079

def inline_br(str)
  "\n"
end

#inline_chap(id) ⇒ Object



1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
# File 'lib/review/idgxmlbuilder.rb', line 1119

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

#inline_chapref(id) ⇒ Object



1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
# File 'lib/review/idgxmlbuilder.rb', line 1096

def inline_chapref(id)
  chs = ["", "", ""]
  unless ReVIEW.book.param["chapref"].nil?
    _chs = convert_inencoding(ReVIEW.book.param["chapref"],
                              ReVIEW.book.param["inencoding"]).split(",")
    if _chs.size != 3
      error "--chapsplitter must have exactly 3 parameters with comma."
    else
      chs = _chs
    end
  else
  end
  s = "#{chs[0]}#{@chapter.env.chapter_index.number(id)}#{chs[1]}#{@chapter.env.chapter_index.title(id)}#{chs[2]}"
  if ReVIEW.book.param["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



1075
1076
1077
# File 'lib/review/idgxmlbuilder.rb', line 1075

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

#inline_dtp(str) ⇒ Object



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

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

#inline_fn(id) ⇒ Object



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

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

#inline_hd_chap(chap, id) ⇒ Object



1173
1174
1175
1176
1177
1178
1179
1180
1181
# File 'lib/review/idgxmlbuilder.rb', line 1173

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

#inline_hidx(str) ⇒ Object



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

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

#inline_hint(str) ⇒ Object



681
682
683
684
685
686
687
# File 'lib/review/idgxmlbuilder.rb', line 681

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

#inline_i(str) ⇒ Object



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

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

#inline_icon(id) ⇒ Object



748
749
750
751
752
753
754
755
# File 'lib/review/idgxmlbuilder.rb', line 748

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



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

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

#inline_img(id) ⇒ Object



452
453
454
455
456
457
458
459
# File 'lib/review/idgxmlbuilder.rb', line 452

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_keytop(str) ⇒ Object



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

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

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



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

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

#inline_list(id) ⇒ Object



339
340
341
342
343
344
345
346
# File 'lib/review/idgxmlbuilder.rb', line 339

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



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

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

#inline_maru(str) ⇒ Object



689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
# File 'lib/review/idgxmlbuilder.rb', line 689

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



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

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

#inline_raw(str) ⇒ Object



677
678
679
# File 'lib/review/idgxmlbuilder.rb', line 677

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

#inline_recipe(id) ⇒ Object



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

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

#inline_sub(str) ⇒ Object



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

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

#inline_sup(str) ⇒ Object



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

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

#inline_table(id) ⇒ Object



443
444
445
446
447
448
449
450
# File 'lib/review/idgxmlbuilder.rb', line 443

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



1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
# File 'lib/review/idgxmlbuilder.rb', line 1130

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

#inline_tt(str) ⇒ Object



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

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

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



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

def inline_ttb(str)
  index = escape_html(str).gsub(/<.*?>/, "").gsub(/\*/, "ESCAPED_ASTERISK").gsub(/'/, "&#27;")
  %Q(<tt style='bold'>#{escape_html(str)}</tt><index value='#{index}' />)
end

#inline_tti(str) ⇒ Object



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

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

#inline_u(str) ⇒ Object



744
745
746
# File 'lib/review/idgxmlbuilder.rb', line 744

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

#inline_uchar(str) ⇒ Object



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

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

#insideout_begin(level, label, caption) ⇒ Object



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

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

#insideout_end(level) ⇒ Object



868
869
870
# File 'lib/review/idgxmlbuilder.rb', line 868

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

#insn(lines, caption = nil) ⇒ Object



1028
1029
1030
# File 'lib/review/idgxmlbuilder.rb', line 1028

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

#label(id) ⇒ Object



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

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

#linebreakObject



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

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


960
961
962
# File 'lib/review/idgxmlbuilder.rb', line 960

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

#list_body(id, lines) ⇒ Object



373
374
375
376
377
# File 'lib/review/idgxmlbuilder.rb', line 373

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

#list_header(id, caption) ⇒ Object



348
349
350
351
352
353
354
355
# File 'lib/review/idgxmlbuilder.rb', line 348

def list_header(id, caption)
  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) ⇒ Object



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/review/idgxmlbuilder.rb', line 391

def listnum_body(lines)
  print %Q(<pre>)
  no = 1
  lines.each_with_index do |line, i|
    unless ReVIEW.book.param["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 ReVIEW.book.param["listinfo"].nil?
    no += 1
  end
  puts "</pre></codelist>"
end

#memo(lines, caption = nil) ⇒ Object



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

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

#messagesObject



113
114
115
# File 'lib/review/idgxmlbuilder.rb', line 113

def messages
  error_messages() + warning_messages()
end

#nofunc_text(str) ⇒ Object



1188
1189
1190
# File 'lib/review/idgxmlbuilder.rb', line 1188

def nofunc_text(str)
  escape_html(str)
end

#noindentObject



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

def noindent
  @noindent = true
end

#nonum_begin(level, label, caption) ⇒ Object



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

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



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

def nonum_end(level)
end

#note(lines, caption = nil) ⇒ Object



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

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

#notice(lines, caption = nil) ⇒ Object



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

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

#ol_beginObject



288
289
290
# File 'lib/review/idgxmlbuilder.rb', line 288

def ol_begin
  puts '<ol>'
end

#ol_endObject



296
297
298
# File 'lib/review/idgxmlbuilder.rb', line 296

def ol_end
  puts '</ol>'
end

#ol_item(lines, num) ⇒ Object



292
293
294
# File 'lib/review/idgxmlbuilder.rb', line 292

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

#pagebreakObject



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

def pagebreak
  puts "<pagebreak />"
end

#paragraph(lines) ⇒ Object



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

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



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

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

#point(lines, caption = nil) ⇒ Object



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

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

#post_paragraphObject



49
50
51
# File 'lib/review/idgxmlbuilder.rb', line 49

def post_paragraph
  '</p>'
end

#practice(lines) ⇒ Object



992
993
994
# File 'lib/review/idgxmlbuilder.rb', line 992

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

#pre_paragraphObject



45
46
47
# File 'lib/review/idgxmlbuilder.rb', line 45

def pre_paragraph
  '<p>'
end

#quote(lines) ⇒ Object



434
435
436
437
438
439
440
441
# File 'lib/review/idgxmlbuilder.rb', line 434

def quote(lines)
  if ReVIEW.book.param["deprecated-blocklines"].nil?
    blocked_lines = split_paragraph(lines)
    puts "<quote>#{blocked_lines.join("")}</quote>"
  else
    puts "<quote>#{lines.join("\n")}</quote>"
  end
end

#rawblock(lines) ⇒ Object



1083
1084
1085
1086
1087
1088
1089
1090
# File 'lib/review/idgxmlbuilder.rb', line 1083

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 = no + 1
  end
end

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



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

def read(lines)
  if ReVIEW.book.param["deprecated-blocklines"].nil?
    puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
  else
    puts %Q[<p aid:pstyle="lead">#{lines.join}</p>]
  end
end

#ref_begin(level, label, caption) ⇒ Object



872
873
874
875
876
877
878
# File 'lib/review/idgxmlbuilder.rb', line 872

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

#ref_end(level) ⇒ Object



880
881
882
# File 'lib/review/idgxmlbuilder.rb', line 880

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

#reference(lines) ⇒ Object



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

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

#resultObject



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/review/idgxmlbuilder.rb', line 83

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



466
467
468
# File 'lib/review/idgxmlbuilder.rb', line 466

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

#security(lines, caption = nil) ⇒ Object



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

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

#shoot(lines, caption = nil) ⇒ Object



980
981
982
983
984
985
986
# File 'lib/review/idgxmlbuilder.rb', line 980

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) ⇒ Object



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

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

#source_header(caption) ⇒ Object



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

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

#sup_begin(level, label, caption) ⇒ Object



884
885
886
887
888
889
890
# File 'lib/review/idgxmlbuilder.rb', line 884

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

#sup_end(level) ⇒ Object



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

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

#syntaxblock(type, lines, caption) ⇒ Object



1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
# File 'lib/review/idgxmlbuilder.rb', line 1000

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 ReVIEW.book.param["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 ReVIEW.book.param["listinfo"].nil?
    no += 1
  end
  puts "</#{type}>"
end

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



514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/review/idgxmlbuilder.rb', line 514

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

  cellwidth = []
  unless tablewidth.nil?
    if @tsize.nil?
      col.times {|n| cellwidth[n] = tablewidth / col }
    else
      cellwidth = @tsize.split(/\s*,\s*/)
      totallength = 0
      cellwidth.size.times do |n|
        cellwidth[n] = cellwidth[n].to_f / 0.351 # mm -> pt
        totallength = 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 => err
    error "no such table: #{id}"
  end
  return if rows.empty?

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

  if sepidx
    sepidx.times do |y|
      if tablewidth.nil?
        puts %Q[<tr type="header">#{rows.shift}</tr>]
      else
        i = 0
        rows.shift.split(/\t/).each_with_index do |cell, x|
          print %Q[<td xyh="#{x + 1},#{y + 1},#{sepidx}" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
          i += 1
        end
      end
    end
  end
  trputs(tablewidth, rows, cellwidth, sepidx)
  puts "</tbody></table>"
  @tsize = nil
end

#table_begin(ncols) ⇒ Object



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

def table_begin(ncols)
end

#table_endObject



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

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

#table_header(id, caption) ⇒ Object



607
608
609
610
611
612
613
# File 'lib/review/idgxmlbuilder.rb', line 607

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



626
627
628
# File 'lib/review/idgxmlbuilder.rb', line 626

def td(str)
  str
end

#term(lines) ⇒ Object



956
957
958
# File 'lib/review/idgxmlbuilder.rb', line 956

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

#texequation(lines) ⇒ Object



505
506
507
508
509
510
511
512
# File 'lib/review/idgxmlbuilder.rb', line 505

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



1092
1093
1094
# File 'lib/review/idgxmlbuilder.rb', line 1092

def text(str)
  str
end

#th(str) ⇒ Object



622
623
624
# File 'lib/review/idgxmlbuilder.rb', line 622

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

#tip(lines, caption = nil) ⇒ Object



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

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

#tr(rows) ⇒ Object



618
619
620
# File 'lib/review/idgxmlbuilder.rb', line 618

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

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



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/review/idgxmlbuilder.rb', line 590

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

#tsize(str) ⇒ Object



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

def tsize(str)
  @tsize = str
end

#ul_beginObject



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

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

#ul_endObject



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

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

#ul_item(lines) ⇒ Object



254
255
256
# File 'lib/review/idgxmlbuilder.rb', line 254

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

#ul_item_begin(lines) ⇒ Object



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

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

#ul_item_endObject



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

def ul_item_end
  puts "</li>"
end

#warn(msg) ⇒ Object



95
96
97
98
99
100
101
102
# File 'lib/review/idgxmlbuilder.rb', line 95

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_messagesObject



127
128
129
130
131
132
133
134
135
# File 'lib/review/idgxmlbuilder.rb', line 127

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



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

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

#world_end(level) ⇒ Object



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

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

#xcolumn_begin(level, label, caption) ⇒ Object



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

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

#xcolumn_end(level) ⇒ Object



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

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