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

Methods included from TextUtils

#convert_inencoding, #convert_outencoding, #detab, #split_paragraph

Methods inherited from Builder

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

Constructor Details

This class inherits a constructor from ReVIEW::Builder

Instance Method Details

#best(lines, caption = nil) ⇒ Object



969
970
971
# File 'lib/review/idgxmlbuilder.rb', line 969

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

#bibpaper(lines, id, caption) ⇒ Object



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

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



1195
1196
1197
# File 'lib/review/idgxmlbuilder.rb', line 1195

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

#bibpaper_header(id, caption) ⇒ Object



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

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



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

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

#bpo(lines) ⇒ Object



1096
1097
1098
# File 'lib/review/idgxmlbuilder.rb', line 1096

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

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



937
938
939
940
941
942
943
944
945
946
947
# File 'lib/review/idgxmlbuilder.rb', line 937

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

#caution(lines, caption = nil) ⇒ Object



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

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

#centering(lines) ⇒ Object



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

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

#choice_multi_beginObject



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

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

#choice_multi_endObject



285
286
287
# File 'lib/review/idgxmlbuilder.rb', line 285

def choice_multi_end
  puts "</choice>"
end

#choice_single_beginObject



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

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

#choice_single_endObject



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

def choice_single_end
  puts "</choice>"
end

#circle_begin(level, label, caption) ⇒ Object



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

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

#circle_end(level) ⇒ Object



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

def circle_end(level)
end

#cmd(lines, caption = nil) ⇒ Object



442
443
444
# File 'lib/review/idgxmlbuilder.rb', line 442

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

#codelines_body(lines) ⇒ Object



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

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



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

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

#column_end(level) ⇒ Object



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

def column_end(level)
  common_column_end("")
end

#comment(str) ⇒ Object



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

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

#common_column_begin(type, caption) ⇒ Object



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

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



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

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

#compile_href(url, label) ⇒ Object



692
693
694
# File 'lib/review/idgxmlbuilder.rb', line 692

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



677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/review/idgxmlbuilder.rb', line 677

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



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

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



324
325
326
# File 'lib/review/idgxmlbuilder.rb', line 324

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

#dl_beginObject



316
317
318
# File 'lib/review/idgxmlbuilder.rb', line 316

def dl_begin
  puts '<dl>'
end

#dl_endObject



328
329
330
# File 'lib/review/idgxmlbuilder.rb', line 328

def dl_end
  puts '</dl>'
end

#dt(line) ⇒ Object



320
321
322
# File 'lib/review/idgxmlbuilder.rb', line 320

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

#dtp(str) ⇒ Object



1088
1089
1090
# File 'lib/review/idgxmlbuilder.rb', line 1088

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

#edition_begin(level, label, caption) ⇒ Object



885
886
887
# File 'lib/review/idgxmlbuilder.rb', line 885

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

#edition_end(level) ⇒ Object



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

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

#emlist(lines, caption = nil) ⇒ Object



412
413
414
# File 'lib/review/idgxmlbuilder.rb', line 412

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

#emlistnum(lines, caption = nil) ⇒ Object



416
417
418
419
420
421
422
# File 'lib/review/idgxmlbuilder.rb', line 416

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



111
112
113
114
115
116
117
118
# File 'lib/review/idgxmlbuilder.rb', line 111

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

#error_messagesObject



124
125
126
127
128
129
130
131
132
# File 'lib/review/idgxmlbuilder.rb', line 124

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

#expert(lines) ⇒ Object



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

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



925
926
927
928
929
930
931
# File 'lib/review/idgxmlbuilder.rb', line 925

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

#footnote(id, str) ⇒ Object



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

def footnote(id, str)
  # see inline_fn
end

#handle_metric(str) ⇒ Object



494
495
496
497
# File 'lib/review/idgxmlbuilder.rb', line 494

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

