Class: Flannel::HtmlFormatter
- Inherits:
-
Object
- Object
- Flannel::HtmlFormatter
- Includes:
- HtmlTransformable
- Defined in:
- lib/flannel/html_formatter.rb
Overview
HtmlFormatter is responsible for formatting text blocks as html
Instance Method Summary collapse
- #build_html ⇒ Object
- #do(text, style, id = nil) ⇒ Object
-
#initialize ⇒ HtmlFormatter
constructor
A new instance of HtmlFormatter.
Methods included from HtmlTransformable
#build_external_link, #build_wiki_links, #convert_external_links, #create_img, #format_dlist, #format_link, #format_link_display, #format_list, #html_escape, #parse_feed, #permalink, #split_definition, #wiki_link
Methods included from Wrappable
Constructor Details
#initialize ⇒ HtmlFormatter
Returns a new instance of HtmlFormatter.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/flannel/html_formatter.rb', line 9 def initialize @tags ={:preformatted => "pre", :feed => "ul", :list => "ul", :dlist => "dl", :header_one => "h1", #new style :header_two => "h2", :header_three => "h3", :header_four => "h4", :header_five => "h5", :header_six => "h6", :paragraph => "p", :blockquote => "blockquote"} end |
Instance Method Details
#build_html ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/flannel/html_formatter.rb', line 34 def build_html case @style when :preformatted html = html_escape @text when :feed html = parse_feed @text when :image html = create_img @text else html = build_wiki_links @text html = convert_external_links html if @style == :list html = format_list html end if @style == :dlist html = format_dlist html end end wrap(html, @tags[@style], @id) end |
#do(text, style, id = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/flannel/html_formatter.rb', line 24 def do text, style, id=nil @text = text @style = style @id = id html = build_html html.force_encoding("UTF-8") html end |