Method: Kramdown::Parser::Base#add_text
- Defined in:
- lib/kramdown/parser/base.rb
#add_text(text, tree = @tree, type = @text_type) ⇒ Object
This helper method adds the given text either to the last element in the tree if it is a type element or creates a new text element with the given type.
103 104 105 106 107 108 109 110 111 |
# File 'lib/kramdown/parser/base.rb', line 103 def add_text(text, tree = @tree, type = @text_type) last = tree.children.last if last && last.type == type last.value << text elsif !text.empty? location = (last && last.[:location] || tree.[:location]) tree.children << Element.new(type, text, nil, location: location) end end |