class Roadie::Document

def serialize_document(dom)

def serialize_document(dom)
  # #dup is called since it fixed a few segfaults in certain versions of Nokogiri
  save_options = Nokogiri::XML::Node::SaveOptions
  format = {
    html: save_options::AS_HTML,
    xhtml: save_options::AS_XHTML,
  }.fetch(mode)
  dom.dup.to_html(
    save_with: (
      save_options::NO_DECLARATION |
      save_options::NO_EMPTY_TAGS |
      format
    ),
  )
end