module WhatTheGem::I::Kramdowns

Public Instance Methods

el2md(el) click to toggle source

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

# File lib/whatthegem/i.rb, line 29
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) click to toggle source
# File lib/whatthegem/i.rb, line 24
def elements(source)
  Kramdown::Document.new(source, input: 'GFM').root.children
end