Class: ReVIEW::HTMLBuilder
Constant Summary
Constants included
from HTMLUtils
ReVIEW::HTMLUtils::ESC
Constants inherited
from Builder
Builder::CAPTION_TITLES
Instance Attribute Summary
Attributes inherited from Builder
#ast, #output
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
-
#node_texequation(node) ⇒ 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
-
#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
-
#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
Methods inherited from Builder
#bind, #detab, #extract_chapter_id, #get_chap, #graph, #image, #include, #initialize, #inline_href, #inline_include, #inline_kw, #inline_ruby, #node_inline_hd, #node_inline_img, #node_inline_imgref, #parse_metric, #post_paragraph, #pre_paragraph, #print, #puts, #raw, #target_name
Instance Method Details
#best(lines, caption = nil) ⇒ Object
289
290
291
|
# File 'lib/review/htmlbuilder.rb', line 289
def best(lines, caption = nil)
captionblock("best", lines, caption)
end
|
#bibpaper(lines, id, caption) ⇒ Object
927
928
929
930
931
932
933
934
935
|
# File 'lib/review/htmlbuilder.rb', line 927
def bibpaper(lines, id, caption)
buf = %Q[<div class="bibpaper">\n]
buf << (id, caption)
unless lines.empty?
buf << bibpaper_bibpaper(id, caption, lines)
end
buf << "</div>" << "\n"
buf
end
|
#bibpaper_bibpaper(id, caption, lines) ⇒ Object
944
945
946
|
# File 'lib/review/htmlbuilder.rb', line 944
def bibpaper_bibpaper(id, caption, lines)
lines.join("")
end
|
937
938
939
940
941
942
|
# File 'lib/review/htmlbuilder.rb', line 937
def (id, caption)
buf = %Q(<a id="bib-#{normalize_id(id)}">)
buf << "[#{@chapter.bibpaper(id).number}]"
buf << %Q(</a>)
buf << " #{(caption)}" << "\n"
end
|
#box(lines, caption = nil) ⇒ Object
317
318
319
320
321
322
323
324
325
326
|
# File 'lib/review/htmlbuilder.rb', line 317
def box(lines, caption = nil)
buf = ""
buf << %Q[<div class="syntax">\n]
buf << %Q[<p class="caption">#{caption}</p>\n] unless caption.nil?
buf << %Q[<pre class="syntax">]
lines.each {|line| buf << detab(line) << "\n" }
buf << "</pre>\n"
buf << "</div>\n"
buf
end
|
#bpo(lines) ⇒ Object
776
777
778
779
780
781
782
783
|
# File 'lib/review/htmlbuilder.rb', line 776
def bpo(lines)
buf = "<bpo>\n"
lines.each do |line|
buf << detab(line) + "\n"
end
buf << "</bpo>\n"
buf
end
|
#captionblock(type, lines, caption) ⇒ Object
259
260
261
262
263
264
265
266
267
268
269
270
271
|
# File 'lib/review/htmlbuilder.rb', line 259
def captionblock(type, lines, caption)
buf = %Q[<div class="#{type}">\n]
unless caption.nil?
buf << %Q[<p class="caption">#{caption}</p>\n]
end
if @book.config["deprecated-blocklines"].nil?
buf << lines.join("")
else
error "deprecated-blocklines is obsoleted."
end
buf << "</div>\n"
buf
end
|
#caution(lines, caption = nil) ⇒ Object
301
302
303
|
# File 'lib/review/htmlbuilder.rb', line 301
def caution(lines, caption = nil)
captionblock("caution", lines, caption)
end
|
#centering(lines) ⇒ Object
1154
1155
1156
|
# File 'lib/review/htmlbuilder.rb', line 1154
def centering(lines)
lines.join("").gsub("<p>", "<p class=\"center\">")
end
|
#cmd(lines, caption = nil) ⇒ Object
528
529
530
531
532
533
534
535
536
537
538
539
540
|
# File 'lib/review/htmlbuilder.rb', line 528
def cmd(lines, caption = nil)
buf = %Q[<div class="cmd-code">\n]
if caption.present?
buf << %Q(<p class="caption">#{caption}</p>\n)
end
buf << %Q[<pre class="cmd">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = 'shell-session'
buf << highlight(:body => body, :lexer => lexer, :format => 'html')
buf << "</pre>\n"
buf << "</div>\n"
buf
end
|
#column_begin(level, label, caption) ⇒ Object
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
# File 'lib/review/htmlbuilder.rb', line 202
def column_begin(level, label, caption)
buf = %Q[<div class="column">\n]
@column += 1
buf << "\n" if level > 1
a_id = %Q[<a id="column-#{@column}"></a>]
if caption.empty?
buf << a_id + "\n" unless label.nil?
else
if label.nil?
buf << %Q[<h#{level}>#{a_id}#{caption}</h#{level}>\n]
else
buf << %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{caption}</h#{level}>\n]
end
end
buf
end
|
#column_end(level) ⇒ Object
221
222
223
|
# File 'lib/review/htmlbuilder.rb', line 221
def column_end(level)
"</div>\n"
end
|
719
720
721
722
723
724
725
726
727
728
729
|
# File 'lib/review/htmlbuilder.rb', line 719
def (lines, = nil)
lines ||= []
lines.unshift unless .blank?
if @book.config["draft"]
str = lines.map{|line| escape_html(line) }.join("<br />")
return %Q(<div class="draft-comment">#{str}</div>\n)
else
str = lines.join("\n")
return %Q(<!-- #{escape_comment(str)} -->\n)
end
end
|
#compile_href(url, label) ⇒ Object
1140
1141
1142
|
# File 'lib/review/htmlbuilder.rb', line 1140
def compile_href(url, label)
%Q(<a href="#{escape_html(url)}" class="link">#{label.nil? ? (url) : (label)}</a>)
end
|
#compile_kw(word, alt) ⇒ Object
846
847
848
849
850
851
852
853
|
# File 'lib/review/htmlbuilder.rb', line 846
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
838
839
840
841
842
843
844
|
# File 'lib/review/htmlbuilder.rb', line 838
def compile_ruby(base, ruby)
if @book.htmlversion == 5
%Q[<ruby>#{base}<rp>#{I18n.t("ruby_prefix")}</rp><rt>#{ruby}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
else
%Q[<ruby><rb>#{(base)}</rb><rp>#{I18n.t("ruby_prefix")}</rp><rt>#{ruby}</rt><rp>#{I18n.t("ruby_postfix")}</rp></ruby>]
end
end
|
#dd(lines) ⇒ Object
378
379
380
|
# File 'lib/review/htmlbuilder.rb', line 378
def dd(lines)
"<dd>#{lines.join}</dd>\n"
end
|
370
371
372
|
# File 'lib/review/htmlbuilder.rb', line 370
def dl_begin
"<dl>\n"
end
|
382
383
384
|
# File 'lib/review/htmlbuilder.rb', line 382
def dl_end
"</dl>\n"
end
|
#doorquote(lines, ref) ⇒ Object
559
560
561
562
563
564
565
566
567
568
569
570
|
# File 'lib/review/htmlbuilder.rb', line 559
def doorquote(lines, ref)
buf = ""
if @book.config["deprecated-blocklines"].nil?
buf << %Q[<blockquote style="text-align:right;">\n]
buf << "#{lines.join("")}\n"
buf << %Q[<p>#{ref}より</p>\n]
buf << %Q[</blockquote>\n]
else
error "deprecated-blocklines is obsoleted."
end
buf
end
|
374
375
376
|
# File 'lib/review/htmlbuilder.rb', line 374
def dt(line)
"<dt>#{line}</dt>\n"
end
|
#emlist(lines, caption = nil, lang = nil) ⇒ Object
492
493
494
495
496
497
498
499
500
501
502
503
504
|
# File 'lib/review/htmlbuilder.rb', line 492
def emlist(lines, caption = nil, lang = nil)
buf = %Q[<div class="emlist-code">\n]
if caption.present?
buf << %Q(<p class="caption">#{caption}</p>\n)
end
buf << %Q[<pre class="emlist">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang
buf << highlight(:body => body, :lexer => lexer, :format => 'html')
buf << "</pre>\n"
buf << "</div>\n"
buf
end
|
#emlistnum(lines, caption = nil, lang = nil) ⇒ Object
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
|
# File 'lib/review/htmlbuilder.rb', line 506
def emlistnum(lines, caption = nil, lang = nil)
buf = %Q[<div class="emlistnum-code">\n]
if caption.present?
buf << %Q(<p class="caption">#{caption}</p>\n)
end
if highlight?
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang
buf << highlight(:body => body, :lexer => lexer, :format => 'html',
:options => {:linenos => 'inline', :nowrap => false})
else
buf << '<pre class="emlist">'
lines.each_with_index do |line, i|
buf << detab((i+1).to_s.rjust(2) + ": " + line) << "\n"
end
buf << '</pre>' << "\n"
end
buf << '</div>' << "\n"
buf
end
|
#error(msg) ⇒ Object
131
132
133
134
135
136
137
138
|
# File 'lib/review/htmlbuilder.rb', line 131
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
144
145
146
147
148
149
150
151
152
|
# File 'lib/review/htmlbuilder.rb', line 144
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
|
37
38
39
|
# File 'lib/review/htmlbuilder.rb', line 37
def extname
".#{@book.config["htmlext"]}"
end
|
#flushright(lines) ⇒ Object
1144
1145
1146
1147
1148
1149
1150
1151
1152
|
# File 'lib/review/htmlbuilder.rb', line 1144
def flushright(lines)
result = ""
if @book.config["deprecated-blocklines"].nil?
result << lines.join("").gsub("<p>", "<p class=\"flushright\">")
else
error "deprecated-blocklines is obsoleted."
end
result
end
|
731
732
733
734
735
736
737
|
# File 'lib/review/htmlbuilder.rb', line 731
def (id, str)
if @book.config["epubversion"].to_i == 3
%Q(<div class="footnote" epub:type="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[*#{@chapter.footnote(id).number}] #{str}</p></div>\n)
else
%Q(<div class="footnote" id="fn-#{normalize_id(id)}"><p class="footnote">[<a href="#fnb-#{normalize_id(id)}">*#{@chapter.footnote(id).number}</a>] #{str}</p></div>\n)
end
end
|
#handle_metric(str) ⇒ Object
601
602
603
604
605
606
607
608
|
# File 'lib/review/htmlbuilder.rb', line 601
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(/\A["']/, '').sub(/"\Z/, '').sub(/["']\Z/, '')}\"|
end
end
|
#headline(level, label, caption) ⇒ Object
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/review/htmlbuilder.rb', line 164
def headline(level, label, caption)
buf = ""
prefix, anchor = headline_prefix(level)
unless prefix.nil?
prefix = %Q[<span class="secno">#{prefix}</span>]
end
a_id = ""
unless anchor.nil?
a_id = %Q[<a id="h#{anchor}"></a>]
end
if caption.empty?
buf << a_id+"\n" unless label.nil?
else
if label.nil?
buf << %Q[<h#{level}>#{a_id}#{prefix}#{caption}</h#{level}>\n]
else
buf << %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{prefix}#{caption}</h#{level}>\n]
end
end
buf
end
|
760
761
762
|
# File 'lib/review/htmlbuilder.rb', line 760
def hr
"<hr />\n"
end
|
#image_dummy(id, caption, lines) ⇒ Object
623
624
625
626
627
628
629
630
631
632
633
634
|
# File 'lib/review/htmlbuilder.rb', line 623
def image_dummy(id, caption, lines)
buf = %Q[<div class="image">\n]
buf << %Q[<pre class="dummyimage">\n]
lines.each do |line|
buf << detab(line) << "\n"
end
buf << %Q[</pre>\n]
buf << (id, caption)
buf << %Q[</div>\n]
warn "no such image: #{id}"
buf
end
|
#image_ext ⇒ Object
1158
1159
1160
|
# File 'lib/review/htmlbuilder.rb', line 1158
def image_ext
"png"
end
|
636
637
638
639
640
641
642
643
644
645
|
# File 'lib/review/htmlbuilder.rb', line 636
def (id, caption)
buf = %Q[<p class="caption">\n]
if get_chap.nil?
buf << %Q[#{I18n.t("image")}#{I18n.t("format_number_header_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix")}#{caption}\n]
else
buf << %Q[#{I18n.t("image")}#{I18n.t("format_number_header", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix")}#{caption}\n]
end
buf << %Q[</p>\n]
buf
end
|
#image_image(id, caption, metric) ⇒ Object
614
615
616
617
618
619
620
621
|
# File 'lib/review/htmlbuilder.rb', line 614
def image_image(id, caption, metric)
metrics = parse_metric("html", metric)
buf = %Q[<div id="#{normalize_id(id)}" class="image">\n]
buf << %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(caption)}"#{metrics} />\n]
buf << (id, caption)
buf << %Q[</div>\n]
buf
end
|
#important(lines, caption = nil) ⇒ Object
293
294
295
|
# File 'lib/review/htmlbuilder.rb', line 293
def important(lines, caption = nil)
captionblock("important", lines, caption)
end
|
#indepimage(id, caption = "", metric = nil) ⇒ Object
Also known as:
numberlessimage
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
|
# File 'lib/review/htmlbuilder.rb', line 739
def indepimage(id, caption="", metric=nil)
metrics = parse_metric("html", metric)
caption = "" if caption.nil?
buf = %Q[<div class="image">\n]
begin
buf << %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(caption)}"#{metrics} />\n]
rescue
buf << %Q[<pre>missing image: #{id}</pre>\n]
end
unless caption.empty?
buf << %Q[<p class="caption">\n]
buf << %Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{caption}\n]
buf << %Q[</p>\n]
end
buf << %Q[</div>\n]
buf
end
|
#info(lines, caption = nil) ⇒ Object
281
282
283
|
# File 'lib/review/htmlbuilder.rb', line 281
def info(lines, caption = nil)
captionblock("info", lines, caption)
end
|
#inline_abbr(str) ⇒ Object
1036
1037
1038
|
# File 'lib/review/htmlbuilder.rb', line 1036
def inline_abbr(str)
inline_asis(str, "abbr")
end
|
#inline_acronym(str) ⇒ Object
1040
1041
1042
|
# File 'lib/review/htmlbuilder.rb', line 1040
def inline_acronym(str)
inline_asis(str, "acronym")
end
|
#inline_ami(str) ⇒ Object
863
864
865
|
# File 'lib/review/htmlbuilder.rb', line 863
def inline_ami(str)
%Q(<span class="ami">#{(str)}</span>)
end
|
#inline_asis(str, tag) ⇒ Object
1032
1033
1034
|
# File 'lib/review/htmlbuilder.rb', line 1032
def inline_asis(str, tag)
%Q(<#{tag}>#{(str)}</#{tag}>)
end
|
#inline_b(str) ⇒ Object
859
860
861
|
# File 'lib/review/htmlbuilder.rb', line 859
def inline_b(str)
%Q(<b>#{str}</b>)
end
|
#inline_bib(id) ⇒ Object
948
949
950
|
# File 'lib/review/htmlbuilder.rb', line 948
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
1072
1073
1074
|
# File 'lib/review/htmlbuilder.rb', line 1072
def inline_big(str)
inline_asis(str, "big")
end
|
#inline_bou(str) ⇒ Object
867
868
869
|
# File 'lib/review/htmlbuilder.rb', line 867
def inline_bou(str)
%Q(<span class="bou">#{(str)}</span>)
end
|
#inline_br(str) ⇒ Object
907
908
909
|
# File 'lib/review/htmlbuilder.rb', line 907
def inline_br(str)
%Q(<br />)
end
|
#inline_chap(id) ⇒ Object
807
808
809
810
811
812
813
814
815
816
|
# File 'lib/review/htmlbuilder.rb', line 807
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
795
796
797
798
799
800
801
802
803
804
805
|
# File 'lib/review/htmlbuilder.rb', line 795
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
1044
1045
1046
|
# File 'lib/review/htmlbuilder.rb', line 1044
def inline_cite(str)
inline_asis(str, "cite")
end
|
#inline_code(str) ⇒ Object
891
892
893
894
895
896
897
|
# File 'lib/review/htmlbuilder.rb', line 891
def inline_code(str)
if @book.htmlversion == 5
%Q(<code class="inline-code tt">#{(str)}</code>)
else
%Q(<tt class="inline-code">#{(str)}</tt>)
end
end
|
#inline_column(id) ⇒ Object
973
974
975
976
977
978
979
980
981
982
|
# File 'lib/review/htmlbuilder.rb', line 973
def inline_column(id)
if @book.config["chapterlink"]
%Q(<a href="\##{column_label(id)}" class="columnref">#{I18n.t("column", (@chapter.column(id).caption))}</a>)
else
I18n.t("column", (@chapter.column(id).caption))
end
rescue KeyError
error "unknown column: #{id}"
nofunc_text("[UnknownColumn:#{id}]")
end
|
1124
1125
1126
1127
1128
1129
1130
|
# File 'lib/review/htmlbuilder.rb', line 1124
def (str)
if @book.config["draft"]
%Q(<span class="draft-comment">#{(str)}</span>)
else
%Q(<!-- #{escape_comment(escape_html(str))} -->)
end
end
|
#inline_del(str) ⇒ Object
1096
1097
1098
|
# File 'lib/review/htmlbuilder.rb', line 1096
def inline_del(str)
inline_asis(str, "del")
end
|
#inline_dfn(str) ⇒ Object
1048
1049
1050
|
# File 'lib/review/htmlbuilder.rb', line 1048
def inline_dfn(str)
inline_asis(str, "dfn")
end
|
#inline_dtp(str) ⇒ Object
887
888
889
|
# File 'lib/review/htmlbuilder.rb', line 887
def inline_dtp(str)
"<?dtp #{str} ?>"
end
|
#inline_em(str) ⇒ Object
1052
1053
1054
|
# File 'lib/review/htmlbuilder.rb', line 1052
def inline_em(str)
inline_asis(str, "em")
end
|
#inline_fn(id) ⇒ Object
830
831
832
833
834
835
836
|
# File 'lib/review/htmlbuilder.rb', line 830
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
952
953
954
955
956
957
958
959
960
961
962
963
964
965
|
# File 'lib/review/htmlbuilder.rb', line 952
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} #{chap.headline(id).caption}")
else
str = I18n.t("chapter_quote", 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
903
904
905
|
# File 'lib/review/htmlbuilder.rb', line 903
def inline_hidx(str)
%Q(<!-- IDX:#{escape_comment(escape_html(str))} -->)
end
|
#inline_i(str) ⇒ Object
855
856
857
|
# File 'lib/review/htmlbuilder.rb', line 855
def inline_i(str)
%Q(<i>#{str}</i>)
end
|
#inline_icon(id) ⇒ Object
1112
1113
1114
1115
1116
1117
1118
|
# File 'lib/review/htmlbuilder.rb', line 1112
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
899
900
901
|
# File 'lib/review/htmlbuilder.rb', line 899
def inline_idx(str)
%Q(#{(str)}<!-- IDX:#{escape_comment(escape_html(str))} -->)
end
|
#inline_img(id) ⇒ Object
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
|
# File 'lib/review/htmlbuilder.rb', line 1014
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
1100
1101
1102
|
# File 'lib/review/htmlbuilder.rb', line 1100
def inline_ins(str)
inline_asis(str, "ins")
end
|
#inline_kbd(str) ⇒ Object
1056
1057
1058
|
# File 'lib/review/htmlbuilder.rb', line 1056
def inline_kbd(str)
inline_asis(str, "kbd")
end
|
#inline_labelref(idref) ⇒ Object
Also known as:
inline_ref
789
790
791
|
# File 'lib/review/htmlbuilder.rb', line 789
def inline_labelref(idref)
%Q[<a target='#{(idref)}'>「#{I18n.t("label_marker")}#{(idref)}」</a>]
end
|
#inline_list(id) ⇒ Object
984
985
986
987
988
989
990
991
992
993
994
|
# File 'lib/review/htmlbuilder.rb', line 984
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
911
912
913
914
915
916
917
918
919
920
921
|
# File 'lib/review/htmlbuilder.rb', line 911
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">#{(str)}</span>]
end
end
|
#inline_raw(str) ⇒ Object
1132
1133
1134
|
# File 'lib/review/htmlbuilder.rb', line 1132
def inline_raw(str)
super(str)
end
|
#inline_recipe(str) ⇒ Object
1108
1109
1110
|
# File 'lib/review/htmlbuilder.rb', line 1108
def inline_recipe(str)
%Q(<span class="recipe">「#{(str)}」</span>)
end
|
#inline_samp(str) ⇒ Object
1060
1061
1062
|
# File 'lib/review/htmlbuilder.rb', line 1060
def inline_samp(str)
inline_asis(str, "samp")
end
|
#inline_small(str) ⇒ Object
1076
1077
1078
|
# File 'lib/review/htmlbuilder.rb', line 1076
def inline_small(str)
inline_asis(str, "small")
end
|
#inline_strong(str) ⇒ Object
1064
1065
1066
|
# File 'lib/review/htmlbuilder.rb', line 1064
def inline_strong(str)
inline_asis(str, "strong")
end
|
#inline_sub(str) ⇒ Object
1080
1081
1082
|
# File 'lib/review/htmlbuilder.rb', line 1080
def inline_sub(str)
inline_asis(str, "sub")
end
|
#inline_sup(str) ⇒ Object
1084
1085
1086
|
# File 'lib/review/htmlbuilder.rb', line 1084
def inline_sup(str)
inline_asis(str, "sup")
end
|
#inline_table(id) ⇒ Object
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
|
# File 'lib/review/htmlbuilder.rb', line 996
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
818
819
820
821
822
823
824
825
826
827
828
|
# File 'lib/review/htmlbuilder.rb', line 818
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
1088
1089
1090
1091
1092
1093
1094
|
# File 'lib/review/htmlbuilder.rb', line 1088
def inline_tt(str)
if @book.htmlversion == 5
%Q(<code class="tt">#{(str)}</code>)
else
%Q(<tt>#{(str)}</tt>)
end
end
|
#inline_ttb(str) ⇒ Object
879
880
881
882
883
884
885
|
# File 'lib/review/htmlbuilder.rb', line 879
def inline_ttb(str)
if @book.htmlversion == 5
%Q(<code class="tt"><b>#{(str)}</b></code>)
else
%Q(<tt><b>#{(str)}</b></tt>)
end
end
|
#inline_tti(str) ⇒ Object
871
872
873
874
875
876
877
|
# File 'lib/review/htmlbuilder.rb', line 871
def inline_tti(str)
if @book.htmlversion == 5
%Q(<code class="tt"><i>#{(str)}</i></code>)
else
%Q(<tt><i>#{(str)}</i></tt>)
end
end
|
#inline_u(str) ⇒ Object
1104
1105
1106
|
# File 'lib/review/htmlbuilder.rb', line 1104
def inline_u(str)
%Q(<u>#{(str)}</u>)
end
|
#inline_uchar(str) ⇒ Object
1120
1121
1122
|
# File 'lib/review/htmlbuilder.rb', line 1120
def inline_uchar(str)
%Q(&#x#{str};)
end
|
#inline_var(str) ⇒ Object
1068
1069
1070
|
# File 'lib/review/htmlbuilder.rb', line 1068
def inline_var(str)
inline_asis(str, "var")
end
|
#label(id) ⇒ Object
764
765
766
|
# File 'lib/review/htmlbuilder.rb', line 764
def label(id)
%Q(<a id="#{normalize_id(id)}"></a>\n)
end
|
#linebreak ⇒ Object
768
769
770
|
# File 'lib/review/htmlbuilder.rb', line 768
def linebreak
"<br />\n"
end
|
#list(lines, id, caption, lang = nil) ⇒ Object
409
410
411
412
413
414
415
416
417
418
419
|
# File 'lib/review/htmlbuilder.rb', line 409
def list(lines, id, caption, lang = nil)
buf = %Q[<div class="caption-code">\n]
begin
buf << (id, caption, lang)
rescue KeyError
error "no such list: #{id}"
end
buf << list_body(id, lines, lang)
buf << "</div>\n"
buf
end
|
#list_body(id, lines, lang) ⇒ Object
429
430
431
432
433
434
435
436
437
|
# File 'lib/review/htmlbuilder.rb', line 429
def list_body(id, lines, lang)
id ||= ''
buf = %Q[<pre class="list">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang || File.extname(id).gsub(/\./, '')
buf << highlight(:body => body, :lexer => lexer, :format => 'html')
buf << "</pre>\n"
buf
end
|
421
422
423
424
425
426
427
|
# File 'lib/review/htmlbuilder.rb', line 421
def (id, caption, lang)
if get_chap.nil?
%Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}</p>\n]
else
%Q[<p class="caption">#{I18n.t("list")}#{I18n.t("format_number_header", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}</p>\n]
end
end
|
#listnum(lines, id, caption, lang = nil) ⇒ Object
463
464
465
466
467
468
469
470
471
472
473
|
# File 'lib/review/htmlbuilder.rb', line 463
def listnum(lines, id, caption, lang = nil)
buf = %Q[<div class="code">\n]
begin
buf << (id, caption, lang)
rescue KeyError
error "no such list: #{id}"
end
buf << listnum_body(lines, lang)
buf << "</div>"
buf
end
|
#listnum_body(lines, lang) ⇒ Object
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
|
# File 'lib/review/htmlbuilder.rb', line 475
def listnum_body(lines, lang)
buf = ""
if highlight?
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang
buf << highlight(:body => body, :lexer => lexer, :format => 'html',
:options => {:linenos => 'inline', :nowrap => false})
else
buf << '<pre class="list">'
lines.each_with_index do |line, i|
buf << detab((i+1).to_s.rjust(2) + ": " + line) << "\n"
end
buf << '</pre>' << "\n"
end
buf
end
|
#memo(lines, caption = nil) ⇒ Object
273
274
275
|
# File 'lib/review/htmlbuilder.rb', line 273
def memo(lines, caption = nil)
captionblock("memo", lines, caption)
end
|
140
141
142
|
# File 'lib/review/htmlbuilder.rb', line 140
def messages
error_messages() + warning_messages()
end
|
#node_texequation(node) ⇒ Object
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
|
# File 'lib/review/htmlbuilder.rb', line 584
def node_texequation(node)
buf = ""
buf << %Q[<div class="equation">\n]
if @book.config["mathml"]
require 'math_ml'
require 'math_ml/symbol/character_reference'
p = MathML::LaTeX::Parser.new(:symbol=>MathML::Symbol::CharacterReference)
buf << p.parse(node.to_raw, true).to_s << "\n"
else
buf << '<pre>'
buf << lines.join("\n") << "\n"
buf << "</pre>\n"
end
buf << "</div>\n"
buf
end
|
#nofunc_text(str) ⇒ Object
1136
1137
1138
|
# File 'lib/review/htmlbuilder.rb', line 1136
def nofunc_text(str)
escape_html(str)
end
|
785
786
787
|
# File 'lib/review/htmlbuilder.rb', line 785
def noindent
@noindent = true
end
|
#nonum_begin(level, label, caption) ⇒ Object
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/review/htmlbuilder.rb', line 186
def nonum_begin(level, label, caption)
buf = ""
buf << "\n" if level > 1
unless caption.empty?
if label.nil?
buf << %Q[<h#{level}>#{caption}</h#{level}>\n]
else
buf << %Q[<h#{level} id="#{normalize_id(label)}">#{caption}</h#{level}>\n]
end
end
buf
end
|
#nonum_end(level) ⇒ Object
199
200
|
# File 'lib/review/htmlbuilder.rb', line 199
def nonum_end(level)
end
|
#note(lines, caption = nil) ⇒ Object
328
329
330
|
# File 'lib/review/htmlbuilder.rb', line 328
def note(lines, caption = nil)
captionblock("note", lines, caption)
end
|
#notice(lines, caption = nil) ⇒ Object
305
306
307
|
# File 'lib/review/htmlbuilder.rb', line 305
def notice(lines, caption = nil)
captionblock("notice", lines, caption)
end
|
352
353
354
355
356
357
358
359
360
|
# File 'lib/review/htmlbuilder.rb', line 352
def ol_begin
if @ol_num
num = @ol_num
@ol_num = nil
"<ol start=\"#{num}\">\n"
else
"<ol>\n"
end
end
|
366
367
368
|
# File 'lib/review/htmlbuilder.rb', line 366
def ol_end
"</ol>\n"
end
|
#ol_item(lines, num) ⇒ Object
362
363
364
|
# File 'lib/review/htmlbuilder.rb', line 362
def ol_item(lines, num)
"<li>#{lines.map(&:to_s).join}</li>\n"
end
|
#olnum(num) ⇒ Object
1162
1163
1164
|
# File 'lib/review/htmlbuilder.rb', line 1162
def olnum(num)
@ol_num = num.to_i
end
|
#pagebreak ⇒ Object
772
773
774
|
# File 'lib/review/htmlbuilder.rb', line 772
def pagebreak
%Q(<br class="pagebreak" />\n)
end
|
#paragraph(lines) ⇒ Object
386
387
388
389
390
391
392
393
|
# File 'lib/review/htmlbuilder.rb', line 386
def paragraph(lines)
if @noindent.nil?
"<p>#{lines.join}</p>\n"
else
@noindent = nil
%Q[<p class="noindent">#{lines.join}</p>\n]
end
end
|
395
396
397
|
# File 'lib/review/htmlbuilder.rb', line 395
def parasep
"<br />\n"
end
|
#planning(lines, caption = nil) ⇒ Object
285
286
287
|
# File 'lib/review/htmlbuilder.rb', line 285
def planning(lines, caption = nil)
captionblock("planning", lines, caption)
end
|
#point(lines, caption = nil) ⇒ Object
309
310
311
|
# File 'lib/review/htmlbuilder.rb', line 309
def point(lines, caption = nil)
captionblock("point", lines, caption)
end
|
#quote(lines) ⇒ Object
551
552
553
554
555
556
557
|
# File 'lib/review/htmlbuilder.rb', line 551
def quote(lines)
if @book.config["deprecated-blocklines"].nil?
"<blockquote>#{lines.join("")}</blockquote>\n"
else
error "deprecated-blocklines is obsoleted."
end
end
|
#read(lines) ⇒ Object
Also known as:
lead
399
400
401
402
403
404
405
|
# File 'lib/review/htmlbuilder.rb', line 399
def read(lines)
if @book.config["deprecated-blocklines"].nil?
%Q[<div class="lead">\n#{lines.join("")}\n</div>\n]
else
error "deprecated-blocklines is obsoleted."
end
end
|
#ref_begin(level, label, caption) ⇒ Object
235
236
237
238
239
|
# File 'lib/review/htmlbuilder.rb', line 235
def ref_begin(level, label, caption)
buf << %Q[<div class="reference">\n]
buf << headline(level, label, caption)
buf
end
|
#ref_end(level) ⇒ Object
241
242
243
|
# File 'lib/review/htmlbuilder.rb', line 241
def ref_end(level)
"</div>\n"
end
|
57
58
59
60
61
62
63
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
|
# File 'lib/review/htmlbuilder.rb', line 57
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(@chapter.title)
toc = ""
toc_level = 0
@chapter.headline_index.items.each do |i|
caption = "<li>#{strip_html(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,
'next' => @chapter.next_chapter,
'prev' => @chapter.prev_chapter},
layout_file).result
end
end
@error_messages = error_messages
@warning_messages = warning_messages
@title = strip_html(@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
610
611
612
|
# File 'lib/review/htmlbuilder.rb', line 610
def result_metric(array)
" #{array.join(' ')}"
end
|
#security(lines, caption = nil) ⇒ Object
297
298
299
|
# File 'lib/review/htmlbuilder.rb', line 297
def security(lines, caption = nil)
captionblock("security", lines, caption)
end
|
#shoot(lines, caption = nil) ⇒ Object
313
314
315
|
# File 'lib/review/htmlbuilder.rb', line 313
def shoot(lines, caption = nil)
captionblock("shoot", lines, caption)
end
|
#source(lines, caption = nil, lang = nil) ⇒ Object
439
440
441
442
443
444
445
|
# File 'lib/review/htmlbuilder.rb', line 439
def source(lines, caption = nil, lang = nil)
buf = %Q[<div class="source-code">\n]
buf << (caption)
buf << source_body(caption, lines, lang)
buf << "</div>\n"
buf
end
|
#source_body(id, lines, lang) ⇒ Object
453
454
455
456
457
458
459
460
461
|
# File 'lib/review/htmlbuilder.rb', line 453
def source_body(id, lines, lang)
id ||= ''
buf = %Q[<pre class="source">]
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
lexer = lang || File.extname(id).gsub(/\./, '')
buf << highlight(:body => body, :lexer => lexer, :format => 'html')
buf << "</pre>\n"
buf
end
|
447
448
449
450
451
|
# File 'lib/review/htmlbuilder.rb', line 447
def (caption)
if caption.present?
%Q[<p class="caption">#{caption}</p>\n]
end
end
|
#sup_begin(level, label, caption) ⇒ Object
245
246
247
248
249
|
# File 'lib/review/htmlbuilder.rb', line 245
def sup_begin(level, label, caption)
buf << %Q[<div class="supplement">\n]
buf << headline(level, label, caption)
buf
end
|
#sup_end(level) ⇒ Object
251
252
253
|
# File 'lib/review/htmlbuilder.rb', line 251
def sup_end(level)
"</div>\n"
end
|
#table(lines, id = nil, caption = nil) ⇒ Object
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
685
686
687
688
689
|
# File 'lib/review/htmlbuilder.rb', line 647
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
buf = %Q[<div id="#{normalize_id(id)}" class="table">\n]
else
buf = %Q[<div class="table">\n]
end
begin
buf << (id, caption) unless caption.nil?
rescue KeyError
error "no such table: #{id}"
end
buf << table_begin(rows.first.size)
return if rows.empty?
if sepidx
sepidx.times do
buf << tr(rows.shift.map {|s| th(s) })
end
rows.each do |cols|
buf << tr(cols.map {|s| td(s) })
end
else
rows.each do |cols|
h, *cs = *cols
buf << tr([th(h)] + cs.map {|s| td(s) })
end
end
buf << table_end
buf << %Q[</div>\n]
buf
end
|
#table_begin(ncols) ⇒ Object
699
700
701
|
# File 'lib/review/htmlbuilder.rb', line 699
def table_begin(ncols)
"<table>\n"
end
|
#table_end ⇒ Object
715
716
717
|
# File 'lib/review/htmlbuilder.rb', line 715
def table_end
"</table>\n"
end
|
691
692
693
694
695
696
697
|
# File 'lib/review/htmlbuilder.rb', line 691
def (id, caption)
if get_chap.nil?
%Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{caption}</p>\n]
else
%Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{caption}</p>\n]
end
end
|
#talk(lines) ⇒ Object
572
573
574
575
576
577
578
579
580
581
582
|
# File 'lib/review/htmlbuilder.rb', line 572
def talk(lines)
buf = ""
buf << %Q[<div class="talk">\n]
if @book.config["deprecated-blocklines"].nil?
buf << "#{lines.join("\n")}\n"
else
error "deprecated-blocklines is obsoleted."
end
buf << "</div>\n"
buf
end
|
711
712
713
|
# File 'lib/review/htmlbuilder.rb', line 711
def td(str)
"<td>#{str}</td>"
end
|
#text(str) ⇒ Object
923
924
925
|
# File 'lib/review/htmlbuilder.rb', line 923
def text(str)
str
end
|
707
708
709
|
# File 'lib/review/htmlbuilder.rb', line 707
def th(str)
"<th>#{str}</th>"
end
|
#tip(lines, caption = nil) ⇒ Object
277
278
279
|
# File 'lib/review/htmlbuilder.rb', line 277
def tip(lines, caption = nil)
captionblock("tip", lines, caption)
end
|
703
704
705
|
# File 'lib/review/htmlbuilder.rb', line 703
def tr(rows)
"<tr>#{rows.join}</tr>\n"
end
|
#tsize(str) ⇒ Object
255
256
257
|
# File 'lib/review/htmlbuilder.rb', line 255
def tsize(str)
end
|
332
333
334
|
# File 'lib/review/htmlbuilder.rb', line 332
def ul_begin
"<ul>\n"
end
|
348
349
350
|
# File 'lib/review/htmlbuilder.rb', line 348
def ul_end
"</ul>\n"
end
|
#ul_item(lines) ⇒ Object
336
337
338
|
# File 'lib/review/htmlbuilder.rb', line 336
def ul_item(lines)
"<li>#{lines.map(&:to_s).join}</li>\n"
end
|
#ul_item_begin(lines) ⇒ Object
340
341
342
|
# File 'lib/review/htmlbuilder.rb', line 340
def ul_item_begin(lines)
"<li>#{lines.map(&:to_s).join}"
end
|
#ul_item_end ⇒ Object
344
345
346
|
# File 'lib/review/htmlbuilder.rb', line 344
def ul_item_end
"</li>\n"
end
|
#warn(msg) ⇒ Object
122
123
124
125
126
127
128
129
|
# File 'lib/review/htmlbuilder.rb', line 122
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
154
155
156
157
158
159
160
161
162
|
# File 'lib/review/htmlbuilder.rb', line 154
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
225
226
227
228
229
|
# File 'lib/review/htmlbuilder.rb', line 225
def xcolumn_begin(level, label, caption)
buf << %Q[<div class="xcolumn">\n]
buf << headline(level, label, caption)
buf
end
|
#xcolumn_end(level) ⇒ Object
231
232
233
|
# File 'lib/review/htmlbuilder.rb', line 231
def xcolumn_end(level)
"</div>\n"
end
|
#xmlns_ops_prefix ⇒ Object
114
115
116
117
118
119
120
|
# File 'lib/review/htmlbuilder.rb', line 114
def xmlns_ops_prefix
if @book.config["epubversion"].to_i == 3
"epub"
else
"ops"
end
end
|