lib/softcover/builders/epub.rb in softcover-1.2.15 vs lib/softcover/builders/epub.rb in softcover-1.3.0
- old
+ new
@@ -326,15 +326,15 @@
ex2em_height_scaling = 0.51 # =1ex/1em for math png height
ex2em_valign_scaling = 0.481482 # =1ex/1em for math png vertical-align
ex2pt_scale_factor = 15 # =1ex/1pt scaling for SVG-->PNG conv.
# These are used a three-step process below: Extract, Convert, Replace
# STEP1: Extract information from svg tag.
- svg_height = svg['style'].scan(/height: (.*?);/).flatten.first
+ svg_height = svg['height']
if svg_height
svg_height_in_ex = Float(svg_height.gsub('ex',''))
- png_height = (svg_height_in_ex * ex2em_height_scaling).to_s + 'em'
# MathJax sets SVG height in `ex` units but we want em units for PNG
+ png_height = (svg_height_in_ex * ex2em_height_scaling).to_s + 'em'
end
# Extract vertical-align css proprty for for inline math.
if svg.parent.parent.attr('class') == "inline_math"
vertical_align = svg['style'].scan(/vertical-align: (.*?);/).flatten.first
if vertical_align
@@ -363,11 +363,11 @@
end
end
rm svg_filename
# STEP 3: Replace svg element with an equivalent png.
png = Nokogiri::XML::Node.new('img', source)
- png['src'] = File.join('images', 'texmath', File.basename(png_filename))
- png['alt'] = png_filename.sub('.png', '')
+ png['src'] = File.join('images', 'texmath', File.basename(png_filename))
+ png['alt'] = png_filename.sub('.png', '')
png['style'] = 'height:' + png_height + ';'
if png_valign
png['style'] += ' vertical-align:' + png_valign + ';'
end
svg.replace(png)
\ No newline at end of file