Class: ReVIEW::HTMLBuilder
Constant Summary
Constants included
from HTMLUtils
ReVIEW::HTMLUtils::ESC
Constants inherited
from Builder
Builder::CAPTION_TITLES
Instance Method Summary
collapse
-
#best(lines, caption = nil) ⇒ Object
-
#bibpaper(lines, id, caption) ⇒ Object
-
#bibpaper_bibpaper(id, caption, lines) ⇒ Object
-
#bibpaper_header(id, caption) ⇒ Object
-
#box(lines, caption = nil) ⇒ Object
-
#bpo(lines) ⇒ Object
-
#captionblock(type, lines, caption) ⇒ Object
-
#caution(lines, caption = nil) ⇒ Object
-
#centering(lines) ⇒ Object
-
#cmd(lines, caption = nil) ⇒ Object
-
#column_begin(level, label, caption) ⇒ Object
-
#column_end(level) ⇒ Object
-
#comment(lines, comment = nil) ⇒ Object
-
#compile_href(url, label) ⇒ Object
-
#compile_kw(word, alt) ⇒ Object
-
#compile_ruby(base, ruby) ⇒ Object
-
#dd(lines) ⇒ Object
-
#dl_begin ⇒ Object
-
#dl_end ⇒ Object
-
#doorquote(lines, ref) ⇒ Object
-
#dt(line) ⇒ Object
-
#emlist(lines, caption = nil, lang = nil) ⇒ Object
-
#emlistnum(lines, caption = nil, lang = nil) ⇒ Object
-
#error(msg) ⇒ Object
-
#error_messages ⇒ Object
-
#extname ⇒ Object
-
#flushright(lines) ⇒ Object
-
#footnote(id, str) ⇒ Object
-
#handle_metric(str) ⇒ Object
-
#headline(level, label, caption) ⇒ Object
-
#hr ⇒ Object
-
#image_dummy(id, caption, lines) ⇒ Object
-
#image_ext ⇒ Object
-
#image_header(id, caption) ⇒ Object
-
#image_image(id, caption, metric) ⇒ Object
-
#important(lines, caption = nil) ⇒ Object
-
#indepimage(id, caption = "", metric = nil) ⇒ Object
(also: #numberlessimage)
-
#info(lines, caption = nil) ⇒ Object
-
#inline_abbr(str) ⇒ Object
-
#inline_acronym(str) ⇒ Object
-
#inline_ami(str) ⇒ Object
-
#inline_asis(str, tag) ⇒ Object
-
#inline_b(str) ⇒ Object
-
#inline_bib(id) ⇒ Object
-
#inline_big(str) ⇒ Object
-
#inline_bou(str) ⇒ Object
-
#inline_br(str) ⇒ Object
-
#inline_chap(id) ⇒ Object
-
#inline_chapref(id) ⇒ Object
-
#inline_cite(str) ⇒ Object
-
#inline_code(str) ⇒ Object
-
#inline_column(id) ⇒ Object
-
#inline_comment(str) ⇒ Object
-
#inline_del(str) ⇒ Object
-
#inline_dfn(str) ⇒ Object
-
#inline_dtp(str) ⇒ Object
-
#inline_em(str) ⇒ Object
-
#inline_fn(id) ⇒ Object
-
#inline_hd_chap(chap, id) ⇒ Object
-
#inline_hidx(str) ⇒ Object
-
#inline_i(str) ⇒ Object
-
#inline_icon(id) ⇒ Object
-
#inline_idx(str) ⇒ Object
-
#inline_img(id) ⇒ Object
-
#inline_ins(str) ⇒ Object
-
#inline_kbd(str) ⇒ Object
-
#inline_labelref(idref) ⇒ Object
(also: #inline_ref)
-
#inline_list(id) ⇒ Object
-
#inline_m(str) ⇒ Object
-
#inline_raw(str) ⇒ Object
-
#inline_recipe(str) ⇒ Object
-
#inline_samp(str) ⇒ Object
-
#inline_small(str) ⇒ Object
-
#inline_strong(str) ⇒ Object
-
#inline_sub(str) ⇒ Object
-
#inline_sup(str) ⇒ Object
-
#inline_table(id) ⇒ Object
-
#inline_title(id) ⇒ Object
-
#inline_tt(str) ⇒ Object
-
#inline_ttb(str) ⇒ Object
-
#inline_tti(str) ⇒ Object
-
#inline_u(str) ⇒ Object
-
#inline_uchar(str) ⇒ Object
-
#inline_var(str) ⇒ Object
-
#label(id) ⇒ Object
-
#linebreak ⇒ Object
-
#list(lines, id, caption, lang = nil) ⇒ Object
-
#list_body(id, lines, lang) ⇒ Object
-
#list_header(id, caption, lang) ⇒ Object
-
#listnum(lines, id, caption, lang = nil) ⇒ Object
-
#listnum_body(lines, lang) ⇒ Object
-
#memo(lines, caption = nil) ⇒ Object
-
#messages ⇒ Object
-
#nofunc_text(str) ⇒ Object
-
#noindent ⇒ Object
-
#nonum_begin(level, label, caption) ⇒ Object
-
#nonum_end(level) ⇒ Object
-
#note(lines, caption = nil) ⇒ Object
-
#notice(lines, caption = nil) ⇒ Object
-
#ol_begin ⇒ Object
-
#ol_end ⇒ Object
-
#ol_item(lines, num) ⇒ Object
-
#olnum(num) ⇒ Object
-
#pagebreak ⇒ Object
-
#paragraph(lines) ⇒ Object
-
#parasep ⇒ Object
-
#planning(lines, caption = nil) ⇒ Object
-
#point(lines, caption = nil) ⇒ Object
-
#post_paragraph ⇒ Object
-
#pre_paragraph ⇒ Object
-
#quote(lines) ⇒ Object
-
#read(lines) ⇒ Object
(also: #lead)
-
#ref_begin(level, label, caption) ⇒ Object
-
#ref_end(level) ⇒ Object
-
#result ⇒ Object
-
#result_metric(array) ⇒ Object
-
#security(lines, caption = nil) ⇒ Object
-
#shoot(lines, caption = nil) ⇒ Object
-
#source(lines, caption = nil, lang = nil) ⇒ Object
-
#source_body(id, lines, lang) ⇒ Object
-
#source_header(caption) ⇒ Object
-
#sup_begin(level, label, caption) ⇒ Object
-
#sup_end(level) ⇒ Object
-
#table(lines, id = nil, caption = nil) ⇒ Object
-
#table_begin(ncols) ⇒ Object
-
#table_end ⇒ Object
-
#table_header(id, caption) ⇒ Object
-
#talk(lines) ⇒ Object
-
#td(str) ⇒ Object
-
#texequation(lines) ⇒ Object
-
#text(str) ⇒ Object
-
#th(str) ⇒ Object
-
#tip(lines, caption = nil) ⇒ Object
-
#tr(rows) ⇒ Object
-
#tsize(str) ⇒ Object
-
#ul_begin ⇒ Object
-
#ul_end ⇒ Object
-
#ul_item(lines) ⇒ Object
-
#ul_item_begin(lines) ⇒ Object
-
#ul_item_end ⇒ Object
-
#warn(msg) ⇒ Object
-
#warning_messages ⇒ Object
-
#xcolumn_begin(level, label, caption) ⇒ Object
-
#xcolumn_end(level) ⇒ Object
-
#xmlns_ops_prefix ⇒ Object
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_hd, #inline_href, #inline_imgref, #inline_include, #inline_kw, #inline_ruby, #parse_metric, #print, #puts, #raw, #target_name
Instance Method Details
#best(lines, caption = nil) ⇒ Object
294
295
296
|
# File 'lib/review/htmlbuilder.rb', line 294
def best(lines, caption = nil)
captionblock("best", lines, caption)
end
|
#bibpaper(lines, id, caption) ⇒ Object
920
921
922
923
924
925
926
927
|
# File 'lib/review/htmlbuilder.rb', line 920
def bibpaper(lines, id, caption)
puts %Q[<div class="bibpaper">]
id, caption
unless lines.empty?
bibpaper_bibpaper id, caption, lines
end
puts "</div>"
end
|
#bibpaper_bibpaper(id, caption, lines) ⇒ Object
936
937
938
|
# File 'lib/review/htmlbuilder.rb', line 936
def bibpaper_bibpaper(id, caption, lines)
print split_paragraph(lines).join("")
end
|
929
930
931
932
933
934
|
# File 'lib/review/htmlbuilder.rb', line 929
def (id, caption)
print %Q(<a id="bib-#{normalize_id(id)}">)
print "[#{@chapter.bibpaper(id).number}]"
print %Q(</a>)
puts " #{compile_inline(caption)}"
end
|
#box(lines, caption = nil) ⇒ Object
322
323
324
325
326
327
328
329
|
# File 'lib/review/htmlbuilder.rb', line 322
def box(lines, caption = nil)
puts %Q[<div class="syntax">]
puts %Q[<p class="caption">#{compile_inline(caption)}</p>] unless caption.nil?
print %Q[<pre class="syntax">]
lines.each {|line| puts detab(line) }
puts '</pre>'
puts '</div>'
end
|
#bpo(lines) ⇒ Object
770
771
772
773
774
775
776
|
# File 'lib/review/htmlbuilder.rb', line 770
def bpo(lines)
puts "<bpo>"
lines.each do |line|
puts detab(line)
end
puts "</bpo>"
end
|
#captionblock(type, lines, caption) ⇒ Object
264
265
266
267
268
269
270
271
272
273
274
275
276
|
# File 'lib/review/htmlbuilder.rb', line 264
def captionblock(type, lines, caption)
puts %Q[<div class="#{type}">]
unless caption.nil?
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
end
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts blocked_lines.join("\n")
else
lines.each {|l| puts "<p>#{l}</p>" }
end
puts '</div>'
end
|
#caution(lines, caption = nil) ⇒ Object
306
307
308
|
# File 'lib/review/htmlbuilder.rb', line 306
def caution(lines, caption = nil)
captionblock("caution", lines, caption)
end
|
#centering(lines) ⇒ Object
1148
1149
1150
|
# File 'lib/review/htmlbuilder.rb', line 1148
def centering(lines)
puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"center\">")
end
|
#cmd(lines, caption = nil) ⇒ Object
523
524
525
526
527
528
529
530
531
532
533
534
|
# File 'lib/review/htmlbuilder.rb', line 523
def cmd(lines, caption = nil)
puts %Q[<div class="cmd-code">]
if caption.present?
puts %Q(<p class="caption">#{compile_inline(caption)}</p>)
end
print %Q[<pre class="cmd">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = 'shell-session'
puts highlight(:body => body, :lexer => lexer, :format => 'html')
puts '</pre>'
puts '</div>'
end
|
#column_begin(level, label, caption) ⇒ Object
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/review/htmlbuilder.rb', line 210
def column_begin(level, label, caption)
puts %Q[<div class="column">]
@column += 1
puts '' if level > 1
a_id = %Q[<a id="column-#{@column}"></a>]
if caption.empty?
puts a_id unless label.nil?
else
if label.nil?
puts %Q[<h#{level}>#{a_id}#{compile_inline(caption)}</h#{level}>]
else
puts %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{compile_inline(caption)}</h#{level}>]
end
end
end
|
#column_end(level) ⇒ Object
229
230
231
|
# File 'lib/review/htmlbuilder.rb', line 229
def column_end(level)
puts '</div>'
end
|
714
715
716
717
718
719
720
721
722
723
724
|
# File 'lib/review/htmlbuilder.rb', line 714
def (lines, = nil)
lines ||= []
lines.unshift unless .blank?
if @book.config["draft"]
str = lines.join("<br />")
puts %Q(<div class="draft-comment">#{str}</div>)
else
str = lines.join("\n")
puts %Q(<!-- #{escape_comment(str)} -->)
end
end
|
#compile_href(url, label) ⇒ Object
1132
1133
1134
|
# File 'lib/review/htmlbuilder.rb', line 1132
def compile_href(url, label)
%Q(<a href="#{escape_html(url)}" class="link">#{label.nil? ? escape_html(url) : escape_html(label)}</a>)
end
|
#compile_kw(word, alt) ⇒ Object
839
840
841
842
843
844
845
846
|
# File 'lib/review/htmlbuilder.rb', line 839
def compile_kw(word, alt)
%Q[<b class="kw">] +
if alt
then escape_html(word + " (#{alt.strip})")
else escape_html(word)
end +
"</b><!-- IDX:#{escape_comment(escape_html(word))} -->"
end
|
#compile_ruby(base, ruby) ⇒ Object
831
832
833
834
835
836
837
|
# File 'lib/review/htmlbuilder.rb', line 831
def compile_ruby(base, ruby)
if @book.htmlversion == 5
%Q[<ruby>#{escape_html(base)}<rp>#{I18n.t("ruby_prefix")}</rp><rt>#{escape_html(ruby)}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
else
%Q[<ruby><rb>#{escape_html(base)}</rb><rp>#{I18n.t("ruby_prefix")}</rp><rt>#{ruby}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
end
end
|
#dd(lines) ⇒ Object
380
381
382
|
# File 'lib/review/htmlbuilder.rb', line 380
def dd(lines)
puts "<dd>#{lines.join}</dd>"
end
|
372
373
374
|
# File 'lib/review/htmlbuilder.rb', line 372
def dl_begin
puts '<dl>'
end
|
384
385
386
|
# File 'lib/review/htmlbuilder.rb', line 384
def dl_end
puts '</dl>'
end
|
#doorquote(lines, ref) ⇒ Object
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
|
# File 'lib/review/htmlbuilder.rb', line 554
def doorquote(lines, ref)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts %Q[<blockquote style="text-align:right;">]
puts "#{blocked_lines.join("\n")}"
puts %Q[<p>#{ref}より</p>]
puts %Q[</blockquote>]
else
puts "<blockquote style=\"text-align:right;\">\n <pre>\#{lines.join(\"\\n\")}\n\n\#{ref}\u3088\u308A</pre>\n</blockquote>\n"
end
end
|
376
377
378
|
# File 'lib/review/htmlbuilder.rb', line 376
def dt(line)
puts "<dt>#{line}</dt>"
end
|
#emlist(lines, caption = nil, lang = nil) ⇒ Object
488
489
490
491
492
493
494
495
496
497
498
499
|
# File 'lib/review/htmlbuilder.rb', line 488
def emlist(lines, caption = nil, lang = nil)
puts %Q[<div class="emlist-code">]
if caption.present?
puts %Q(<p class="caption">#{compile_inline(caption)}</p>)
end
print %Q[<pre class="emlist">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang
puts highlight(:body => body, :lexer => lexer, :format => 'html')
puts '</pre>'
puts '</div>'
end
|
#emlistnum(lines, caption = nil, lang = nil) ⇒ Object
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
# File 'lib/review/htmlbuilder.rb', line 501
def emlistnum(lines, caption = nil, lang = nil)
puts %Q[<div class="emlistnum-code">]
if caption.present?
puts %Q(<p class="caption">#{compile_inline(caption)}</p>)
end
if highlight?
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang
puts highlight(:body => body, :lexer => lexer, :format => 'html',
:options => {:linenos => 'inline', :nowrap => false})
else
print '<pre class="emlist">'
lines.each_with_index do |line, i|
puts detab((i+1).to_s.rjust(2) + ": " + line)
end
puts '</pre>'
end
puts '</div>'
end
|
#error(msg) ⇒ Object
142
143
144
145
146
147
148
149
|
# File 'lib/review/htmlbuilder.rb', line 142
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_messages ⇒ Object
155
156
157
158
159
160
161
162
163
|
# File 'lib/review/htmlbuilder.rb', line 155
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
|
44
45
46
|
# File 'lib/review/htmlbuilder.rb', line 44
def extname
".#{@book.config["htmlext"]}"
end
|
#flushright(lines) ⇒ Object
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
|
# File 'lib/review/htmlbuilder.rb', line 1136
def flushright(lines)
if @book.config["deprecated-blocklines"].nil?
puts split_paragraph(lines).join("\n").gsub("<p>", "<p class=\"flushright\">")
else
puts %Q[<div style="text-align:right;">]
print %Q[<pre class="flushright">]
lines.each {|line| puts detab(line) }
puts '</pre>'
puts '</div>'
end
end
|
726
727
728
729
730
731
732
|
# File 'lib/review/htmlbuilder.rb', line 726
def (id, str)
if @book.config["epubversion"].to_i == 3
puts %Q(<div class="footnote" epub:type="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[*#{@chapter.footnote(id).number}] #{compile_inline(str)}</p></div>)
else
puts %Q(<div class="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[<a href="#fnb-#{normalize_id(id)}">*#{@chapter.footnote(id).number}</a>] #{compile_inline(str)}</p></div>)
end
end
|
#handle_metric(str) ⇒ Object
600
601
602
603
604
605
606
607
|
# File 'lib/review/htmlbuilder.rb', line 600
def handle_metric(str)
if str =~ /\Ascale=([\d.]+)\Z/
return "width=\"#{($1.to_f * 100).round}%\""
else
k, v = str.split('=', 2)
return %Q|#{k}=\"#{v.sub(/\A["']/, '').sub(/["']\Z/, '')}\"|
end
end
|
#headline(level, label, caption) ⇒ Object
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/review/htmlbuilder.rb', line 175
def headline(level, label, caption)
prefix, anchor = headline_prefix(level)
unless prefix.nil?
prefix = %Q[<span class="secno">#{prefix}</span>]
end
puts '' if level > 1
a_id = ""
unless anchor.nil?
a_id = %Q[<a id="h#{anchor}"></a>]
end
if caption.empty?
puts a_id unless label.nil?
else
if label.nil?
puts %Q[<h#{level}>#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
else
puts %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{prefix}#{compile_inline(caption)}</h#{level}>]
end
end
end
|
754
755
756
|
# File 'lib/review/htmlbuilder.rb', line 754
def hr
puts "<hr />"
end
|
#image_dummy(id, caption, lines) ⇒ Object
621
622
623
624
625
626
627
628
629
630
631
|
# File 'lib/review/htmlbuilder.rb', line 621
def image_dummy(id, caption, lines)
puts %Q[<div class="image">]
puts %Q[<pre class="dummyimage">]
lines.each do |line|
puts detab(line)
end
puts %Q[</pre>]
id, caption
puts %Q[</div>]
warn "no such image: #{id}"
end
|
#image_ext ⇒ Object
1152
1153
1154
|
# File 'lib/review/htmlbuilder.rb', line 1152
def image_ext
"png"
end
|
633
634
635
636
637
638
639
640
641
|
# File 'lib/review/htmlbuilder.rb', line 633
def (id, caption)
puts %Q[<p class="caption">]
if get_chap.nil?
puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
else
puts %Q[#{I18n.t("image")}#{I18n.t("format_number_header", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
end
puts %Q[</p>]
end
|
#image_image(id, caption, metric) ⇒ Object
613
614
615
616
617
618
619
|
# File 'lib/review/htmlbuilder.rb', line 613
def image_image(id, caption, metric)
metrics = parse_metric("html", metric)
puts %Q[<div id="#{normalize_id(id)}" class="image">]
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
id, caption
puts %Q[</div>]
end
|
#important(lines, caption = nil) ⇒ Object
298
299
300
|
# File 'lib/review/htmlbuilder.rb', line 298
def important(lines, caption = nil)
captionblock("important", lines, caption)
end
|
#indepimage(id, caption = "", metric = nil) ⇒ Object
Also known as:
numberlessimage
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
|
# File 'lib/review/htmlbuilder.rb', line 734
def indepimage(id, caption="", metric=nil)
metrics = parse_metric("html", metric)
caption = "" if caption.nil?
puts %Q[<div class="image">]
begin
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
rescue
puts %Q[<pre>missing image: #{id}</pre>]
end
unless caption.empty?
puts %Q[<p class="caption">]
puts %Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
puts %Q[</p>]
end
puts %Q[</div>]
end
|
#info(lines, caption = nil) ⇒ Object
286
287
288
|
# File 'lib/review/htmlbuilder.rb', line 286
def info(lines, caption = nil)
captionblock("info", lines, caption)
end
|
#inline_abbr(str) ⇒ Object
1028
1029
1030
|
# File 'lib/review/htmlbuilder.rb', line 1028
def inline_abbr(str)
inline_asis(str, "abbr")
end
|
#inline_acronym(str) ⇒ Object
1032
1033
1034
|
# File 'lib/review/htmlbuilder.rb', line 1032
def inline_acronym(str)
inline_asis(str, "acronym")
end
|
#inline_ami(str) ⇒ Object
856
857
858
|
# File 'lib/review/htmlbuilder.rb', line 856
def inline_ami(str)
%Q(<span class="ami">#{escape_html(str)}</span>)
end
|
#inline_asis(str, tag) ⇒ Object
1024
1025
1026
|
# File 'lib/review/htmlbuilder.rb', line 1024
def inline_asis(str, tag)
%Q(<#{tag}>#{escape_html(str)}</#{tag}>)
end
|
#inline_b(str) ⇒ Object
852
853
854
|
# File 'lib/review/htmlbuilder.rb', line 852
def inline_b(str)
%Q(<b>#{escape_html(str)}</b>)
end
|
#inline_bib(id) ⇒ Object
940
941
942
|
# File 'lib/review/htmlbuilder.rb', line 940
def inline_bib(id)
%Q(<a href="#{@book.bib_file.gsub(/\.re\Z/, ".#{@book.config['htmlext']}")}#bib-#{normalize_id(id)}">[#{@chapter.bibpaper(id).number}]</a>)
end
|
#inline_big(str) ⇒ Object
1064
1065
1066
|
# File 'lib/review/htmlbuilder.rb', line 1064
def inline_big(str)
inline_asis(str, "big")
end
|
#inline_bou(str) ⇒ Object
860
861
862
|
# File 'lib/review/htmlbuilder.rb', line 860
def inline_bou(str)
%Q(<span class="bou">#{escape_html(str)}</span>)
end
|
#inline_br(str) ⇒ Object
900
901
902
|
# File 'lib/review/htmlbuilder.rb', line 900
def inline_br(str)
%Q(<br />)
end
|
#inline_chap(id) ⇒ Object
800
801
802
803
804
805
806
807
808
809
|
# File 'lib/review/htmlbuilder.rb', line 800
def inline_chap(id)
if @book.config["chapterlink"]
%Q(<a href="./#{id}#{extname}">#{@book.chapter_index.number(id)}</a>)
else
@book.chapter_index.number(id)
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_chapref(id) ⇒ Object
788
789
790
791
792
793
794
795
796
797
798
|
# File 'lib/review/htmlbuilder.rb', line 788
def inline_chapref(id)
title = super
if @book.config["chapterlink"]
%Q(<a href="./#{id}#{extname}">#{title}</a>)
else
title
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_cite(str) ⇒ Object
1036
1037
1038
|
# File 'lib/review/htmlbuilder.rb', line 1036
def inline_cite(str)
inline_asis(str, "cite")
end
|
#inline_code(str) ⇒ Object
884
885
886
887
888
889
890
|
# File 'lib/review/htmlbuilder.rb', line 884
def inline_code(str)
if @book.htmlversion == 5
%Q(<code class="inline-code tt">#{escape_html(str)}</code>)
else
%Q(<tt class="inline-code">#{escape_html(str)}</tt>)
end
end
|
#inline_column(id) ⇒ Object
965
966
967
968
969
970
971
972
973
974
|
# File 'lib/review/htmlbuilder.rb', line 965
def inline_column(id)
if @book.config["chapterlink"]
%Q(<a href="\##{column_label(id)}" class="columnref">#{I18n.t("column", escape_html(@chapter.column(id).caption))}</a>)
else
I18n.t("column", escape_html(@chapter.column(id).caption))
end
rescue KeyError
error "unknown column: #{id}"
nofunc_text("[UnknownColumn:#{id}]")
end
|
1116
1117
1118
1119
1120
1121
1122
|
# File 'lib/review/htmlbuilder.rb', line 1116
def (str)
if @book.config["draft"]
%Q(<span class="draft-comment">#{escape_html(str)}</span>)
else
%Q(<!-- #{escape_comment(escape_html(str))} -->)
end
end
|
#inline_del(str) ⇒ Object
1088
1089
1090
|
# File 'lib/review/htmlbuilder.rb', line 1088
def inline_del(str)
inline_asis(str, "del")
end
|
#inline_dfn(str) ⇒ Object
1040
1041
1042
|
# File 'lib/review/htmlbuilder.rb', line 1040
def inline_dfn(str)
inline_asis(str, "dfn")
end
|
#inline_dtp(str) ⇒ Object
880
881
882
|
# File 'lib/review/htmlbuilder.rb', line 880
def inline_dtp(str)
"<?dtp #{str} ?>"
end
|
#inline_em(str) ⇒ Object
1044
1045
1046
|
# File 'lib/review/htmlbuilder.rb', line 1044
def inline_em(str)
inline_asis(str, "em")
end
|
#inline_fn(id) ⇒ Object
823
824
825
826
827
828
829
|
# File 'lib/review/htmlbuilder.rb', line 823
def inline_fn(id)
if @book.config["epubversion"].to_i == 3
%Q(<a id="fnb-#{normalize_id(id)}" href="#fn-#{normalize_id(id)}" class="noteref" epub:type="noteref">*#{@chapter.footnote(id).number}</a>)
else
%Q(<a id="fnb-#{normalize_id(id)}" href="#fn-#{normalize_id(id)}" class="noteref">*#{@chapter.footnote(id).number}</a>)
end
end
|
#inline_hd_chap(chap, id) ⇒ Object
944
945
946
947
948
949
950
951
952
953
954
955
956
957
|
# File 'lib/review/htmlbuilder.rb', line 944
def inline_hd_chap(chap, id)
n = chap.headline_index.number(id)
if chap.number and @book.config["secnolevel"] >= n.split('.').size
str = I18n.t("chapter_quote", "#{n} #{compile_inline(chap.headline(id).caption)}")
else
str = I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
end
if @book.config["chapterlink"]
anchor = "h"+n.gsub(/\./, "-")
%Q(<a href="#{chap.id}#{extname}##{anchor}">#{str}</a>)
else
str
end
end
|
#inline_hidx(str) ⇒ Object
896
897
898
|
# File 'lib/review/htmlbuilder.rb', line 896
def inline_hidx(str)
%Q(<!-- IDX:#{escape_comment(escape_html(str))} -->)
end
|
#inline_i(str) ⇒ Object
848
849
850
|
# File 'lib/review/htmlbuilder.rb', line 848
def inline_i(str)
%Q(<i>#{escape_html(str)}</i>)
end
|
#inline_icon(id) ⇒ Object
1104
1105
1106
1107
1108
1109
1110
|
# File 'lib/review/htmlbuilder.rb', line 1104
def inline_icon(id)
begin
%Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="[#{id}]" />]
rescue
%Q[<pre>missing image: #{id}</pre>]
end
end
|
#inline_idx(str) ⇒ Object
892
893
894
|
# File 'lib/review/htmlbuilder.rb', line 892
def inline_idx(str)
%Q(#{escape_html(str)}<!-- IDX:#{escape_comment(escape_html(str))} -->)
end
|
#inline_img(id) ⇒ Object
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
|
# File 'lib/review/htmlbuilder.rb', line 1006
def inline_img(id)
chapter, id = (id)
str = nil
if get_chap(chapter).nil?
str = "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}"
else
str = "#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}"
end
if @book.config["chapterlink"]
%Q(<a href="./#{chapter.id}#{extname}##{normalize_id(id)}">#{str}</a>)
else
str
end
rescue KeyError
error "unknown image: #{id}"
nofunc_text("[UnknownImage:#{id}]")
end
|
#inline_ins(str) ⇒ Object
1092
1093
1094
|
# File 'lib/review/htmlbuilder.rb', line 1092
def inline_ins(str)
inline_asis(str, "ins")
end
|
#inline_kbd(str) ⇒ Object
1048
1049
1050
|
# File 'lib/review/htmlbuilder.rb', line 1048
def inline_kbd(str)
inline_asis(str, "kbd")
end
|
#inline_labelref(idref) ⇒ Object
Also known as:
inline_ref
782
783
784
|
# File 'lib/review/htmlbuilder.rb', line 782
def inline_labelref(idref)
%Q[<a target='#{escape_html(idref)}'>「#{I18n.t("label_marker")}#{escape_html(idref)}」</a>]
end
|
#inline_list(id) ⇒ Object
976
977
978
979
980
981
982
983
984
985
986
|
# File 'lib/review/htmlbuilder.rb', line 976
def inline_list(id)
chapter, id = (id)
if get_chap(chapter).nil?
"#{I18n.t("list")}#{I18n.t("format_number_without_header", [chapter.list(id).number])}"
else
"#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), chapter.list(id).number])}"
end
rescue KeyError
error "unknown list: #{id}"
nofunc_text("[UnknownList:#{id}]")
end
|
#inline_m(str) ⇒ Object
904
905
906
907
908
909
910
911
912
913
914
|
# File 'lib/review/htmlbuilder.rb', line 904
def inline_m(str)
if @book.config["mathml"]
require 'math_ml'
require 'math_ml/symbol/character_reference'
parser = MathML::LaTeX::Parser.new(
:symbol => MathML::Symbol::CharacterReference)
%Q[<span class="equation">#{parser.parse(str, nil)}</span>]
else
%Q[<span class="equation">#{escape_html(str)}</span>]
end
end
|
#inline_raw(str) ⇒ Object
1124
1125
1126
|
# File 'lib/review/htmlbuilder.rb', line 1124
def inline_raw(str)
super(str)
end
|
#inline_recipe(str) ⇒ Object
1100
1101
1102
|
# File 'lib/review/htmlbuilder.rb', line 1100
def inline_recipe(str)
%Q(<span class="recipe">「#{escape_html(str)}」</span>)
end
|
#inline_samp(str) ⇒ Object
1052
1053
1054
|
# File 'lib/review/htmlbuilder.rb', line 1052
def inline_samp(str)
inline_asis(str, "samp")
end
|
#inline_small(str) ⇒ Object
1068
1069
1070
|
# File 'lib/review/htmlbuilder.rb', line 1068
def inline_small(str)
inline_asis(str, "small")
end
|
#inline_strong(str) ⇒ Object
1056
1057
1058
|
# File 'lib/review/htmlbuilder.rb', line 1056
def inline_strong(str)
inline_asis(str, "strong")
end
|
#inline_sub(str) ⇒ Object
1072
1073
1074
|
# File 'lib/review/htmlbuilder.rb', line 1072
def inline_sub(str)
inline_asis(str, "sub")
end
|
#inline_sup(str) ⇒ Object
1076
1077
1078
|
# File 'lib/review/htmlbuilder.rb', line 1076
def inline_sup(str)
inline_asis(str, "sup")
end
|
#inline_table(id) ⇒ Object
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
|
# File 'lib/review/htmlbuilder.rb', line 988
def inline_table(id)
chapter, id = (id)
str = nil
if get_chap(chapter).nil?
str = "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [chapter.table(id).number])}"
else
str = "#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}"
end
if @book.config["chapterlink"]
%Q(<a href="./#{chapter.id}#{extname}##{id}">#{str}</a>)
else
str
end
rescue KeyError
error "unknown table: #{id}"
nofunc_text("[UnknownTable:#{id}]")
end
|
#inline_title(id) ⇒ Object
811
812
813
814
815
816
817
818
819
820
821
|
# File 'lib/review/htmlbuilder.rb', line 811
def inline_title(id)
title = super
if @book.config["chapterlink"]
%Q(<a href="./#{id}#{extname}">#{title}</a>)
else
title
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_tt(str) ⇒ Object
1080
1081
1082
1083
1084
1085
1086
|
# File 'lib/review/htmlbuilder.rb', line 1080
def inline_tt(str)
if @book.htmlversion == 5
%Q(<code class="tt">#{escape_html(str)}</code>)
else
%Q(<tt>#{escape_html(str)}</tt>)
end
end
|
#inline_ttb(str) ⇒ Object
872
873
874
875
876
877
878
|
# File 'lib/review/htmlbuilder.rb', line 872
def inline_ttb(str)
if @book.htmlversion == 5
%Q(<code class="tt"><b>#{escape_html(str)}</b></code>)
else
%Q(<tt><b>#{escape_html(str)}</b></tt>)
end
end
|
#inline_tti(str) ⇒ Object
864
865
866
867
868
869
870
|
# File 'lib/review/htmlbuilder.rb', line 864
def inline_tti(str)
if @book.htmlversion == 5
%Q(<code class="tt"><i>#{escape_html(str)}</i></code>)
else
%Q(<tt><i>#{escape_html(str)}</i></tt>)
end
end
|
#inline_u(str) ⇒ Object
1096
1097
1098
|
# File 'lib/review/htmlbuilder.rb', line 1096
def inline_u(str)
%Q(<u>#{escape_html(str)}</u>)
end
|
#inline_uchar(str) ⇒ Object
1112
1113
1114
|
# File 'lib/review/htmlbuilder.rb', line 1112
def inline_uchar(str)
%Q(&#x#{str};)
end
|
#inline_var(str) ⇒ Object
1060
1061
1062
|
# File 'lib/review/htmlbuilder.rb', line 1060
def inline_var(str)
inline_asis(str, "var")
end
|
#label(id) ⇒ Object
758
759
760
|
# File 'lib/review/htmlbuilder.rb', line 758
def label(id)
puts %Q(<a id="#{normalize_id(id)}"></a>)
end
|
#linebreak ⇒ Object
762
763
764
|
# File 'lib/review/htmlbuilder.rb', line 762
def linebreak
puts "<br />"
end
|
#list(lines, id, caption, lang = nil) ⇒ Object
412
413
414
415
416
417
418
419
420
421
|
# File 'lib/review/htmlbuilder.rb', line 412
def list(lines, id, caption, lang = nil)
puts %Q[<div class="caption-code">]
begin
id, caption, lang
rescue KeyError
error "no such list: #{id}"
end
list_body id, lines, lang
puts '</div>'
end
|
#list_body(id, lines, lang) ⇒ Object
431
432
433
434
435
436
437
438
|
# File 'lib/review/htmlbuilder.rb', line 431
def list_body(id, lines, lang)
id ||= ''
print %Q[<pre class="list">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang || File.extname(id).gsub(/\./, '')
puts highlight(:body => body, :lexer => lexer, :format => 'html')
puts '</pre>'
end
|
423
424
425
426
427
428
429
|
# File 'lib/review/htmlbuilder.rb', line 423
def (id, caption, lang)
if get_chap.nil?
puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
else
puts %Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
end
end
|
#listnum(lines, id, caption, lang = nil) ⇒ Object
462
463
464
465
466
467
468
469
470
471
|
# File 'lib/review/htmlbuilder.rb', line 462
def listnum(lines, id, caption, lang = nil)
puts %Q[<div class="code">]
begin
id, caption, lang
rescue KeyError
error "no such list: #{id}"
end
listnum_body lines, lang
puts '</div>'
end
|
#listnum_body(lines, lang) ⇒ Object
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
# File 'lib/review/htmlbuilder.rb', line 473
def listnum_body(lines, lang)
if highlight?
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang
puts highlight(:body => body, :lexer => lexer, :format => 'html',
:options => {:linenos => 'inline', :nowrap => false})
else
print '<pre class="list">'
lines.each_with_index do |line, i|
puts detab((i+1).to_s.rjust(2) + ": " + line)
end
puts '</pre>'
end
end
|
#memo(lines, caption = nil) ⇒ Object
278
279
280
|
# File 'lib/review/htmlbuilder.rb', line 278
def memo(lines, caption = nil)
captionblock("memo", lines, caption)
end
|
151
152
153
|
# File 'lib/review/htmlbuilder.rb', line 151
def messages
error_messages() + warning_messages()
end
|
#nofunc_text(str) ⇒ Object
1128
1129
1130
|
# File 'lib/review/htmlbuilder.rb', line 1128
def nofunc_text(str)
escape_html(str)
end
|
778
779
780
|
# File 'lib/review/htmlbuilder.rb', line 778
def noindent
@noindent = true
end
|
#nonum_begin(level, label, caption) ⇒ Object
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/review/htmlbuilder.rb', line 196
def nonum_begin(level, label, caption)
puts '' if level > 1
unless caption.empty?
if label.nil?
puts %Q[<h#{level}>#{compile_inline(caption)}</h#{level}>]
else
puts %Q[<h#{level} id="#{normalize_id(label)}">#{compile_inline(caption)}</h#{level}>]
end
end
end
|
#nonum_end(level) ⇒ Object
207
208
|
# File 'lib/review/htmlbuilder.rb', line 207
def nonum_end(level)
end
|
#note(lines, caption = nil) ⇒ Object
331
332
333
|
# File 'lib/review/htmlbuilder.rb', line 331
def note(lines, caption = nil)
captionblock("note", lines, caption)
end
|
#notice(lines, caption = nil) ⇒ Object
310
311
312
|
# File 'lib/review/htmlbuilder.rb', line 310
def notice(lines, caption = nil)
captionblock("notice", lines, caption)
end
|
355
356
357
358
359
360
361
362
|
# File 'lib/review/htmlbuilder.rb', line 355
def ol_begin
if @ol_num
puts "<ol start=\"#{@ol_num}\">"
@ol_num = nil
else
puts '<ol>'
end
end
|
368
369
370
|
# File 'lib/review/htmlbuilder.rb', line 368
def ol_end
puts '</ol>'
end
|
#ol_item(lines, num) ⇒ Object
364
365
366
|
# File 'lib/review/htmlbuilder.rb', line 364
def ol_item(lines, num)
puts "<li>#{lines.join}</li>"
end
|
#olnum(num) ⇒ Object
1156
1157
1158
|
# File 'lib/review/htmlbuilder.rb', line 1156
def olnum(num)
@ol_num = num.to_i
end
|
#pagebreak ⇒ Object
766
767
768
|
# File 'lib/review/htmlbuilder.rb', line 766
def pagebreak
puts %Q(<br class="pagebreak" />)
end
|
#paragraph(lines) ⇒ Object
388
389
390
391
392
393
394
395
|
# File 'lib/review/htmlbuilder.rb', line 388
def paragraph(lines)
if @noindent.nil?
puts "<p>#{lines.join}</p>"
else
puts %Q[<p class="noindent">#{lines.join}</p>]
@noindent = nil
end
end
|
397
398
399
|
# File 'lib/review/htmlbuilder.rb', line 397
def parasep
puts '<br />'
end
|
#planning(lines, caption = nil) ⇒ Object
290
291
292
|
# File 'lib/review/htmlbuilder.rb', line 290
def planning(lines, caption = nil)
captionblock("planning", lines, caption)
end
|
#point(lines, caption = nil) ⇒ Object
314
315
316
|
# File 'lib/review/htmlbuilder.rb', line 314
def point(lines, caption = nil)
captionblock("point", lines, caption)
end
|
#post_paragraph ⇒ Object
40
41
42
|
# File 'lib/review/htmlbuilder.rb', line 40
def post_paragraph
'</p>'
end
|
#pre_paragraph ⇒ Object
37
38
39
|
# File 'lib/review/htmlbuilder.rb', line 37
def pre_paragraph
'<p>'
end
|
#quote(lines) ⇒ Object
545
546
547
548
549
550
551
552
|
# File 'lib/review/htmlbuilder.rb', line 545
def quote(lines)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "<blockquote>#{blocked_lines.join("\n")}</blockquote>"
else
puts "<blockquote><pre>#{lines.join("\n")}</pre></blockquote>"
end
end
|
#read(lines) ⇒ Object
Also known as:
lead
401
402
403
404
405
406
407
408
|
# File 'lib/review/htmlbuilder.rb', line 401
def read(lines)
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts %Q[<div class="lead">\n#{blocked_lines.join("\n")}\n</div>]
else
puts %Q[<p class="lead">\n#{lines.join("\n")}\n</p>]
end
end
|
#ref_begin(level, label, caption) ⇒ Object
242
243
244
245
|
# File 'lib/review/htmlbuilder.rb', line 242
def ref_begin(level, label, caption)
print %Q[<div class="reference">]
headline(level, label, caption)
end
|
#ref_end(level) ⇒ Object
247
248
249
|
# File 'lib/review/htmlbuilder.rb', line 247
def ref_end(level)
puts '</div>'
end
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/review/htmlbuilder.rb', line 64
def result
layout_file = File.join(@book.basedir, "layouts", "layout.html.erb")
unless File.exist?(layout_file)
layout_file = File.join(@book.basedir, "layouts", "layout.erb")
end
if File.exist?(layout_file)
if ENV["REVIEW_SAFE_MODE"].to_i & 4 > 0
warn "user's layout is prohibited in safe mode. ignored."
else
title = strip_html(compile_inline(@chapter.title))
language = @book.config['language']
stylesheets = @book.config["stylesheet"]
toc = ""
toc_level = 0
@chapter.headline_index.items.each do |i|
caption = "<li>#{strip_html(compile_inline(i.caption))}</li>\n"
if toc_level == i.number.size
elsif toc_level < i.number.size
toc += "<ul>\n" * (i.number.size - toc_level)
toc_level = i.number.size
elsif toc_level > i.number.size
toc += "</ul>\n" * (toc_level - i.number.size)
toc_level = i.number.size
toc += "<ul>\n" * (toc_level - 1)
end
toc += caption
end
toc += "</ul>" * toc_level
return messages() +
HTMLLayout.new(
{'body' => @output.string, 'title' => title, 'toc' => toc,
'builder' => self,
'language' => language,
'stylesheets' => stylesheets,
'next' => @chapter.next_chapter,
'prev' => @chapter.prev_chapter},
layout_file).result
end
end
@error_messages = error_messages
@warning_messages = warning_messages
@title = strip_html(compile_inline(@chapter.title))
@body = @output.string
@language = @book.config['language']
@stylesheets = @book.config["stylesheet"]
if @book.htmlversion == 5
htmlfilename = "layout-html5.html.erb"
else
htmlfilename = "layout-xhtml1.html.erb"
end
tmplfile = File.expand_path('./html/'+htmlfilename, ReVIEW::Template::TEMPLATE_DIR)
tmpl = ReVIEW::Template.load(tmplfile)
tmpl.result(binding)
end
|
#result_metric(array) ⇒ Object
609
610
611
|
# File 'lib/review/htmlbuilder.rb', line 609
def result_metric(array)
" #{array.join(' ')}"
end
|
#security(lines, caption = nil) ⇒ Object
302
303
304
|
# File 'lib/review/htmlbuilder.rb', line 302
def security(lines, caption = nil)
captionblock("security", lines, caption)
end
|
#shoot(lines, caption = nil) ⇒ Object
318
319
320
|
# File 'lib/review/htmlbuilder.rb', line 318
def shoot(lines, caption = nil)
captionblock("shoot", lines, caption)
end
|
#source(lines, caption = nil, lang = nil) ⇒ Object
440
441
442
443
444
445
|
# File 'lib/review/htmlbuilder.rb', line 440
def source(lines, caption = nil, lang = nil)
puts %Q[<div class="source-code">]
caption
source_body caption, lines, lang
puts '</div>'
end
|
#source_body(id, lines, lang) ⇒ Object
453
454
455
456
457
458
459
460
|
# File 'lib/review/htmlbuilder.rb', line 453
def source_body(id, lines, lang)
id ||= ''
print %Q[<pre class="source">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang || File.extname(id).gsub(/\./, '')
puts highlight(:body => body, :lexer => lexer, :format => 'html')
puts '</pre>'
end
|
447
448
449
450
451
|
# File 'lib/review/htmlbuilder.rb', line 447
def (caption)
if caption.present?
puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
end
end
|
#sup_begin(level, label, caption) ⇒ Object
251
252
253
254
|
# File 'lib/review/htmlbuilder.rb', line 251
def sup_begin(level, label, caption)
print %Q[<div class="supplement">]
headline(level, label, caption)
end
|
#sup_end(level) ⇒ Object
256
257
258
|
# File 'lib/review/htmlbuilder.rb', line 256
def sup_end(level)
puts '</div>'
end
|
#table(lines, id = nil, caption = nil) ⇒ Object
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
|
# File 'lib/review/htmlbuilder.rb', line 643
def table(lines, id = nil, caption = nil)
rows = []
sepidx = nil
lines.each_with_index do |line, idx|
if /\A[\=\-]{12}/ =~ line
sepidx ||= idx
next
end
rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
end
rows = adjust_n_cols(rows)
if id
puts %Q[<div id="#{normalize_id(id)}" class="table">]
else
puts %Q[<div class="table">]
end
begin
id, caption unless caption.nil?
rescue KeyError
error "no such table: #{id}"
end
table_begin rows.first.size
return if rows.empty?
if sepidx
sepidx.times do
tr rows.shift.map {|s| th(s) }
end
rows.each do |cols|
tr cols.map {|s| td(s) }
end
else
rows.each do |cols|
h, *cs = *cols
tr [th(h)] + cs.map {|s| td(s) }
end
end
table_end
puts %Q[</div>]
end
|
#table_begin(ncols) ⇒ Object
694
695
696
|
# File 'lib/review/htmlbuilder.rb', line 694
def table_begin(ncols)
puts '<table>'
end
|
#table_end ⇒ Object
710
711
712
|
# File 'lib/review/htmlbuilder.rb', line 710
def table_end
puts '</table>'
end
|
686
687
688
689
690
691
692
|
# File 'lib/review/htmlbuilder.rb', line 686
def (id, caption)
if get_chap.nil?
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
else
puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
end
end
|
#talk(lines) ⇒ Object
572
573
574
575
576
577
578
579
580
581
582
583
|
# File 'lib/review/htmlbuilder.rb', line 572
def talk(lines)
puts %Q[<div class="talk">]
if @book.config["deprecated-blocklines"].nil?
blocked_lines = split_paragraph(lines)
puts "#{blocked_lines.join("\n")}"
else
print '<pre>'
puts "#{lines.join("\n")}"
puts '</pre>'
end
puts '</div>'
end
|
706
707
708
|
# File 'lib/review/htmlbuilder.rb', line 706
def td(str)
"<td>#{str}</td>"
end
|
#texequation(lines) ⇒ Object
585
586
587
588
589
590
591
592
593
594
595
596
597
598
|
# File 'lib/review/htmlbuilder.rb', line 585
def texequation(lines)
puts %Q[<div class="equation">]
if @book.config["mathml"]
require 'math_ml'
require 'math_ml/symbol/character_reference'
p = MathML::LaTeX::Parser.new(:symbol=>MathML::Symbol::CharacterReference)
puts p.parse(unescape_html(lines.join("\n")), true)
else
print '<pre>'
puts "#{lines.join("\n")}"
puts '</pre>'
end
puts '</div>'
end
|
#text(str) ⇒ Object
916
917
918
|
# File 'lib/review/htmlbuilder.rb', line 916
def text(str)
str
end
|
702
703
704
|
# File 'lib/review/htmlbuilder.rb', line 702
def th(str)
"<th>#{str}</th>"
end
|
#tip(lines, caption = nil) ⇒ Object
282
283
284
|
# File 'lib/review/htmlbuilder.rb', line 282
def tip(lines, caption = nil)
captionblock("tip", lines, caption)
end
|
698
699
700
|
# File 'lib/review/htmlbuilder.rb', line 698
def tr(rows)
puts "<tr>#{rows.join}</tr>"
end
|
#tsize(str) ⇒ Object
260
261
262
|
# File 'lib/review/htmlbuilder.rb', line 260
def tsize(str)
end
|
335
336
337
|
# File 'lib/review/htmlbuilder.rb', line 335
def ul_begin
puts '<ul>'
end
|
351
352
353
|
# File 'lib/review/htmlbuilder.rb', line 351
def ul_end
puts '</ul>'
end
|
#ul_item(lines) ⇒ Object
339
340
341
|
# File 'lib/review/htmlbuilder.rb', line 339
def ul_item(lines)
puts "<li>#{lines.join}</li>"
end
|
#ul_item_begin(lines) ⇒ Object
343
344
345
|
# File 'lib/review/htmlbuilder.rb', line 343
def ul_item_begin(lines)
print "<li>#{lines.join}"
end
|
#ul_item_end ⇒ Object
347
348
349
|
# File 'lib/review/htmlbuilder.rb', line 347
def ul_item_end
puts "</li>"
end
|
#warn(msg) ⇒ Object
133
134
135
136
137
138
139
140
|
# File 'lib/review/htmlbuilder.rb', line 133
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_messages ⇒ Object
165
166
167
168
169
170
171
172
173
|
# File 'lib/review/htmlbuilder.rb', line 165
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
|
#xcolumn_begin(level, label, caption) ⇒ Object
233
234
235
236
|
# File 'lib/review/htmlbuilder.rb', line 233
def xcolumn_begin(level, label, caption)
puts %Q[<div class="xcolumn">]
headline(level, label, caption)
end
|
#xcolumn_end(level) ⇒ Object
238
239
240
|
# File 'lib/review/htmlbuilder.rb', line 238
def xcolumn_end(level)
puts '</div>'
end
|
#xmlns_ops_prefix ⇒ Object
125
126
127
128
129
130
131
|
# File 'lib/review/htmlbuilder.rb', line 125
def xmlns_ops_prefix
if @book.config["epubversion"].to_i == 3
"epub"
else
"ops"
end
end
|