Class: Kramdown::Converter::TrutyHtml

Inherits:
Html
  • Object
show all
Defined in:
lib/jekyll-truty/kramdown.rb

Instance Method Summary collapse

Instance Method Details

#convert_text(el, indent) ⇒ Object



34
35
36
37
38
# File 'lib/jekyll-truty/kramdown.rb', line 34

def convert_text(el, indent)
  node = Nokogiri::HTML.fragment(el.value)
  traverse_html(node, @options[:truty_lang])
  node.to_html(:indent => 0)
end

#traverse_html(node, lang = :english) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/jekyll-truty/kramdown.rb', line 40

def traverse_html(node, lang = :english)
  node.children.each do |child|
    if child.text? && child.text.strip.length > 0 then
      child.content = Truty.convert(child.inner_text, lang)
    else
      traverse_html(child)
    end
  end
end