lib/softcover/builders/epub.rb in softcover-0.6.3 vs lib/softcover/builders/epub.rb in softcover-0.6.4

- old
+ new

@@ -85,11 +85,11 @@ doc = strip_attributes(Nokogiri::HTML(content)) inner_html = doc.at_css('body').children.to_xhtml if math?(inner_html) html = html_with_math(chapter, images_dir, texmath_dir, pngs, options) - next if html.nil? + html ||= inner_html # handle case of spurious math detection else html = inner_html end f.write(chapter_template("Chapter #{i}", html)) end @@ -122,11 +122,16 @@ # It shouldn't ever happen, but it does no harm to skip it. return nil unless File.exist?('phantomjs_source.html') raw_source = File.read('phantomjs_source.html') source = strip_attributes(Nokogiri::HTML(raw_source)) rm 'phantomjs_source.html' - # Remove the first body div, which is the hidden MathJax SVGs - source.at_css('body div').remove + # Remove the first body div, which is the hidden MathJax SVGs. + if (mathjax_svgs = source.at_css('body div')) + mathjax_svgs.remove + else + # There's not actually any math, so return nil. + return nil + end # Remove all the unneeded raw TeX displays. source.css('script').each(&:remove) # Remove all the MathJax preview spans. source.css('MathJax_Preview').each(&:remove) \ No newline at end of file