class Kramdown::Converter::RemoveHtmlTags
This converter modifies the given tree in-place and returns it.
*some elements may be violated)!
Note that the returned element tree may not be fully conformant (i.e. the content models of
contain native kramdown elements.
This converter can be used on parsed HTML documents to get an element tree that will only
Removes all block (and optionally span) level HTML tags from the element tree.
def convert(el)
def convert(el) children = el.children.dup index = 0 while index < children.length if [:xml_pi].include?(children[index].type) || (children[index].type == :html_element && %w[style script].include?(children[index].value)) children[index..index] = [] elsif children[index].type == :html_element && ((@options[:remove_block_html_tags] && children[index].options[:category] == :block) || (@options[:remove_span_html_tags] && children[index].options[:category] == :span)) children[index..index] = children[index].children else convert(children[index]) index += 1 end end el.children = children el end
def initialize(root, options)
def initialize(root, options) super @options[:template] = '' end