softcover 1.7.5 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35f8216b104c6b6341a7ff95524712cc97fdafd2153fff6d6c69bcab3f113a06
4
- data.tar.gz: 691d43d5226885e4796440ec770bd0c19df2466fd180b3194a0de0f971a94c36
3
+ metadata.gz: ac6a3f1ecc0ba2a8ba2dc4dac7b8a480fc451acd10c563b5a5a5a55209c4d6cf
4
+ data.tar.gz: caa2837b7e97298887d0a927c84e6973bd4fe5857f29b2fc80eea0f18533417f
5
5
  SHA512:
6
- metadata.gz: 5a891f8b339375b86a3a4259b7fc9dc07d7f57aa1e2da8d8df3448ad2866a12af4c0ded3720675cbf33dd79121cf33cd4c6e590f096e91015684472a2cb5600c
7
- data.tar.gz: 101c6147113f550d1b56109ec33da95559198f7cd03e14838fd1b0bf44a5a127203d0f4a5e8c95d1960d34454fdcf05a6f1f5bc70298e11097078c1f7be0f23e
6
+ metadata.gz: 31e8000d8dc51018be5e76ecab96fbac5b5373c9d3a9df2a05085844d20da0ae6251dca92c09c3860f35224b9ec903c81a327e8ef78deb1ecebaa81b64049c30
7
+ data.tar.gz: c706ab7791768ea06cd05caa5c80ce34a669015425d35ba63a14df6e05b0c8234cd220c6fcf9c035d1c35d4936449119321db01fbfeeab9c5531bc80265bcd40
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- softcover (1.7.5)
4
+ softcover (1.8.0)
5
5
  activesupport (~> 4.2.3)
6
6
  async_sinatra (~> 1.1.0)
7
7
  coffee-script (>= 2.2.0)
@@ -12,7 +12,7 @@ PATH
12
12
  maruku (~> 0.7.1)
13
13
  msgpack (~> 1.2.0)
14
14
  nokogiri (>= 1.6.0, < 2.0)
15
- polytexnic (~> 1.7.2)
15
+ polytexnic (~> 1.8.0)
16
16
  pygments.rb (~> 2.1)
17
17
  rest-client (>= 1.8.0)
18
18
  ruby-progressbar (~> 1.10)
@@ -30,8 +30,8 @@ GEM
30
30
  minitest (~> 5.1)
31
31
  thread_safe (~> 0.3, >= 0.3.4)
32
32
  tzinfo (~> 1.1)
33
- addressable (2.8.0)
34
- public_suffix (>= 2.0.2, < 5.0)
33
+ addressable (2.8.1)
34
+ public_suffix (>= 2.0.2, < 6.0)
35
35
  async_sinatra (1.1.0)
36
36
  rack (>= 1.4.1)
37
37
  sinatra (>= 1.3.2)
@@ -50,7 +50,7 @@ GEM
50
50
  crack (0.4.5)
51
51
  rexml
52
52
  crass (1.0.6)
53
- curb (1.0.0)
53
+ curb (1.0.1)
54
54
  daemons (1.4.1)
55
55
  diff-lcs (1.5.0)
56
56
  docile (1.4.0)
@@ -61,12 +61,12 @@ GEM
61
61
  ffi (1.15.5)
62
62
  hashdiff (1.0.1)
63
63
  http-accept (1.7.0)
64
- http-cookie (1.0.4)
64
+ http-cookie (1.0.5)
65
65
  domain_name (~> 0.5)
66
66
  i18n (0.9.5)
67
67
  concurrent-ruby (~> 1.0)
68
68
  json (2.3.1)
69
- kramdown (2.3.2)
69
+ kramdown (2.4.0)
70
70
  rexml
71
71
  listen (3.7.1)
72
72
  rb-fsevent (~> 0.10, >= 0.10.3)
@@ -76,14 +76,16 @@ GEM
76
76
  mime-types (3.4.1)
77
77
  mime-types-data (~> 3.2015)
78
78
  mime-types-data (3.2022.0105)
