Class: Kramdown::Converter::RemoveHtmlTags

### Home Classes Methods

### In Files

- lib/kramdown/converter/remove_html_tags.rb

### Parent

Kramdown::Converter::Base

### Methods

- ::new
- #convert

### Class/Module Index

Quicksearch

- Kramdown
- Kramdown::Converter
- Kramdown::Converter::Base
- Kramdown::Converter::Html
- Kramdown::Converter::Kramdown
- Kramdown::Converter::Latex
- Kramdown::Converter::MathEngine
- Kramdown::Converter::MathEngine::Itex2MML
- Kramdown::Converter::MathEngine::Mathjax
- Kramdown::Converter::MathEngine::MathjaxNode
- Kramdown::Converter::MathEngine::Ritex
- Kramdown::Converter::RemoveHtmlTags
- Kramdown::Converter::SyntaxHighlighter
- Kramdown::Converter::SyntaxHighlighter::Coderay
- Kramdown::Converter::SyntaxHighlighter::Minted
- Kramdown::Converter::SyntaxHighlighter::Rouge
- Kramdown::Converter::Toc
- Kramdown::Document
- Kramdown::Element
- Kramdown::Error
- Kramdown::Options
- Kramdown::Options::Boolean
- Kramdown::Parser
- Kramdown::Parser::Base
- Kramdown::Parser::GFM
- Kramdown::Parser::Html
- Kramdown::Parser::Html::Constants
- Kramdown::Parser::Html::ElementConverter
- Kramdown::Parser::Html::Parser
- Kramdown::Parser::Kramdown
- Kramdown::Parser::Markdown
- Kramdown::Utils
- Kramdown::Utils::Configurable
- Kramdown::Utils::Entities
- Kramdown::Utils::Entities::Entity
- Kramdown::Utils::Html
- Kramdown::Utils::OrderedHash
- Kramdown::Utils::StringScanner
- Kramdown::Utils::Unidecoder

No matching classes.

# Kramdown::Converter::RemoveHtmlTags

Removes all block (and optionally span) level HTML tags from the element tree.

This converter can be used on parsed HTML documents to get an element tree that will only contain native kramdown elements.

Note that the returned element tree may not be fully conformant (i.e. the content models of *some elements may be violated)!

This converter modifies the given tree in-place and returns it.

### Public Class Methods

new(root, options) click to toggle source

    # File lib/kramdown/converter/remove_html_tags.rb, line 26
    def initialize(root, options)
      super
      @options[:template] = ''
    end

### Public Instance Methods

convert(el) click to toggle source

    # File lib/kramdown/converter/remove_html_tags.rb, line 31
    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 && ]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

[Validate]

Generated with the Darkfish Rdoc Generator 2.