softcover 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b898b99eecd64b980a244b0e8cb071d62e607beb
4
- data.tar.gz: aba03346eeab27fcf482445621e0b61dc450f97a
3
+ metadata.gz: f27c4e7ed70a567ecdbf1fe2f3006fb443cca2de
4
+ data.tar.gz: b7ae7871dd8d5879b9af113d75655b18ba806028
5
5
  SHA512:
6
- metadata.gz: bc02c7d4e3bd9fc0303d87ba24c5b2dde04358701b04ccb99c0c0e5e714c2b26c3a72bcc1eeb7ac7504fd6cc2a08325797027b3f87812bbba8d92eca10a2bf18
7
- data.tar.gz: 42b19d4cc49c42213cf835be214a55d3262dc18a16597827218528402a0d54b384c55841623e9dc7aa761b434cc221b9df44fbc7e58e22d7d3172cecfc114509
6
+ metadata.gz: 91f2706763c7a616e9c5573f3610ab0863c3f27d76fcc582fdc346fc00af5b1ac8910595689dc7a8485c7ee420ae8451d67bb8f16776fd9422c1365c1f2222a4
7
+ data.tar.gz: 354aa70a652efda59c861b3044266bd2885505af69c2309a35c1fd24d8ca46cbac11b35a027d7a2bf80e8b5131523d00c9cd2b8ab771066d9f1fe3b5333fffc5
@@ -315,32 +315,33 @@ module Softcover
315
315
  first_child.replace(svg) unless svg == first_child
316
316
  output = svg.to_xhtml
317
317
  svg_filename = File.join(texmath_dir, "#{digest(output)}.svg")
318
- svg_filename_abspath = File.join("#{Dir.pwd}", svg_filename)
318
+ svg_abspath = File.join("#{Dir.pwd}", svg_filename)
319
319
  File.write(svg_filename, output)
320
320
  # Convert to PNG named:
321
321
  png_filename = svg_filename.sub('.svg', '.png')
322
- png_filename_abspath = svg_filename_abspath.sub('.svg', '.png')
322
+ png_abspath = svg_abspath.sub('.svg', '.png')
323
323
  pngs << png_filename
324
324
  #
325
325
  # Settings for inline math in ePub / mobi
326
- pt_scale_factor = 16 # scaling factor used for SVG --> PNG conversion
327
- height_scale_factor = 0.50 # 1ex/1em for scaling math PNG's height
328
- valign_scale_factor = 0.45 # 1ex/1em when scaling PNG's vertical-align
329
- # these are used in three-step process below: Extract, Convert, Eeplace
326
+ ex2em_height_scaling = 0.51 # =1ex/1em for math png height
327
+ ex2em_valign_scaling = 0.481482 # =1ex/1em for math png vertical-align
328
+ ex2pt_scale_factor = 15 # =1ex/1pt scaling for SVG-->PNG conv.
329
+ # These are used a three-step process below: Extract, Convert, Replace
330
330
  # STEP1: Extract information from svg tag.
331
331
  svg_height = svg['style'].scan(/height: (.*?);/).flatten.first
332
332
  if svg_height
333
333
  svg_height_in_ex = Float(svg_height.gsub('ex',''))
334
- png_height = (svg_height_in_ex * height_scale_factor).to_s + 'em'
335
- # MathJax sets SVG height in `ex` units but we wan `em` units for PNG
334
+ png_height = (svg_height_in_ex * ex2em_height_scaling).to_s + 'em'
335
+ # MathJax sets SVG height in `ex` units but we want em units for PNG
336
336
  end
337
337
  # Extract vertical-align css proprty for for inline math.
338
338
  if svg.parent.parent.attr('class') == "inline_math"
339
339
  vertical_align = svg['style'].scan(/vertical-align: (.*?);/).flatten.first
340
340
  if vertical_align
341
341
  valign_in_ex = Float(vertical_align.gsub('ex',''))
342
- # png vertical-align in ems is the css equivalent of `depth` in TeX
343
- png_valign = (valign_in_ex * valign_scale_factor).to_s + 'em'
342
+ valign_in_ex += 0.1155 # correction factor for MathJax 1px margin
343
+ # png vertical-align in ems is the css equivalent of depth in TeX
344
+ png_valign = (valign_in_ex * ex2em_valign_scaling).to_s + 'em'
344
345
  else
345
346
  png_valign = "0em"
346
347
  end
@@ -349,12 +350,12 @@ module Softcover
349
350
  end
350
351
  # STEP2: Generate PNG from each SVG (if necessary).
351
352
  unless File.exist?(png_filename)
352
- h = pt_scale_factor * svg_height.to_f # PNG height in pt
353
+ h = ex2pt_scale_factor * svg_height_in_ex # = PNG height in pt
353
354
  unless options[:silent] || options[:quiet]
354
355
  puts "Creating #{png_filename}"
355
356
  end
356
357
  # generate png from the MathJax_SVG using inkscape
357
- cmd = "#{inkscape} -f #{svg_filename_abspath} -e #{png_filename_abspath} -h #{h}pt"
358
+ cmd = "#{inkscape} -f #{svg_abspath} -e #{png_abspath} -h #{h}pt"
358
359
  if options[:silent]
359
360
  silence { silence_stream(STDERR) { system cmd } }
360
361
  else
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "1.2.7"
2
+ VERSION = "1.2.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softcover
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-08 00:00:00.000000000 Z
12
+ date: 2016-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: polytexnic