79
- minitest (5.15.0)
79
+ minitest (5.16.3)
80
80
  msgpack (1.2.10)
81
81
  netrc (0.11.0)
82
- nokogiri (1.13.3-x86_64-darwin)
82
+ nokogiri (1.13.10-arm64-darwin)
83
+ racc (~> 1.4)
84
+ nokogiri (1.13.10-x86_64-darwin)
83
85
  racc (~> 1.4)
84
86
  nokogumbo (2.0.5)
85
87
  nokogiri (~> 1.8, >= 1.8.4)
86
- polytexnic (1.7.2)
88
+ polytexnic (1.8.0)
87
89
  json (~> 2.3.0)
88
90
  kramdown (>= 2.0, < 3.0)
89
91
  msgpack (~> 1.2.0)
@@ -92,16 +94,16 @@ GEM
92
94
  pry (0.14.1)
93
95
  coderay (~> 1.1)
94
96
  method_source (~> 1.0)
95
- public_suffix (4.0.6)
96
- pygments.rb (2.3.0)
97
- racc (1.6.0)
97
+ public_suffix (5.0.1)
98
+ pygments.rb (2.3.1)
99
+ racc (1.6.1)
98
100
  rack (1.6.13)
99
101
  rack-protection (1.5.5)
100
102
  rack
101
- rack-test (1.1.0)
102
- rack (>= 1.0, < 3)
103
+ rack-test (2.0.2)
104
+ rack (>= 1.3)
103
105
  rake (13.0.6)
104
- rb-fsevent (0.11.1)
106
+ rb-fsevent (0.11.2)
105
107
  rb-inotify (0.10.1)
106
108
  ffi (~> 1.0)
107
109
  rest-client (2.1.0)
@@ -145,21 +147,23 @@ GEM
145
147
  rack (~> 1.0)
146
148
  thor (1.2.1)
147
149
  thread_safe (0.3.6)
148
- tilt (2.0.10)
149
- tins (1.31.0)
150
+ tilt (2.0.11)
151
+ tins (1.32.1)
150
152
  sync
151
- tzinfo (1.2.9)
153
+ tzinfo (1.2.10)
152
154
  thread_safe (~> 0.1)
153
155
  unf (0.1.4)
154
156
  unf_ext
155
- unf_ext (0.0.8.1)
156
- webmock (3.14.0)
157
+ unf_ext (0.0.8.2)
158
+ webmock (3.18.1)
157
159
  addressable (>= 2.8.0)
158
160
  crack (>= 0.3.2)
159
161
  hashdiff (>= 0.4.0, < 2.0.0)
160
162
 
161
163
  PLATFORMS
164
+ arm64-darwin-21
162
165
  x86_64-darwin-19
166
+ x86_64-darwin-21
163
167
 
164
168
  DEPENDENCIES
165
169
  coveralls
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Softcover
2
2
 
