Class: Alf::Doc::ToHtml
- Inherits:
-
Object
- Object
- Alf::Doc::ToHtml
- Defined in:
- lib/alf/doc/to_html.rb
Defined Under Namespace
Classes: HTMLwithAlbino
Instance Method Summary collapse
- #aggregator(op) ⇒ Object
- #operator(op) ⇒ Object
- #page(md) ⇒ Object
- #predicate(op) ⇒ Object
- #to_html(src) ⇒ Object
Instance Method Details
#aggregator(op) ⇒ Object
20 21 22 |
# File 'lib/alf/doc/to_html.rb', line 20 def aggregator(op) to_html(ToMarkdown.new.aggregator(op)) end |
#operator(op) ⇒ Object
16 17 18 |
# File 'lib/alf/doc/to_html.rb', line 16 def operator(op) to_html(ToMarkdown.new.operator(op)) end |
#page(md) ⇒ Object
28 29 30 |
# File 'lib/alf/doc/to_html.rb', line 28 def page(md) to_html(md) end |
#predicate(op) ⇒ Object
24 25 26 |
# File 'lib/alf/doc/to_html.rb', line 24 def predicate(op) to_html(ToMarkdown.new.predicate(op)) end |
#to_html(src) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/alf/doc/to_html.rb', line 32 def to_html(src) src = src.gsub(/([ ]*)```try\n(.*?)\n([ ]*)```/m){|m| spacing = $1 || "" source = $2.strip.gsub(/^#{spacing}/, "") quoted = Base64.encode64(source) source = "```\n#{source}\n```" source = source.gsub(/^/, spacing) %Q{#{source}\n<div class="try-this"><a href="/?src=#{quoted}" target="_blank">Try it!</a></div>} } = {:fenced_code_blocks => true} Redcarpet::Markdown.new(HTMLwithAlbino, ).render(src) end |