Class: Kramdown::Converter::PlainText
- Inherits:
-
Base
- Object
- Base
- Kramdown::Converter::PlainText
- Defined in:
- lib/liquid_markdown/converter/plain_text.rb
Overview
Converts tree to plain text. Removes all formatting and attributes. This converter can be used to generate clean text for use in meta tags, plain text emails, etc.
Instance Method Summary collapse
- #convert(el) ⇒ Object
- #convert_entity(el) ⇒ Object
- #convert_smart_quote(el) ⇒ Object
- #convert_text(el) ⇒ Object
- #convert_type(type, el) ⇒ Object
- #convert_typographic_sym(el) ⇒ Object
-
#initialize(root, options) ⇒ PlainText
constructor
A new instance of PlainText.
Constructor Details
Instance Method Details
#convert(el) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/liquid_markdown/converter/plain_text.rb', line 35 def convert(el) type = el.type category = ::Kramdown::Element.category(el) @plain_text << convert_type(type, el) if TEXT_TYPES.include?(type) @plain_text << "\n" if category == :block el.children.each { |e| convert(e) } @plain_text.strip if type == :root end |
#convert_entity(el) ⇒ Object
55 56 57 |
# File 'lib/liquid_markdown/converter/plain_text.rb', line 55 def convert_entity(el) el.value.char end |
#convert_smart_quote(el) ⇒ Object
59 60 61 |
# File 'lib/liquid_markdown/converter/plain_text.rb', line 59 def convert_smart_quote(el) smart_quote_entity(el).char end |
#convert_text(el) ⇒ Object
51 52 53 |
# File 'lib/liquid_markdown/converter/plain_text.rb', line 51 def convert_text(el) el.value end |
#convert_type(type, el) ⇒ Object
47 48 49 |
# File 'lib/liquid_markdown/converter/plain_text.rb', line 47 def convert_type(type, el) send("convert_#{type}", el) end |