lib/kitabu/exporter/pdf.rb in kitabu-2.1.0 vs lib/kitabu/exporter/pdf.rb in kitabu-3.0.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Kitabu class Exporter class PDF < Base def export apply_footnotes! @@ -7,16 +9,20 @@ spawn_command ["prince", html_for_print.to_s, "-o", print_file.to_s] end def apply_footnotes! html = Footnotes::PDF.process(html_file.read).html - create_html_file(html_for_print, html, 'print') - create_html_file(html_for_pdf, html, 'pdf') + create_html_file(html_for_print, html, "print") + create_html_file(html_for_pdf, html, "pdf") end def create_html_file(target, html, class_name) html.css("html").first.set_attribute "class", class_name - html.css("link[name=stylesheet]").first.set_attribute "href", "styles/#{class_name}.css" + html + .css("link[name=stylesheet]") + .first + .set_attribute "href", "styles/#{class_name}.css" + File.open(target, "w") {|f| f << html.to_html } end def html_for_pdf root_dir.join("output/#{name}.pdf.html")