Module: WhatTheGem::I::Kramdowns

Extended by:
Kramdowns
Included in:
Kramdowns
Defined in:
lib/whatthegem/i.rb

Instance Method Summary collapse

Instance Method Details

#el2md(el) ⇒ Object

Somehow there is no saner methods for converting parsed element back to source :shrug:



30
31
32
33
34
# File 'lib/whatthegem/i.rb', line 30

def el2md(el)
  el.options[:encoding] = 'UTF-8'
  el.attr.replace({}) # don't render header anchors
  Kramdown::Converter::Kramdown.convert(el, line_width: 1000).first
end

#elements(source) ⇒ Object



25
26
27
# File 'lib/whatthegem/i.rb', line 25

def elements(source)
  Kramdown::Document.new(source, input: 'GFM').root.children
end