softcover 0.5.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 241551e9906a00f2eb0a5d8ce1de0c08609ddb30
4
- data.tar.gz: 4f4e7c76d2095f5901a453dfabe386305c8b4ade
3
+ metadata.gz: 5cafb54a38347e1a39e36d6d4bcca3aa533d7eb2
4
+ data.tar.gz: b1b6d089e5c1cdf27bdd8c7617d32261c37b5e33
5
5
  SHA512:
6
- metadata.gz: 8cbcbc5414d6e04a168c14b15d505e3ecfda89f6ade8ef241a036f4d92d1682aa181e71d2349ccfcf2e0d00a6a0a49469700f9d2c059feb2db39fe5987419f34
7
- data.tar.gz: 6de7dd3b4b929147c8d2aa84e3fe04244ddf965d9daa22abb334fde33288f58464f84d1918c99afa89016ad3a244dae2cb90bcbbad67e4d0e1956b6aff36d727
6
+ metadata.gz: 4e8a8c0f01b38a3cd2d9278b54c75c4456f969739ce72fd348d767a95b3fa603df147c247d4882ff716811fdb63673062fdec566a8b9e7008a3670659f0b8589
7
+ data.tar.gz: 019ce8093c7f097e387a428944636b1877178cf69240779bfa077b2f2064e12f06c4b09272f61fc7a36b9a2173940d1be24097be64f94e22a8e083bd2a267d39
data/lib/softcover/cli.rb CHANGED
@@ -163,11 +163,11 @@ module Softcover
163
163
  # ===============================================
164
164
 
165
165
  desc "new <name>", "Generate new book directory structure."
166
- method_option :markdown,
166
+ method_option :polytex,
167
167
  :type => :boolean,
168
168
  :default => false,
169
- :aliases => "-m",
170
- :desc => "Generate a Markdown book."
169
+ :aliases => "-p",
170
+ :desc => "Generate a PolyTeX book."
171
171
  method_option :simple,
172
172
  :type => :boolean,
173
173
  :default => false,
@@ -8,7 +8,7 @@ module Softcover
8
8
  # Generates the default book file tree.
9
9
  def generate_file_tree(name, options = {})
10
10
  @name = name
11
- @markdown = options[:markdown]
11
+ @markdown = !options[:polytex]
12
12
  @simple = options[:simple]
13
13
 
14
14
  thor = Thor::Shell::Basic.new
@@ -12,7 +12,9 @@ module Softcover::Commands::Server
12
12
  server_pid = Process.pid
13
13
  directories = ['.', 'chapters']
14
14
  @listener = Listen.to(*directories)
