module IsoDoc::HtmlFunction module Html def postprocess(result, filename, dir) result = from_xhtml(cleanup(to_xhtml(textcleanup(result)))) toHTML(result, filename) @files_to_delete.each { |f| FileUtils.rm_rf f } end def script_cdata(result) result.gsub(%r{]*)>\s*"). gsub(%r{\]\]>\s*}, ""). gsub(%r{]*)>}m, ""). gsub(%r{\s*\]\]>}, "") end def toHTML(result, filename) result = (from_xhtml(html_cleanup(to_xhtml(result)))) #result = populate_template(result, :html) result = from_xhtml(move_images(to_xhtml(result))) result = html5(script_cdata(inject_script(result))) File.open(filename, "w:UTF-8") { |f| f.write(result) } end def html5(doc) doc.sub(%r{]+>}, ""). sub(%r{<\?xml[^>]+>}, "") end def html_cleanup(x) footnote_format(footnote_backlinks(html_toc( term_header((html_footnote_filter(html_preface(htmlstyle(x)))))) )) end def htmlstylesheet @htmlstylesheet.open stylesheet = @htmlstylesheet.read xml = Nokogiri::XML("