class HikiDoc::HTMLOutput

Public Class Methods

new(suffix = " />") click to toggle source
# File lib/hikidoc.rb, line 549
def initialize(suffix = " />")
  @suffix = suffix
  @f = nil
end

Public Instance Methods

block_plugin(str) click to toggle source
# File lib/hikidoc.rb, line 695
def block_plugin(str)
  @f.puts %Q(<div class="plugin">{{#{escape_html(str)}}}</div>)
end
block_preformatted(str, info) click to toggle source
# File lib/hikidoc.rb, line 670
def block_preformatted(str, info)
  syntax = info ? info.downcase : nil
  if syntax
    begin
      convertor = Syntax::Convertors::HTML.for_syntax(syntax)
      @f.puts convertor.convert(str)
      return
    rescue NameError, RuntimeError
      @f.puts %Q<pre class="prettyprint">#{text(str)}</pre>|
      return
    end
  end
  preformatted(text(str))
end
blockquote_close() click to toggle source
# File lib/hikidoc.rb, line 666
def blockquote_close
  @f.puts "</blockquote>"
end
blockquote_open() click to toggle source
# File lib/hikidoc.rb, line 662
def blockquote_open
  @f.print "<blockquote>"
end
container(_for=nil) click to toggle source
# File lib/hikidoc.rb, line 562
def container(_for=nil)
  case _for
  when :paragraph
    []
  else
    ""
  end
end
del(item) click to toggle source
# File lib/hikidoc.rb, line 725
def del(item)
  "<del>#{item}</del>"
end
dlist_close() click to toggle source
# File lib/hikidoc.rb, line 614
def dlist_close
  @f.puts "</dl>"
end
dlist_item(dt, dd) click to toggle source
# File lib/hikidoc.rb, line 618
def dlist_item(dt, dd)
  case
  when dd.empty?
    @f.puts "<dt>#{dt}</dt>"
  when dt.empty?
    @f.puts "<dd>#{dd}</dd>"
  else
    @f.puts "<dt>#{dt}</dt>"
    @f.puts "<dd>#{dd}</dd>"
  end
end
dlist_open() click to toggle source
# File lib/hikidoc.rb, line 610
def dlist_open
  @f.puts "<dl>"
end
em(item) click to toggle source
# File lib/hikidoc.rb, line 721
def em(item)
  "<em>#{item}</em>"
end
escape_html(text) click to toggle source
# File lib/hikidoc.rb, line 749
def escape_html(text)
  text.gsub(/&/, "&amp;").gsub(/</, "&lt;").gsub(/>/, "&gt;")
end
escape_html_param(str) click to toggle source

Utilities

# File lib/hikidoc.rb, line 745
def escape_html_param(str)
  escape_quote(escape_html(str))
end
escape_quote(text) click to toggle source
# File lib/hikidoc.rb, line 757
def escape_quote(text)
  text.gsub(/"/, "&quot;")
end
finish() click to toggle source
# File lib/hikidoc.rb, line 558
def finish
  @f.string
end
headline(level, title) click to toggle source

Procedures

# File lib/hikidoc.rb, line 575
def headline(level, title)
  @f.puts "<h#{level}>#{title}</h#{level}>"
end
hrule() click to toggle source
# File lib/hikidoc.rb, line 579
def hrule
  @f.puts "<hr#{@suffix}"
end
inline_plugin(src) click to toggle source
# File lib/hikidoc.rb, line 737
def inline_plugin(src)
  %Q(<span class="plugin">{{#{escape_html(src)}}}</span>)
end
list_begin() click to toggle source
# File lib/hikidoc.rb, line 583
def list_begin
end
list_close(type) click to toggle source
# File lib/hikidoc.rb, line 594
def list_close(type)
  @f.print "</#{type}>"
end
list_end() click to toggle source
# File lib/hikidoc.rb, line 586
def list_end
  @f.puts
end
list_open(type) click to toggle source
# File lib/hikidoc.rb, line 590
def list_open(type)
  @f.puts "<#{type}>"
end
listitem(item) click to toggle source
# File lib/hikidoc.rb, line 606
def listitem(item)
  @f.print item
end
listitem_close() click to toggle source
# File lib/hikidoc.rb, line 602
def listitem_close
  @f.puts "</li>"
end
listitem_open() click to toggle source
# File lib/hikidoc.rb, line 598
def listitem_open
  @f.print "<li>"
end
paragraph(lines) click to toggle source
# File lib/hikidoc.rb, line 691
def paragraph(lines)
  @f.puts "<p>#{lines.join("\n")}</p>"
end
preformatted(str) click to toggle source
# File lib/hikidoc.rb, line 685
def preformatted(str)
  @f.print "<pre>"
  @f.print str
  @f.puts "</pre>"
end
reset() click to toggle source
# File lib/hikidoc.rb, line 554
def reset
  @f = StringIO.new
end
strong(item) click to toggle source
# File lib/hikidoc.rb, line 717
def strong(item)
  "<strong>#{item}</strong>"
end
table_close() click to toggle source
# File lib/hikidoc.rb, line 634
def table_close
  @f.puts "</table>"
end
table_data(item, rs, cs) click to toggle source
# File lib/hikidoc.rb, line 650
def table_data(item, rs, cs)
  @f.print "<td#{tdattr(rs, cs)}>#{item}</td>"
end
table_head(item, rs, cs) click to toggle source
# File lib/hikidoc.rb, line 646
def table_head(item, rs, cs)
  @f.print "<th#{tdattr(rs, cs)}>#{item}</th>"
end
table_open() click to toggle source
# File lib/hikidoc.rb, line 630
def table_open
  @f.puts %Q(<table border="1">)
end
table_record_close() click to toggle source
# File lib/hikidoc.rb, line 642
def table_record_close
  @f.puts "</tr>"
end
table_record_open() click to toggle source
# File lib/hikidoc.rb, line 638
def table_record_open
  @f.print "<tr>"
end
text(str) click to toggle source
# File lib/hikidoc.rb, line 733
def text(str)
  escape_html(str)
end
tt(item) click to toggle source
# File lib/hikidoc.rb, line 729
def tt(item)
  "<tt>#{item}</tt>"
end
unescape_html(text) click to toggle source
# File lib/hikidoc.rb, line 753
def unescape_html(text)
  text.gsub(/&gt;/, ">").gsub(/&lt;/, "<").gsub(/&amp;/, "&")
end
wiki_name(name) click to toggle source
# File lib/hikidoc.rb, line 707
def wiki_name(name)
  hyperlink(name, text(name))
end

Private Instance Methods

tdattr(rs, cs) click to toggle source
# File lib/hikidoc.rb, line 654
def tdattr(rs, cs)
  buf = ""
  buf << %Q( rowspan="#{rs}") if rs
  buf << %Q( colspan="#{cs}") if cs
  buf
end