15
- @listener.filter(/(\.tex|\.md|custom\.sty)$/)
15
+ file_pattern = markdown? ? '\.md' : '\.tex'
16
+ @listener.filter(/(#{file_pattern}|custom\.sty)$/)
17
+
16
18
  @listener.change do |modified|
17
19
  rebuild modified.try(:first)
18
20
  Process.kill("HUP", server_pid)
@@ -20,11 +22,16 @@ module Softcover::Commands::Server
20
22
  @listener.start
21
23
  end
22
24
 
25
+ def markdown?
26
+ !Dir.glob(path('chapters/*.md')).empty?
27
+ end
28
+
23
29
  def rebuild(modified=nil)
24
30
  printf modified ? "=> #{File.basename modified} changed, rebuilding... " :
25
31
  'Building...'
26
32
  t = Time.now
27
- Softcover::Builders::Html.new.build
33
+ builder = Softcover::Builders::Html.new
34
+ builder.build(preserve_tex: true)
28
35
  puts "Done. (#{(Time.now - t).round(2)}s)"
29
36
 
30
37
  rescue Softcover::BookManifest::NotFound => e
@@ -1,12 +1,14 @@
1
1
  # A chapter
2
+ \label{cha:a_chapter}
2
3
 
3
- 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. (The other available input format is *PolyTeX*, a subset of the *LaTeX* typesetting language optimized for ebooks. PolyTeX has a more complicated syntax but is more powerful.) For more information, see [*The Softcover Manual*](http://manual.softcover.io/) (**link not live yet**). 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.
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/) (**link not live yet**). 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.
4
5
 
5
6
  This is the *second* paragraph, showing how to emphasize text.[^sample-footnote] You can also make text **bold** or _emphasize a second way_.
6
7
 
7
8
  ## A section
9
+ \label{sec:a_section}
8
10
 
9
- This is a section.
11
+ This is a section. You can refer to it using the \LaTeX\ cross-reference syntax, like so: Section~\ref{sec:a_section}.
10
12
 
11
13
  ### Source code
12
14
 
@@ -33,14 +35,37 @@ def hello
33
35
  end
34
36
  ```
35
37
 
38
+ The last of these can be combined with \PolyTeX's `codelisting` environment to make code listings with linked cross-references (Listing~\ref{code:hello}).
39
+
40
+ \begin{codelisting}
41
+ \codecaption{Hello, world.}
42
+ \label{code:hello}
43
+ ```ruby
44
+ def hello
45
+ puts "hello, world!"
46
+ end
47
+ ```
48
+ \end{codelisting}
49
+
50
+
36
51
  ### Mathematics
37
52
 
38
- Softcover's Markdown mode supports limited mathematical typesetting, including inline math, such as {$$}\phi^2 - \phi - 1 = 0{/$$}, and centered math, such as
53
+ Softcover's Markdown mode supports mathematical typesetting using \LaTeX\ syntax, including inline math, such as \( \phi^2 - \phi - 1 = 0, \) and centered math, such as
54
+ \[ \phi = \frac{1+\sqrt{5}}{2}. \]
55
+ It also support centered equations with linked cross-reference via embedded \PolyTeX\ (Eq.~\eqref{eq:phi}).
56
+
57
+ \begin{equation}
58
+ \label{eq:phi}
59
+ \phi = \frac{1+\sqrt{5}}{2}
60
+ \end{equation}
61
+
62
+ Softcover also supports an alternate math syntax, such as {$$}\phi^2 - \phi - 1 = 0{/$$}, and centered math, such as
39
63
 
40
64
  {$$}
41
65
  \phi = \frac{1+\sqrt{5}}{2}.
42
66
  {/$$}
43
67
 
68
+ The \LaTeX\ syntax is strongly preferred, but the alternate syntax is included for maximum compatibility with other systems.
44
69
 
45
70
  ## Images and tables
46
71
 
@@ -84,7 +109,7 @@ Commands:
84
109
  softcover login # Log into Softcover account
85
110
  softcover logout # Log out of Softcover account
86
111
  softcover new <name> # Generate new book directory structure.
87
- softcover open # Open book on Softcover website (OS X only)
112
+ softcover open # Open book on Softcover website
88
113
  softcover publish # Publish your book on Softcover
89
114
  softcover publish:screencasts # Publish screencasts
90
115
  softcover server # Run local server
@@ -110,7 +135,7 @@ This is the end of the template---apart from two mostly empty chapters. In fact,
110
135
 
111
136
  <<(chapters/yet_another_chapter.md, lang: text)
112
137
 
113
- Visit <http://manual.softcover.io> to learn more about what Softcover can do.
138
+ Visit [*The Softcover Book*](http://manual.softcover.io) to learn more about what Softcover can do.
114
139
 
115
140
 
116
141
  [^sample-footnote]: This is a footnote. It is numbered automatically.
@@ -1,12 +1,10 @@
1
1
  \chapter{A chapter}
2
2
  \label{cha:a_chapter}
3
3
 
4
- This is the first paragraph of the \PolyTeXnic\ 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://polytexnic.org/book}{\emph{The \PolyTeXnic\ Book}} and the \href{http://polytexnic.org/source}{\PolyTeX\ source of the book} (\textbf{links not live yet}). To learn how to easily publish (and optionally sell) documents produced with \PolyTeXnic, visit \href{http://softcover.io/}{Softcover.io}. \PolyTeXnic\ is currently in private beta; go to \href{http://softcover.io/}{Softcover.io} to get an invitation.
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} (\textbf{links not live yet}). 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
 
8
- \emph{Note}: ``\PolyTeXnic'' is pronounced exactly like the English word \emph{polytechnic}, and ``\LaTeX'' is pronounced \emph{lay}-tech (with ``tech'' as in ``technology'').\footnote{Pronunciations of ``\LaTeX'' differ, but \emph{lay}-tech is the one I prefer.}
9
-
10
8
  \section{A section}
11
9
  \label{sec:a_section}
12
10
 
@@ -17,14 +15,14 @@ This is a section. Because it has a label, we can refer to it as Section~\ref{se
17
15
 
18
16
  This is a subsection. As usual, it can be referenced by label (Section~\ref{sec:source_code}). Note that the label starts with \kode{sec:}, not \kode{ssec:} or \kode{subsec:}. Any of these would work, but I find that sections often become subsections (and vice versa) when figuring out the structure of a book, and using \kode{sec:} to prefix them both saves having to change labels.
19
17
 
20
- \PolyTeXnic\ comes with full support for syntax-highlighted source code:
18
+ Softcover comes with full support for syntax-highlighted source code:
21
19
  %= lang:ruby
22
20
  \begin{code}
23
21
  def hello
24
22
  puts "hello, world!"
25
23
  end
26
24
  \end{code}
27
- \noindent \PolyTeXnic\ can highlight any language supported by \href{http://pygments.org/languages/}{Pygments} (which means most of them).
25
+ \noindent Softcover can highlight any language supported by \href{http://pygments.org/languages/}{Pygments} (which means most of them).
28
26
 
29
27
  You can also define \emph{code listings}, as seen in Listing~\ref{code:hello_world}. Such code listings are automatically numbered and linked.
30
28
 
@@ -63,7 +61,7 @@ Listing~\ref{code:hyphenation} also shows how to escape the underscore character
63
61
  \subsection{Mathematics}
64
62
  \label{sec:mathematics}
65
63
 
66
- \PolyTeXnic\ supports full mathematical typesetting, including inline math, such as $\phi^2 - \phi - 1 = 0$, and centered math, such as
64
+ Softcover supports full mathematical typesetting, including inline math, such as $\phi^2 - \phi - 1 = 0$, and centered math, such as
67
65
  \[ \phi = \frac{1+\sqrt{5}}{2}. \]
68
66
  It also supports cross-referenced equations, as in Eq.~\eqref{eq:golden_ratio} and Eq.~\eqref{eq:stokes_theorem}.
69
67
 
@@ -82,7 +80,7 @@ It also supports cross-referenced equations, as in Eq.~\eqref{eq:golden_ratio} a
82
80
 
83
81
  This is the second section. As we saw above above, the first section is Section~\ref{sec:a_section}.
84
82
 
85
- \PolyTeXnic\ supports \href{http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}{\emph{floats}} such as figures and tables, including numbered captions and linked cross-references. The defining quality of a float is that its placement isn't guaranteed (i.e., it ``floats'' in the document), so you shouldn't generally assume it will be placed immediately after the text that precedes it. (Such placement \emph{will} be the case with HTML-based output, but \emph{not} in PDFs, where \TeX's state-of-the-art float placement algorithm is in charge.)
83
+ Softcover supports \href{http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}{\emph{floats}} such as figures and tables, including numbered captions and linked cross-references. The defining quality of a float is that its placement isn't guaranteed (i.e., it ``floats'' in the document), so you shouldn't generally assume it will be placed immediately after the text that precedes it. (Such placement \emph{will} be the case with HTML-based output, but \emph{not} in PDFs, where \TeX's state-of-the-art float placement algorithm is in charge.)
86
84
 
87
85
  \subsection{Graphics and figures}
88
86
  \label{sec:graphics_and_figures}
@@ -109,7 +107,7 @@ To turn an image into a figure, use the \kode{figure} environment (Figure~\ref{f
109
107
  \subsection{Tables and tabular environments}
110
108
  \label{tables_and_tabular}
111
109
 
112
- \PolyTeXnic\ supports raw tables via the \kode{tabular} environment. To make a tabular environment into a full-blown table, with a number and a caption, use the \kode{table} environment (Table~\ref{table:rails_actions}), which includes some special magic to make the font size nicer in PDFs.
110
+ Softcover supports raw tables via the \kode{tabular} environment. To make a tabular environment into a full-blown table, with a number and a caption, use the \kode{table} environment (Table~\ref{table:rails_actions}), which includes some special magic to make the font size nicer in PDFs.
113
111
 
114
112
  \bigskip
115
113
 
@@ -142,7 +140,7 @@ To turn an image into a figure, use the \kode{figure} environment (Figure~\ref{f
142
140
 
143
141
  \section{Command-line interface}
144
142
 
145
- \PolyTeXnic\ comes with a command-line interface called \kode{poly}. To get more information, just run \kode{poly help}:
143
+ Softcover comes with a command-line interface called \kode{poly}. To get more information, just run \kode{poly help}:
146
144
 
147
145
  %= lang:console
148
146
  \begin{code}
@@ -188,4 +186,4 @@ This is the end of the template---apart from two mostly empty chapters (Chapter~
188
186
 
189
187
  %= <<(chapters/yet_another_chapter.tex)
190
188
 
191
- Visit \href{http://polytexnic.org/book}{http://polytexnic.org/book} to learn more about what \PolyTeXnic\ can do.
189
+ See \href{http://manual.softcover.org/book}{\emph{The Softcover Book}} to learn more about what Softcover can do.
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -35,13 +35,13 @@ describe Softcover::CLI do
35
35
 
36
36
  context "softcover new options" do
37
37
  subject { `softcover help new` }
38
- it { should include '-m, [--markdown]' }
38
+ it { should include '-p, [--polytex]' }
39
39
  it { should include '-s, [--simple]' }
40
40
  end
41
41
 
42
42
  context "softcover new" do
43
43
  before(:all) { chdir_to_fixtures }
44
- after(:all) { remove_book }
44
+ after(:all) { remove_book }
45
45
  it "should not raise error" do
46
46
  result = `softcover new book 2>&1`
47
47
  expect($?.exitstatus).to eq 0
@@ -107,7 +107,7 @@ describe Softcover::CLI do
107
107
  before(:all) do
108
108
  remove_book
109
109
  chdir_to_fixtures
110
- silence { `softcover new book` }
110
+ silence { `softcover new book --polytex` }
111
111
  chdir_to_book
112
112
  end
113
113
  after(:all) { remove_book }
@@ -120,7 +120,7 @@ describe Softcover::CLI do
120
120
  before(:all) do
121
121
  remove_book
122
122
  chdir_to_fixtures
123
- silence { `softcover new book -m` }
123
+ silence { `softcover new book` }
124
124
  chdir_to_book
125
125
  end
126
126
  after(:all) { remove_book }
@@ -7,7 +7,7 @@ describe Softcover::Commands::Generator do
7
7
  before(:all) do
8
8
  chdir_to_non_book
9
9
  @name = 'foo_bar'
10
- Softcover::Commands::Generator.generate_file_tree @name
10
+ Softcover::Commands::Generator.generate_file_tree @name, polytex: true
11
11
  end
12
12
 
13
13
  let(:name) { @name }
@@ -142,7 +142,8 @@ describe Softcover::Commands::Generator do
142
142
  before(:all) do
143
143
  chdir_to_non_book
144
144
  @name = 'foo_bar'
145
- Softcover::Commands::Generator.generate_file_tree @name, simple: true
145
+ Softcover::Commands::Generator.generate_file_tree @name, simple: true,
146
+ polytex: true
146
147
  end
147
148
 
148
149
  let(:name) { @name }
@@ -196,7 +197,7 @@ describe Softcover::Commands::Generator do
196
197
  before(:all) do
197
198
  chdir_to_non_book
198
199
  @name = 'foo_bar'
199
- Softcover::Commands::Generator.generate_file_tree @name, markdown: true
200
+ Softcover::Commands::Generator.generate_file_tree @name
200
201
  end
201
202
 
202
203
  let(:name) { @name }
@@ -244,7 +245,9 @@ describe Softcover::Commands::Generator do
244
245
  $stdin.should_receive(:gets).and_return("a")
245
246
 
246
247
  silence do
247
- 2.times { Softcover::Commands::Generator.generate_file_tree name }
248
+ 2.times do
249
+ Softcover::Commands::Generator.generate_file_tree name, polytex: true
250
+ end
248
251
  end
249
252
  end
250
253
 
@@ -159,7 +159,7 @@ module WebmockHelpers
159
159
  remove_book
160
160
  Dir.chdir File.join File.dirname(__FILE__), "fixtures/"
161
161
  flags = []
162
- flags << '-m' if options[:markdown]
162
+ flags << '-p' unless options[:markdown]
163
163
  flags << '-s' if options[:simple]
164
164
  silence { system "softcover new #{name} #{flags.join(' ')}" }
165
165
  chdir_to_book
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.5.0
4
+ version: 0.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: 2013-11-13 00:00:00.000000000 Z
12
+ date: 2013-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: polytexnic