softcover 1.5.11 → 1.6.0
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 +4 -4
- data/.circleci/config.yml +1 -3
- data/.travis.yml +2 -3
- data/Gemfile.lock +2 -2
- data/lib/softcover/builders/epub.rb +19 -14
- data/lib/softcover/builders/mobi.rb +3 -11
- data/lib/softcover/cli.rb +0 -3
- data/lib/softcover/commands/check.rb +0 -6
- data/lib/softcover/utils.rb +1 -1
- data/lib/softcover/version.rb +1 -1
- data/spec/builders/mobi_spec.rb +0 -18
- data/spec/cli_spec.rb +0 -2
- data/spec/commands/check_spec.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 886ab5a917abf3257be857060db1093474d3c7f44f8beecc1efbf06aed972862
|
4
|
+
data.tar.gz: aff32e009c3e4ca5098394186602116b6c6fc63c87cadd73c9ab5bd96f2cae95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdce663475b349497cdb1aa53f472d26ccf8f9043fcdde5590ff46ea73c33692dd54b766810e3c31b1386876f2f71a1fd2e445a8063d0bd403fb1105955b5c9a
|
7
|
+
data.tar.gz: 20c08b57bb53e0e0189096b60f8fe33a665129b4ea7980d51d899c184cead1ec7b262f9044bdd8ac7989e5ac7ec90cbe4c3c24476f94028c9936b244ebda7c1f
|
data/.circleci/config.yml
CHANGED
@@ -20,10 +20,8 @@ jobs:
|
|
20
20
|
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh
|
21
21
|
echo 'export PATH=$PATH:`echo ~`' >> $BASH_ENV
|
22
22
|
curl -O -L https://github.com/IDPF/epubcheck/releases/download/v4.0.2/epubcheck-4.0.2.zip && unzip epubcheck-4.0.2.zip -d ~
|
23
|
-
curl -o ~/kindlegen http://softcover-binaries.s3.amazonaws.com/kindlegen && chmod +x ~/kindlegen
|
24
|
-
wget https://softcover-static.s3.amazonaws.com/Bodoni%2072%20Smallcaps%20Book.ttf && sudo cp 'Bodoni 72 Smallcaps Book.ttf' /usr/share/fonts/truetype/bodoni-classic
|
25
23
|
sudo fc-cache -fsv
|
26
|
-
# gem i softcover && softcover check # NOTE: enable to troubleshoot tex, gs, calibre, epubcheck,
|
24
|
+
# gem i softcover && softcover check # NOTE: enable to troubleshoot tex, gs, calibre, epubcheck, issus
|
27
25
|
- ruby/bundle-install
|
28
26
|
- run:
|
29
27
|
name: specs
|
data/.travis.yml
CHANGED
@@ -12,9 +12,8 @@ before_install:
|
|
12
12
|
- sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh
|
13
13
|
- export PATH=$PATH:`echo ~`
|
14
14
|
- curl -O -L https://github.com/IDPF/epubcheck/releases/download/v4.0.2/epubcheck-4.0.2.zip && unzip epubcheck-4.0.2.zip -d ~
|
15
|
-
- curl -o ~/kindlegen http://softcover-binaries.s3.amazonaws.com/kindlegen && chmod +x ~/kindlegen
|
16
15
|
- wget https://softcover-static.s3.amazonaws.com/Bodoni%2072%20Smallcaps%20Book.ttf && sudo cp 'Bodoni 72 Smallcaps Book.ttf' /usr/share/fonts/truetype/bodoni-classic
|
17
16
|
- sudo fc-cache -fsv
|
18
|
-
# - gem i softcover && softcover check # NOTE: enable to troubleshoot tex, gs, calibre, epubcheck,
|
17
|
+
# - gem i softcover && softcover check # NOTE: enable to troubleshoot tex, gs, calibre, epubcheck, issus
|
19
18
|
|
20
|
-
script: "bundle exec rspec -f d"
|
19
|
+
script: "bundle exec rspec -f d"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
softcover (1.
|
4
|
+
softcover (1.6.0)
|
5
5
|
activesupport (~> 4.2.3)
|
6
6
|
async_sinatra (~> 1.1.0)
|
7
7
|
coffee-script (>= 2.2.0)
|
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
msgpack (1.2.10)
|
83
83
|
multi_json (1.14.1)
|
84
84
|
netrc (0.11.0)
|
85
|
-
nokogiri (1.10.
|
85
|
+
nokogiri (1.10.9)
|
86
86
|
mini_portile2 (~> 2.4.0)
|
87
87
|
nokogumbo (1.5.0)
|
88
88
|
nokogiri
|
@@ -229,8 +229,9 @@ module Softcover
|
|
229
229
|
texmath_dir = File.join(images_dir, 'texmath')
|
230
230
|
mkdir images_dir
|
231
231
|
mkdir texmath_dir
|
232
|
-
|
233
|
-
|
232
|
+
if cover?(options)
|
233
|
+
File.write(path("epub/OEBPS/#{cover_filename}"), cover_page)
|
234
|
+
end
|
234
235
|
|
235
236
|
pngs = []
|
236
237
|
chapters.each_with_index do |chapter, i|
|
@@ -314,7 +315,7 @@ module Softcover
|
|
314
315
|
# Workaround for bug in Inkscape 0.91 on MacOS X:
|
315
316
|
# extract height/width from svg attributes and move them to style attr
|
316
317
|
svg_height = svg['height'] # in ex
|
317
|
-
svg_width
|
318
|
+
svg_width = svg['width'] # in ex
|
318
319
|
svg['style'] += ' height:'+svg_height+';' + ' width:'+svg_width+';'
|
319
320
|
svg.remove_attribute('height')
|
320
321
|
svg.remove_attribute('width')
|
@@ -323,25 +324,26 @@ module Softcover
|
|
323
324
|
first_child.replace(svg) unless svg == first_child
|
324
325
|
output = svg.to_xhtml
|
325
326
|
svg_filename = File.join(texmath_dir, "#{digest(output)}.svg")
|
326
|
-
svg_abspath
|
327
|
+
svg_abspath = File.join("#{Dir.pwd}", svg_filename)
|
327
328
|
File.write(svg_filename, output)
|
328
329
|
# Convert to PNG named:
|
329
330
|
png_filename = svg_filename.sub('.svg', '.png')
|
330
|
-
png_abspath
|
331
|
+
png_abspath = svg_abspath.sub('.svg', '.png')
|
331
332
|
pngs << png_filename
|
332
333
|
#
|
333
334
|
# Settings for texmath images in ePub / mobi
|
334
335
|
ex2em_height_scaling = 0.51 # =1ex/1em for math png height
|
335
336
|
ex2em_valign_scaling = 0.481482 # =1ex/1em for math png vertical-align
|
336
|
-
|
337
|
+
ex2px_scale_factor = 20 # =1ex/1px scaling for SVG-->PNG conv.
|
337
338
|
# These are used a three-step process below: Compute, Convert, Replace
|
338
|
-
# STEP1: compute height and vertical-align in `
|
339
|
+
# STEP1: compute height and vertical-align in `ex` units
|
339
340
|
svg_height_in_ex = Float(svg_height.gsub('ex',''))
|
340
341
|
# MathJax sets SVG height in `ex` units but we want `em` units for PNG
|
341
342
|
png_height = (svg_height_in_ex * ex2em_height_scaling).to_s + 'em'
|
342
343
|
# Extract vertical-align css proprty for inline math equations:
|
343
344
|
if svg.parent.parent.attr('class') == "inline_math"
|
344
|
-
vertical_align = svg['style'].scan(/vertical-align: (.*?);/)
|
345
|
+
vertical_align = svg['style'].scan(/vertical-align: (.*?);/)
|
346
|
+
vertical_align = vertical_align.flatten.first
|
345
347
|
if vertical_align
|
346
348
|
valign_in_ex = Float(vertical_align.gsub('ex',''))
|
347
349
|
png_valign = (valign_in_ex * ex2em_valign_scaling).to_s + 'em'
|
@@ -353,24 +355,27 @@ module Softcover
|
|
353
355
|
end
|
354
356
|
# STEP2: Generate PNG from each SVG (unless PNG exists already).
|
355
357
|
unless File.exist?(png_filename)
|
356
|
-
h = ex2pt_scale_factor * svg_height_in_ex # = PNG height in pt
|
357
358
|
unless options[:silent] || options[:quiet]
|
358
359
|
puts "Creating #{png_filename}"
|
359
360
|
end
|
360
|
-
#
|
361
|
-
|
361
|
+
# Generate png from the MathJax_SVG using Inkscape
|
362
|
+
# Use the -d option to get a sensible size:
|
363
|
+
# Resolution for bitmaps and rasterized filters
|
364
|
+
cmd = "#{inkscape} #{svg_abspath} -o #{png_abspath} -d 2"
|
362
365
|
if options[:silent]
|
363
366
|
silence { silence_stream(STDERR) { system cmd } }
|
364
367
|
else
|
368
|
+
puts cmd
|
365
369
|
silence_stream(STDERR) { system cmd }
|
366
370
|
end
|
367
371
|
end
|
368
372
|
rm svg_filename
|
369
373
|
# STEP 3: Replace svg element with an equivalent png.
|
370
374
|
png = Nokogiri::XML::Node.new('img', source)
|
371
|
-
png['src']
|
372
|
-
|
373
|
-
png['
|
375
|
+
png['src'] = File.join('images', 'texmath',
|
376
|
+
File.basename(png_filename))
|
377
|
+
png['alt'] = png_filename.sub('.png', '')
|
378
|
+
png['style'] = 'height:' + png_height + ';'
|
374
379
|
if png_valign
|
375
380
|
png['style'] += ' vertical-align:' + png_valign + ';'
|
376
381
|
end
|
@@ -24,12 +24,8 @@ module Softcover
|
|
24
24
|
# Returns the command for making a MOBI, based on the options.
|
25
25
|
def mobi_command(filename, options={})
|
26
26
|
silent = options[:silent] || Softcover.test?
|
27
|
-
|
28
|
-
|
29
|
-
else
|
30
|
-
cmd = "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.mobi" +
|
31
|
-
" #{calibre_options}"
|
32
|
-
end
|
27
|
+
cmd = "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.mobi" +
|
28
|
+
" #{calibre_options}"
|
33
29
|
puts cmd unless (options[:quiet] || silent)
|
34
30
|
cmd
|
35
31
|
end
|
@@ -57,10 +53,6 @@ module Softcover
|
|
57
53
|
end
|
58
54
|
opts.join(" ")
|
59
55
|
end
|
60
|
-
|
61
|
-
def kindlegen
|
62
|
-
@kindlegen ||= executable(dependency_filename(:kindlegen))
|
63
|
-
end
|
64
56
|
end
|
65
57
|
end
|
66
|
-
end
|
58
|
+
end
|
data/lib/softcover/cli.rb
CHANGED
@@ -45,9 +45,6 @@ module Softcover
|
|
45
45
|
desc: "Run PDF generator in nonstopmode",
|
46
46
|
type: :boolean
|
47
47
|
elsif format == 'mobi'
|
48
|
-
method_option :kindlegen, aliases: '-k',
|
49
|
-
desc: "Use KindleGen to build the MOBI",
|
50
|
-
type: :boolean
|
51
48
|
method_option :amazon, aliases: '-a',
|
52
49
|
desc: "Build for Amazon KDP", type: :boolean
|
53
50
|
end
|
@@ -40,7 +40,6 @@ module Softcover
|
|
40
40
|
[:phantomjs, 'PhantomJS'],
|
41
41
|
[:inkscape, 'Inkscape'],
|
42
42
|
[:calibre, 'Calibre'],
|
43
|
-
[:kindlegen, 'KindleGen'],
|
44
43
|
[:java, 'Java'],
|
45
44
|
[:zip, 'zip'],
|
46
45
|
[:epubcheck, 'EpubCheck'],
|
@@ -71,11 +70,6 @@ module Softcover
|
|
71
70
|
message = "PhantomJS (https://phantomjs.org/download.html)\n"
|
72
71
|
message += " ∟ Put bin/phantomjs version 2 somewhere on your path,"
|
73
72
|
message += " e.g., in /usr/local/bin"
|
74
|
-
when :kindlegen
|
75
|
-
url = 'https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211'
|
76
|
-
message = "KindleGen (#{url})\n"
|
77
|
-
message += " ∟ Put the kindlegen executable on your path,"
|
78
|
-
message += " e.g., in /usr/local/bin"
|
79
73
|
when :calibre
|
80
74
|
url = 'https://calibre-ebook.com/'
|
81
75
|
message = "Calibre (#{url})\n"
|
data/lib/softcover/utils.rb
CHANGED
@@ -263,7 +263,7 @@ module Softcover::Utils
|
|
263
263
|
version_4 = path('epubcheck-4.0.2/epubcheck.jar')
|
264
264
|
first_path(version_4) || get_filename(:'epubcheck') || ""
|
265
265
|
when :inkscape
|
266
|
-
default = '/Applications/Inkscape.app/Contents/
|
266
|
+
default = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
|
267
267
|
filename_or_default(:inkscape, default)
|
268
268
|
when :phantomjs
|
269
269
|
phantomjs = get_filename(label)
|
data/lib/softcover/version.rb
CHANGED
data/spec/builders/mobi_spec.rb
CHANGED
@@ -37,24 +37,6 @@ describe Softcover::Builders::Mobi do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
context "kindlegen" do
|
41
|
-
let(:command) do
|
42
|
-
@builder.mobi_command(@builder.mobi_filename, kindlegen: true)
|
43
|
-
end
|
44
|
-
it "should use Amazon.com's kindlegen" do
|
45
|
-
expect(command).to include 'kindlegen'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "amazon" do
|
50
|
-
let(:command) do
|
51
|
-
@builder.mobi_command(@builder.mobi_filename, amazon: true)
|
52
|
-
end
|
53
|
-
it "should use Amazon.com's kindlegen" do
|
54
|
-
expect(command).to include 'kindlegen'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
40
|
context "preview" do
|
59
41
|
let(:filename) do
|
60
42
|
@builder.mobi_filename(preview: true)
|
data/spec/cli_spec.rb
CHANGED
@@ -43,7 +43,6 @@ describe Softcover::CLI do
|
|
43
43
|
subject { `softcover help build:mobi` }
|
44
44
|
it { should include '-q, [--quiet]' }
|
45
45
|
it { should include '-s, [--silent]' }
|
46
|
-
it { should include '-k, [--kindlegen]' }
|
47
46
|
it { should include '-a, [--amazon]' }
|
48
47
|
end
|
49
48
|
|
@@ -139,7 +138,6 @@ describe Softcover::CLI do
|
|
139
138
|
context "command-line options" do
|
140
139
|
subject(:options) { `softcover help build:mobi` }
|
141
140
|
it { should_not include 'calibre' }
|
142
|
-
it { should include 'kindlegen' }
|
143
141
|
end
|
144
142
|
end
|
145
143
|
end
|
data/spec/commands/check_spec.rb
CHANGED
@@ -35,7 +35,6 @@ describe Softcover::Commands::Check do
|
|
35
35
|
it { should match /Checking for PhantomJS.*Missing/ }
|
36
36
|
it { should match /Checking for Inkscape.*Missing/ }
|
37
37
|
it { should match /Checking for Calibre.*Missing/ }
|
38
|
-
it { should match /Checking for KindleGen.*Missing/ }
|
39
38
|
it { should match /Checking for Java.*Missing/ }
|
40
39
|
it { should match /Checking for EpubCheck.*Missing/ }
|
41
40
|
it { should match /Checking for ImageMagick.*Missing/ }
|
@@ -46,7 +45,6 @@ describe Softcover::Commands::Check do
|
|
46
45
|
it { should match /PhantomJS/ }
|
47
46
|
it { should match /Inkscape/ }
|
48
47
|
it { should match /Calibre/ }
|
49
|
-
it { should match /KindleGen/ }
|
50
48
|
it { should match /Java/ }
|
51
49
|
it { should match /EpubCheck/ }
|
52
50
|
it { should match /ImageMagick/ }
|
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.
|
4
|
+
version: 1.6.0
|
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: 2020-
|
12
|
+
date: 2020-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: polytexnic
|