Module: TextTube::InsideBlock
- Extended by:
- Filterable
- Defined in:
- lib/texttube/filters/inside_block.rb
Overview
This finds html tags with “markdown=‘1’” as an attribute, runs markdown over the contents, then removes the markdown attribute, allowing markdown within html blocks
Class Method Summary collapse
Methods included from Filterable
Class Method Details
.run(content, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/texttube/filters/inside_block.rb', line 18 def self.run( content, ={}) ||= {} if [:markdown_parser].nil? require 'rdiscount' markdown_parser=RDiscount end doc = Nokogiri::HTML::fragment(content) (doc/"*[@markdown='1']").each do |ele| ele.inner_html = markdown_parser.new(ele.inner_html).to_html ele.remove_attribute("markdown") end doc.to_s end |