softcover 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.pull_requests/1386448492 +0 -0
- data/lib/softcover/book_manifest.rb +1 -1
- data/lib/softcover/builders/pdf.rb +16 -14
- data/lib/softcover/sanitizer.rb +3 -2
- data/lib/softcover/template/chapters/a_chapter.md +2 -2
- data/lib/softcover/template/chapters/a_chapter.tex +3 -2
- data/lib/softcover/template/epub/OEBPS/styles/epub.css +1 -1
- data/lib/softcover/template/html/stylesheets/softcover.css +0 -1
- data/lib/softcover/utils.rb +8 -5
- data/lib/softcover/version.rb +1 -1
- data/spec/book_manifest_spec.rb +0 -1
- data/spec/builders/html_spec.rb +3 -3
- data/spec/utils_spec.rb +12 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 642f6e9fa8e34595d1d5811f2d843b072b78db25
|
4
|
+
data.tar.gz: 6d62ef63616c5fc96aaae8510a7460a2ab9f758c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce330e42045af1b357e2816dcacb521905b6b698113eb482e5cbbb81464f258c12e29e605c76e2d0ebf9350aa330968db11522055d8ec30c88a6a1caefb4657f
|
7
|
+
data.tar.gz: dd2401d92cff7c84c7468c0ce7801adc001ede05815dd43fbfc0835572a3b738531a7a7bcefa196cf753a7b64e5408d1584857d6bbc4987163d0434e782e9d92
|
File without changes
|
@@ -246,7 +246,7 @@ class Softcover::BookManifest < OpenStruct
|
|
246
246
|
def source_files
|
247
247
|
self.class.find_book_root!
|
248
248
|
md_tex = /.*(?:\.md|\.tex)/
|
249
|
-
|
249
|
+
book_txt_lines.select { |path| path =~ md_tex }.map(&:strip)
|
250
250
|
end
|
251
251
|
|
252
252
|
def basenames
|
@@ -24,20 +24,6 @@ module Softcover
|
|
24
24
|
if options[:debug]
|
25
25
|
execute "#{xelatex} #{book_filename}"
|
26
26
|
return # only gets called in test env
|
27
|
-
elsif options[:'find-overfull']
|
28
|
-
tmp_name = book_filename.sub('.tex', '.tmp.tex')
|
29
|
-
# The way we do things, code listings show up as "Overfull", but
|
30
|
-
# they're actually fine, so filter them out.
|
31
|
-
filter_out_listings = "grep -v 3.22281pt"
|
32
|
-
# Because each chapter typically lives in a separate file, it's
|
33
|
-
# hard to correlate Overfull line numbers with lines in the source,
|
34
|
-
# so we use grep's -A flag to provide some context instead. Authors
|
35
|
-
# can then use their text editors' search function to find the
|
36
|
-
# corresponding place in the text.
|
37
|
-
show_context = 'grep -A 3 "Overfull \hbox"'
|
38
|
-
cmd = "xelatex #{tmp_name} | #{filter_out_listings} | #{show_context}"
|
39
|
-
silence_stream(STDERR) { execute cmd }
|
40
|
-
return
|
41
27
|
end
|
42
28
|
|
43
29
|
polytex_filenames = manifest.pdf_chapter_filenames << book_filename
|
@@ -56,6 +42,22 @@ module Softcover
|
|
56
42
|
write_pygments_file(:latex)
|
57
43
|
copy_polytexnic_sty
|
58
44
|
|
45
|
+
if options[:'find-overfull']
|
46
|
+
tmp_name = book_filename.sub('.tex', '.tmp.tex')
|
47
|
+
# The way we do things, code listings show up as "Overfull", but
|
48
|
+
# they're actually fine, so filter them out.
|
49
|
+
filter_out_listings = "grep -v 3.22281pt"
|
50
|
+
# Because each chapter typically lives in a separate file, it's
|
51
|
+
# hard to correlate Overfull line numbers with lines in the source,
|
52
|
+
# so we use grep's -A flag to provide some context instead. Authors
|
53
|
+
# can then use their text editors' search function to find the
|
54
|
+
# corresponding place in the text.
|
55
|
+
show_context = 'grep -A 3 "Overfull \\\\\\\\hbox"'
|
56
|
+
cmd = "xelatex #{tmp_name} | #{filter_out_listings} | #{show_context}"
|
57
|
+
silence_stream(STDERR) { execute cmd }
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
59
61
|
tmp_filename = Softcover::Utils.tmpify(manifest, book_filename)
|
60
62
|
build_pdf = "#{xelatex} #{tmp_filename}"
|
61
63
|
# Run the command twice (to guarantee up-to-date cross-references)
|
data/lib/softcover/sanitizer.rb
CHANGED
@@ -12,7 +12,7 @@ module Softcover
|
|
12
12
|
|
13
13
|
sanitize_options = {
|
14
14
|
elements: %w{div span p a ul ol li h1 h2 h3 h4
|
15
|
-
pre em sup table tbody thead tr td img code},
|
15
|
+
pre em sup table tbody thead tr td img code strong},
|
16
16
|
remove_contents: %w{script},
|
17
17
|
attributes: {
|
18
18
|
'div' => %w{id class data-tralics-id data-number data-chapter},
|
@@ -28,7 +28,8 @@ module Softcover
|
|
28
28
|
'h4' => %w{id class},
|
29
29
|
'img' => %w{id class src alt},
|
30
30
|
'em' => %w{id class},
|
31
|
-
'code' => %w{id class}
|
31
|
+
'code' => %w{id class},
|
32
|
+
'strong' => %w{id class}
|
32
33
|
},
|
33
34
|
protocols: {
|
34
35
|
'a' => {'href' => [:relative, 'http', 'https', 'mailto']},
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# A chapter
|
2
2
|
\label{cha:a_chapter}
|
3
3
|
|
4
|
-
This is the first paragraph of the Softcover Markdown template. It shows how to write a document in Markdown, a lightweight markup language, augmented with the [kramdown](http://kramdown.rubyforge.org/) converter and some custom extensions, including support for embedded \PolyTeX, a subset of the powerful \LaTeX\ typesetting system. For more information, see [*The Softcover Book*](http://manual.softcover.io/)
|
4
|
+
This is the first paragraph of the Softcover Markdown template. It shows how to write a document in Markdown, a lightweight markup language, augmented with the [kramdown](http://kramdown.rubyforge.org/) converter and some custom extensions, including support for embedded \PolyTeX, a subset of the powerful \LaTeX\ typesetting system. For more information, see [*The Softcover Book*](http://manual.softcover.io/book). To learn how to easily publish (and optionally sell) documents produced with Softcover, visit [Softcover.io](http://softcover.io/). Softcover is currently in private beta; go to [Softcover.io](http://softcover.io/) to get an invitation.
|
5
5
|
|
6
6
|
This is the *second* paragraph, showing how to emphasize text.[^sample-footnote] You can also make text **bold** or _emphasize a second way_.
|
7
7
|
|
@@ -115,7 +115,7 @@ Commands:
|
|
115
115
|
softcover server # Run local server
|
116
116
|
```
|
117
117
|
|
118
|
-
|
118
|
+
\noindent You can run `softcover help <command>` to get additional help on a given command:
|
119
119
|
|
120
120
|
```console
|
121
121
|
$ softcover help build
|
@@ -1,7 +1,7 @@
|
|
1
1
|
\chapter{A chapter}
|
2
2
|
\label{cha:a_chapter}
|
3
3
|
|
4
|
-
This is the first paragraph of the Softcover template. It shows how to write a document in \PolyTeX, a subset of the \LaTeX\ typesetting language optimized for ebooks. For more information, see \href{http://manual.softcover.org/book}{\emph{The Softcover Book}} and the \href{http://example.com}{\PolyTeX\ source of the book}
|
4
|
+
This is the first paragraph of the Softcover template. It shows how to write a document in \PolyTeX, a subset of the \LaTeX\ typesetting language optimized for ebooks. For more information, see \href{http://manual.softcover.org/book}{\emph{The Softcover Book}} and the \href{http://example.com}{\PolyTeX\ source of the book}. To learn how to easily publish (and optionally sell) documents produced with Softcover, visit \href{http://softcover.io/}{Softcover.io}. Softcover is currently in private beta; go to \href{http://softcover.io/}{Softcover.io} to get an invitation.
|
5
5
|
|
6
6
|
This is the \emph{second} paragraph, showing how to emphasize text.\footnote{This is a footnote. It is numbered automatically.} You can also make text \textbf{bold} or \textit{italicized} (which looks the same as emphasized text).
|
7
7
|
|
@@ -165,7 +165,8 @@ Commands:
|
|
165
165
|
softcover server # Run local server
|
166
166
|
\end{code}
|
167
167
|
|
168
|
-
|
168
|
+
\noindent You can run \kode{softcover help <command>} to get additional help on a given command:
|
169
|
+
|
169
170
|
%= lang:console
|
170
171
|
\begin{code}
|
171
172
|
$ softcoverhelp build
|
data/lib/softcover/utils.rb
CHANGED
@@ -74,22 +74,25 @@ module Softcover::Utils
|
|
74
74
|
"#{manifest.filename}.tex"
|
75
75
|
end
|
76
76
|
|
77
|
-
# Returns the lines of Book.txt as an array.
|
77
|
+
# Returns the lines of Book.txt as an array, removing any commented-out lines.
|
78
78
|
def book_txt_lines
|
79
|
+
comment = /^\s*#.*$/
|
80
|
+
raw_lines.reject { |line| line.match(comment) }
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns all the lines in Book.txt.
|
84
|
+
def raw_lines
|
79
85
|
File.readlines(Softcover::BookManifest::TXT_PATH)
|
80
86
|
end
|
81
87
|
|
82
88
|
# Returns the content for the master LaTeX file.
|
83
89
|
def master_content(manifest)
|
84
|
-
comment = /^\s*#.*$/
|
85
90
|
front_or_mainmatter = /(.*):\s*$/
|
86
91
|
source_file = /(.*)(?:\.md|\.tex)\s*$/
|
87
92
|
|
88
93
|
tex_file = [master_latex_header(manifest)]
|
89
94
|
book_txt_lines.each do |line|
|
90
|
-
if
|
91
|
-
next
|
92
|
-
elsif line.match(source_file)
|
95
|
+
if line.match(source_file)
|
93
96
|
tex_file << "\\include{#{manifest.polytex_dir}/#{$1}}"
|
94
97
|
elsif line.match(front_or_mainmatter) # frontmatter or mainmatter
|
95
98
|
tex_file << "\\#{$1}"
|
data/lib/softcover/version.rb
CHANGED
data/spec/book_manifest_spec.rb
CHANGED
data/spec/builders/html_spec.rb
CHANGED
@@ -139,12 +139,12 @@ describe Softcover::Builders::Html do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
describe "commented-out lines of Book.txt" do
|
142
|
-
let(:lines) { ['
|
142
|
+
let(:lines) { ['foo.md', '# bar.md'] }
|
143
143
|
let(:content) { builder.master_content(builder.manifest) }
|
144
144
|
before { builder.stub(:book_txt_lines).and_return(lines) }
|
145
145
|
it "should be ignored" do
|
146
|
-
expect(content).to include '
|
147
|
-
expect(content).not_to include '
|
146
|
+
expect(content).to include 'generated_polytex/foo'
|
147
|
+
expect(content).not_to include 'generated_polytex/bar'
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
data/spec/utils_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Softcover::Utils do
|
4
|
+
context "book_txt_lines" do
|
5
|
+
before do
|
6
|
+
Softcover::Utils.stub(:raw_lines).and_return(['foo.md', '# bar.tex'])
|
7
|
+
end
|
8
|
+
subject { Softcover::Utils.book_txt_lines }
|
9
|
+
it { should include 'foo.md' }
|
10
|
+
it { should_not include 'bar.tex' }
|
11
|
+
end
|
12
|
+
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: 0.7.
|
4
|
+
version: 0.7.5
|
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: 2013-12-
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: polytexnic
|
@@ -373,6 +373,7 @@ files:
|
|
373
373
|
- .pull_requests/1385862948
|
374
374
|
- .pull_requests/1386099285
|
375
375
|
- .pull_requests/1386115582
|
376
|
+
- .pull_requests/1386448492
|
376
377
|
- .rspec
|
377
378
|
- Gemfile
|
378
379
|
- LICENSE.txt
|
@@ -1007,6 +1008,7 @@ files:
|
|
1007
1008
|
- spec/sanitizer_spec.rb
|
1008
1009
|
- spec/spec_helper.rb
|
1009
1010
|
- spec/support/exist_matcher.rb
|
1011
|
+
- spec/utils_spec.rb
|
1010
1012
|
- spec/webmock_helpers.rb
|
1011
1013
|
- tasks/run_specs.rake
|
1012
1014
|
homepage: http://manual.softcover.io/
|
@@ -1056,4 +1058,5 @@ test_files:
|
|
1056
1058
|
- spec/sanitizer_spec.rb
|
1057
1059
|
- spec/spec_helper.rb
|
1058
1060
|
- spec/support/exist_matcher.rb
|
1061
|
+
- spec/utils_spec.rb
|
1059
1062
|
- spec/webmock_helpers.rb
|