3
- [![CircleCI](https://circleci.com/gh/softcover/softcover.svg?style=shield)](https://circleci.com/gh/softcover/softcover) [![Coverage Status](https://coveralls.io/repos/softcover/softcover/badge.svg)](https://coveralls.io/github/softcover/softcover)
3
+ [![Coverage Status](https://coveralls.io/repos/softcover/softcover/badge.svg)](https://coveralls.io/github/softcover/softcover)
4
4
 
5
5
  Softcover is an ebook typesetting system for technical authors. This is the main gem, `softcover`, which depends on `polytexnic` to convert Markdown or PolyTeX input to HTML and LaTeX, and thence to EPUB, MOBI, and PDF. Authors can use Softcover to publish and optionally sell the resulting ebooks (as well as associated digital goods such as screencasts) on the [Softcover publishing platform](http://www.softcover.io/).
6
6
 
@@ -8,7 +8,6 @@ tmp/
8
8
  generated_polytex/
9
9
 
10
10
  .highlight_cache
11
- .softcover-book
12
11
 
13
12
  # Generated HTML files
14
13
  html/*.html
@@ -40,6 +40,7 @@
40
40
  % American Mathematical Society extensions
41
41
  \usepackage{amsmath}
42
42
  \usepackage{amsfonts}
43
+ \usepackage{amssymb}
43
44
  % 'Verbatim' environment
44
45
  \usepackage{fancyvrb}
45
46
  % Be able to resize text relative to other text
@@ -9,7 +9,6 @@ tmp/
9
9
  generated_polytex/
10
10
 
11
11
  .highlight_cache
12
- .softcover-book
13
12
 
14
13
  # Generated HTML files
15
14
  html/*.html
@@ -8,7 +8,6 @@ tmp/
8
8
  generated_polytex/
9
9
 
10
10
  .highlight_cache
11
- .softcover-book
12
11
 
13
12
  # Generated HTML files
14
13
  html/*.html
@@ -40,6 +40,7 @@
40
40
  % American Mathematical Society extensions
41
41
  \usepackage{amsmath}
42
42
  \usepackage{amsfonts}
43
+ \usepackage{amssymb}
43
44
  % 'Verbatim' environment
44
45
  \usepackage{fancyvrb}
45
46
  % Be able to resize text relative to other text
@@ -9,7 +9,6 @@ tmp/
9
9
  generated_polytex/
10
10
 
11
11
  .highlight_cache
12
- .softcover-book
13
12
 
14
13
  # Generated HTML files
15
14
  html/*.html
@@ -273,6 +273,12 @@ module Softcover
273
273
  end
274
274
  end
275
275
 
276
+ # Escapes spaces in filename directories.
277
+ # E.g., "Mobile Directory" becomes "Mobile\ Directory".
278
+ def escape_spaces(name)
279
+ name.gsub(' ', '\ ')
280
+ end
281
+
276
282
  # Returns HTML for HTML source that includes math.
277
283
  # As a side-effect, html_with_math creates PNGs corresponding to any
278
284
  # math in the given source. The technique involves using PhantomJS to
@@ -285,7 +291,8 @@ module Softcover
285
291
  content = File.read(File.join("html",
286
292
  "#{chapter.slug}.#{html_extension}"))
287
293
  pagejs = "#{File.dirname(__FILE__)}/utils/page.js"
288
- url = "file://#{Dir.pwd}/html/#{chapter.slug}.#{html_extension}"
294
+ dir = escape_spaces(Dir.pwd)
295
+ url = "file://" + dir + "/html/#{chapter.slug}.#{html_extension}"
289
296
  cmd = "#{phantomjs} #{pagejs} #{url}"
290
297
  silence { silence_stream(STDERR) { system cmd } }
291
298
  # Sometimes in tests the phantomjs_source.html file is missing.
data/lib/softcover/cli.rb CHANGED
@@ -99,9 +99,12 @@ module Softcover
99
99
  desc 'server', 'Run local server'
100
100
  method_option :port, type: :numeric, default: 4000, aliases: '-p'
101
101
  method_option :bind, type: :string, default: '0.0.0.0', aliases: '-o'
102
+ method_option :pdf, type: :boolean, default: false
103
+ method_option :overfull, type: :boolean, default: false
102
104
  def server
103
105
  if Softcover::BookManifest::valid_directory?
104
- Softcover::Commands::Server.run options[:port], options[:bind]
106
+ Softcover::Commands::Server.run options[:port], options[:bind],
107
+ options[:pdf], options[:overfull]
105
108
  else
106
109
  puts 'Not in a valid book directory.'
107
110
  exit 1
@@ -22,7 +22,7 @@ module Softcover
22
22
  str += line
23
23
 
24
24
  case line
25
- when %r{\\subsubsection{Exercises}}
25
+ when %r{\\subsection{Exercises}}
26
26
  in_exercise = true
27
27
  when %r{\\end{enumerate}}
28
28
  in_exercise = false
@@ -7,14 +7,14 @@ module Softcover::Commands::Server
7
7
  extend self
8
8
 
9
9
  # Listens for changes to the book's source files.
10
- def listen_for_changes
10
+ def listen_for_changes(is_pdf=false, overfull=false)
11
11
  return if defined?(@no_listener) && @no_listener
12
12
  server_pid = Process.pid
13
13
  filter_regex = /(\.md|\.tex|custom\.sty|custom\.css|Book\.txt|book\.yml)$/
14
14
  @listener = Listen.to('.', only: filter_regex, ignore: /html\//) do |modified|
15
15
  first_modified = modified.try(:first)
16
16
  unless first_modified =~ ignore_regex
17
- rebuild first_modified
17
+ rebuild(is_pdf, modified: first_modified, overfull: overfull)
18
18
  Process.kill("HUP", server_pid)
19
19
  end
20
20
  end
@@ -37,30 +37,42 @@ module Softcover::Commands::Server
37
37
  !Dir.glob(path('chapters/*.md')).empty?
38
38
  end
39
39
 
40
- def rebuild(modified=nil)
40
+ def rebuild(is_pdf, modified: nil, overfull: nil)
41
41
  printf modified ? "=> #{File.basename modified} changed, rebuilding... " :
42
42
  'Building...'
43
43
  t = Time.now
44
- builder = Softcover::Builders::Html.new
45
- builder.build
44
+
45
+ if is_pdf
46
+ if overfull
47
+ options = "--find-overfull"
48
+ else
49
+ options = "--once --nonstop --quiet"
50
+ end
51
+ system "softcover build:pdf #{options}"
52
+ else
53
+ builder = Softcover::Builders::Html.new
54
+ builder.build
55
+ end
46
56
  puts "Done. (#{(Time.now - t).round(2)}s)"
47
57
 
48
58
  rescue Softcover::BookManifest::NotFound => e
49
59
  puts e.message
50
60
  end
51
61
 
52
- def start_server(port, bind)
62
+ def start_server(port, bind, is_pdf)
53
63
  require 'softcover/server/app'
54
- puts "Running Softcover server on http://#{bind}:#{port}"
55
64
  Softcover::App.set :port, port
56
- Softcover::App.set :bind, bind
65
+ unless is_pdf
66
+ puts "Running Softcover server on http://#{bind}:#{port}"
67
+ Softcover::App.set :bind, bind
68
+ end
57
69
  Softcover::App.run!
58
70
  end
59
71
 
60
- def run(port, bind)
61
- rebuild
62
- listen_for_changes
63
- start_server port, bind
72
+ def run(port, bind, is_pdf, overfull)
73
+ rebuild(is_pdf, overfull: overfull)
74
+ listen_for_changes(is_pdf, overfull)
75
+ start_server port, bind, is_pdf
64
76
  end
65
77
  end
66
78
 
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "1.7.5"
2
+ VERSION = "1.8.0"
3
3
  end
data/softcover.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency 'polytexnic', '~> 1.7.2'
21
+ gem.add_dependency 'polytexnic', '~> 1.8.0'
22
22
  gem.add_dependency 'msgpack', '~> 1.2.0'
23
23
  gem.add_dependency 'nokogiri', '>= 1.6.0', '< 2.0'
24
24
  gem.add_dependency 'thor', '>= 0.18.1', '< 2.0'
@@ -13,10 +13,12 @@ describe Softcover::Commands::Server do
13
13
  it '#run' do
14
14
  Softcover::App.should_receive :run!
15
15
 
16
- port = 5000
17
- bind = "localhost"
16
+ port = 5000
17
+ bind = "localhost"
18
+ pdf = false
19
+ overfull = false
18
20
 
19
- subject.run port, bind
21
+ subject.run port, bind, pdf, overfull
20
22
 
21
23
  expect(Softcover::App.port).to eq port
22
24
  expect(Softcover::App.bind).to eq bind
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.7.5
4
+ version: 1.8.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: 2022-03-25 00:00:00.000000000 Z
12
+ date: 2022-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: polytexnic
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.7.2
20
+ version: 1.8.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 1.7.2
27
+ version: 1.8.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: msgpack
30
30
  requirement: !ruby/object:Gem::Requirement