#headline(level, label, caption) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
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
247
248
249
250
251
252
253
# File 'lib/review/idgxmlbuilder.rb', line 144

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_APPENDIX?
                      '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 @book.config["secnolevel"] >= 2
      if @chapter.number.blank? or @chapter.on_APPENDIX?
        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 @book.config["secnolevel"] >= 3
      if @chapter.number.blank? or @chapter.on_APPENDIX?
        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 @book.config["secnolevel"] >= 4
      if @chapter.number.blank? or @chapter.on_APPENDIX?
        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 @book.config["secnolevel"] >= 5
      if @chapter.number.blank? or @chapter.on_APPENDIX?
        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 > @book.config["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



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

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

#hood_end(level) ⇒ Object



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

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

#hrObject



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

def hr
  print "<hr />"
end

#image_dummy(id, caption, lines) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/review/idgxmlbuilder.rb', line 511

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



1222
1223
1224
# File 'lib/review/idgxmlbuilder.rb', line 1222

def image_ext
  "eps"
end

#image_header(id, caption) ⇒ Object



524
525
526
527
528
529
530
# File 'lib/review/idgxmlbuilder.rb', line 524

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



503
504
505
506
507
508
509
# File 'lib/review/idgxmlbuilder.rb', line 503

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



973
974
975
# File 'lib/review/idgxmlbuilder.rb', line 973

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

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



1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
# File 'lib/review/idgxmlbuilder.rb', line 1065

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



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

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

#inline_ami(str) ⇒ Object



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

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

#inline_b(str) ⇒ Object



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

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

#inline_balloon(str) ⇒ Object



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

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

#inline_bib(id) ⇒ Object



1199
1200
1201
# File 'lib/review/idgxmlbuilder.rb', line 1199

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

#inline_bou(str) ⇒ Object



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

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

#inline_br(str) ⇒ Object



1108
1109
1110
# File 'lib/review/idgxmlbuilder.rb', line 1108

def inline_br(str)
  "\n"
end

#inline_chap(id) ⇒ Object



1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
# File 'lib/review/idgxmlbuilder.rb', line 1148

def inline_chap(id)
  if @book.config["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



1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'lib/review/idgxmlbuilder.rb', line 1125

def inline_chapref(id)
  chs = ["", "「", "」"]
  unless @book.config["chapref"].nil?
    _chs = convert_inencoding(@book.config["chapref"],
                              @book.config["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 @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



1104
1105
1106
# File 'lib/review/idgxmlbuilder.rb', line 1104

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

#inline_column(id) ⇒ Object



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

def inline_column(id)
  if @book.config["chapterlink"]
    %Q(<link href="#{column_label(id)}">#{escape_html(@chapter.column(id).caption)}</link>)
  else
    escape_html(@chapter.column(id).caption)
  end
rescue KeyError
  error "unknown column: #{id}"
  nofunc_text("[UnknownColumn:#{id}]")
end

#inline_dtp(str) ⇒ Object



1100
1101
1102
# File 'lib/review/idgxmlbuilder.rb', line 1100

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

#inline_fn(id) ⇒ Object



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

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

#inline_hd_chap(chap, id) ⇒ Object



1203
1204
1205
1206
1207
1208
1209
1210
1211
# File 'lib/review/idgxmlbuilder.rb', line 1203

def inline_hd_chap(chap, id)
  if chap.number
    n = chap.headline_index.number(id)
    if @book.config["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



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

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

#inline_hint(str) ⇒ Object



708
709
710
711
712
713
714
# File 'lib/review/idgxmlbuilder.rb', line 708

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



748
749
750
# File 'lib/review/idgxmlbuilder.rb', line 748

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

#inline_icon(id) ⇒ Object



775
776
777
778
779
780
781
782
# File 'lib/review/idgxmlbuilder.rb', line 775

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



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

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

#inline_img(id) ⇒ Object



485
486
487
488
489
490
491
492
# File 'lib/review/idgxmlbuilder.rb', line 485

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



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

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

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



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

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

#inline_list(id) ⇒ Object



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

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



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

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

#inline_maru(str) ⇒ Object



716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'lib/review/idgxmlbuilder.rb', line 716

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



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

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

#inline_raw(str) ⇒ Object



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

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

#inline_recipe(id) ⇒ Object



1213
1214
1215
1216
# File 'lib/review/idgxmlbuilder.rb', line 1213

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

#inline_sub(str) ⇒ Object



700
701
702
# File 'lib/review/idgxmlbuilder.rb', line 700

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

#inline_sup(str) ⇒ Object



696
697
698
# File 'lib/review/idgxmlbuilder.rb', line 696

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

#inline_table(id) ⇒ Object



476
477
478
479
480
481
482
483
# File 'lib/review/idgxmlbuilder.rb', line 476

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



1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
# File 'lib/review/idgxmlbuilder.rb', line 1159

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



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

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

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



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

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



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

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

#inline_u(str) ⇒ Object



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

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

#inline_uchar(str) ⇒ Object



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

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

#insideout_begin(level, label, caption) ⇒ Object



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

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

#insideout_end(level) ⇒ Object



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

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

#insn(lines, caption = nil) ⇒ Object



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

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

#label(id) ⇒ Object



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

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

#linebreakObject



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

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


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

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

#list_body(id, lines) ⇒ Object



406
407
408
409
410
# File 'lib/review/idgxmlbuilder.rb', line 406

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

#list_header(id, caption) ⇒ Object



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

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



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/review/idgxmlbuilder.rb', line 424

def listnum_body(lines)
  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



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

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

#messagesObject



120
121
122
# File 'lib/review/idgxmlbuilder.rb', line 120

def messages
  error_messages() + warning_messages()
end

#nofunc_text(str) ⇒ Object



1218
1219
1220
# File 'lib/review/idgxmlbuilder.rb', line 1218

def nofunc_text(str)
  escape_html(str)
end

#noindentObject



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

def noindent
  @noindent = true
end

#nonum_begin(level, label, caption) ⇒ Object



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

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



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

def nonum_end(level)
end

#note(lines, caption = nil) ⇒ Object



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

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

#notice(lines, caption = nil) ⇒ Object



993
994
995
996
997
998
999
# File 'lib/review/idgxmlbuilder.rb', line 993

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

#ol_beginObject



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

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

#ol_endObject



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

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

#ol_item(lines, num) ⇒ Object



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

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



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

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

#pagebreakObject



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

def pagebreak
  puts "<pagebreak />"
end

#paragraph(lines) ⇒ Object



332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/review/idgxmlbuilder.rb', line 332

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



965
966
967
# File 'lib/review/idgxmlbuilder.rb', line 965

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

#point(lines, caption = nil) ⇒ Object



1001
1002
1003
1004
1005
1006
1007
# File 'lib/review/idgxmlbuilder.rb', line 1001

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



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

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



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

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

#rawblock(lines) ⇒ Object



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

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



345
346
347
348
349
350
351
# File 'lib/review/idgxmlbuilder.rb', line 345

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

#ref_begin(level, label, caption) ⇒ Object



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

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

#ref_end(level) ⇒ Object



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

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

#reference(lines) ⇒ Object



1017
1018
1019
# File 'lib/review/idgxmlbuilder.rb', line 1017

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

#resultObject



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/review/idgxmlbuilder.rb', line 90

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

#result_metric(array) ⇒ Object



499
500
501
# File 'lib/review/idgxmlbuilder.rb', line 499

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

#security(lines, caption = nil) ⇒ Object



977
978
979
# File 'lib/review/idgxmlbuilder.rb', line 977

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

#shoot(lines, caption = nil) ⇒ Object



1009
1010
1011
1012
1013
1014
1015
# File 'lib/review/idgxmlbuilder.rb', line 1009

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



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

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

#source_header(caption) ⇒ Object



1171
1172
1173
1174
# File 'lib/review/idgxmlbuilder.rb', line 1171

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

#sup_begin(level, label, caption) ⇒ Object



913
914
915
916
917
918
919
# File 'lib/review/idgxmlbuilder.rb', line 913

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

#sup_end(level) ⇒ Object



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

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

#syntaxblock(type, lines, caption) ⇒ Object



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
# File 'lib/review/idgxmlbuilder.rb', line 1029

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



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
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
# File 'lib/review/idgxmlbuilder.rb', line 541

def table(lines, id = nil, caption = nil)
  tablewidth = nil
  col = 0
  unless @book.config["tableopt"].nil?
    tablewidth = @book.config["tableopt"].split(",")[0].to_f / 0.351 # 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
    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



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

def table_begin(ncols)
end

#table_endObject



657
658
659
# File 'lib/review/idgxmlbuilder.rb', line 657

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

#table_header(id, caption) ⇒ Object



634
635
636
637
638
639
640
# File 'lib/review/idgxmlbuilder.rb', line 634

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



653
654
655
# File 'lib/review/idgxmlbuilder.rb', line 653

def td(str)
  str
end

#term(lines) ⇒ Object



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

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

#texequation(lines) ⇒ Object



532
533
534
535
536
537
538
539
# File 'lib/review/idgxmlbuilder.rb', line 532

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



1121
1122
1123
# File 'lib/review/idgxmlbuilder.rb', line 1121

def text(str)
  str
end

#th(str) ⇒ Object



649
650
651
# File 'lib/review/idgxmlbuilder.rb', line 649

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

#tip(lines, caption = nil) ⇒ Object



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

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

#tr(rows) ⇒ Object



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

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

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



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

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



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

def tsize(str)
  @tsize = str
end

#ul_beginObject



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

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

#ul_endObject



289
290
291
292
293
# File 'lib/review/idgxmlbuilder.rb', line 289

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

#ul_item(lines) ⇒ Object



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

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

#ul_item_begin(lines) ⇒ Object



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

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

#ul_item_endObject



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

def ul_item_end
  puts "</li>"
end

#warn(msg) ⇒ Object



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

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

#warning_messagesObject



134
135
136
137
138
139
140
141
142
# File 'lib/review/idgxmlbuilder.rb', line 134

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

#world_begin(level, label, caption) ⇒ Object



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

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

#world_end(level) ⇒ Object



873
874
875
# File 'lib/review/idgxmlbuilder.rb', line 873

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

#xcolumn_begin(level, label, caption) ⇒ Object



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

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

#xcolumn_end(level) ⇒ Object



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

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