def substitute_markdown_inside_raw_html
self.each_element(:raw_html) do |e|
doc = e.instance_variable_get :@parsed_html
if doc
block_tags = ['div']
XPath.match(doc, "//*[attribute::markdown]" ).each do |e|
how = e.attributes['markdown']
parse_blocks = (how == 'block') || block_tags.include?(e.name)
XPath.match(e, "//text()" ).each { |original_text|
s = original_text.value.strip
if s.size > 0
el = md_el(:dummy,
parse_blocks ? parse_text_as_markdown(s) :
parse_lines_as_span([s]) )
p = original_text.parent
el.children_to_html.each do |x|
p.insert_before(original_text, x)
end
p.delete(original_text)
end
}
e.delete_attribute 'markdown'
end
end
end
end