Method: IsoDoc::HeadlessHtmlConvert#strip_head

Defined in:
lib/isodoc/headlesshtml_convert.rb

#strip_head(input, output) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/isodoc/headlesshtml_convert.rb', line 36

def strip_head(input, output)
  file = File.read(input, encoding: "utf-8")
  doc = Nokogiri::XML(file)
  doc.xpath("//head").each(&:remove)
  doc.xpath("//html").each { |x| x.name = "div" }
  body = doc.at("//body")
  body.replace(body.children)
  File.open(output, "w") { |f| f.write(doc.to_xml) }
end