softcover 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/softcover/builders/epub.rb +13 -12
- data/lib/softcover/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f27c4e7ed70a567ecdbf1fe2f3006fb443cca2de
|
4
|
+
data.tar.gz: b7ae7871dd8d5879b9af113d75655b18ba806028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
327
|
-
|
328
|
-
|
329
|
-
#
|
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 *
|
335
|
-
|
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
|
-
|
343
|
-
|
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 =
|
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 #{
|
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
|
data/lib/softcover/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: polytexnic
|