Method: IsoDoc::HtmlFunction::Html#htmlstylesheet

Defined in:
lib/isodoc/html_function/postprocess_cover.rb

#htmlstylesheet(file) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/isodoc/html_function/postprocess_cover.rb', line 15

def htmlstylesheet(file)
  return if file.nil?

  file.open if file.is_a?(Tempfile)
  stylesheet = file.read
  xml = Nokogiri::XML("<style/>")
  xml.children.first << Nokogiri::XML::Comment
    .new(xml, "\n#{stylesheet}\n")
  file.close
  file.unlink if file.is_a?(Tempfile)
  xml.root.to_s
end