prophecy 0.1.3 → 0.2.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/README.md +14 -7
- data/lib/prophecy/assets/latex_template/book-core-first.sty +62 -35
- data/lib/prophecy/assets/sass/_byronic.sass +10 -6
- data/lib/prophecy/assets/stylesheets/style-epub.css +41 -41
- data/lib/prophecy/assets/stylesheets/style-mobi-kf8.css +41 -41
- data/lib/prophecy/assets/stylesheets/style-mobi.css +41 -41
- data/lib/prophecy/book.rb +3 -1
- data/lib/prophecy/chapter.rb +26 -3
- data/lib/prophecy/cli.rb +132 -47
- data/lib/prophecy/generators/book/book.yml.tt +9 -2
- data/lib/prophecy/generators/book/manuscript/further-comments.markdown +5 -0
- data/lib/prophecy/generators/book/manuscript/glossary.md +8 -3
- data/lib/prophecy/generators/book/manuscript/like-a-boat.md +12 -0
- data/lib/prophecy/generators/book/manuscript/nameless-labyrinth.markdown +24 -30
- data/lib/prophecy/generators/book/manuscript/time-machine.markdown +25 -0
- data/lib/prophecy/version.rb +1 -1
- data/prophecy.gemspec +4 -2
- metadata +9 -12
- data/lib/prophecy/generators/book/manuscript/the-sway-of-reason.markdown +0 -22
- data/lib/prophecy/generators/book/manuscript/unhuman-massiveness.markdown +0 -27
data/lib/prophecy/book.rb
CHANGED
data/lib/prophecy/chapter.rb
CHANGED
@@ -77,8 +77,21 @@ module Prophecy
|
|
77
77
|
unless @src.nil?
|
78
78
|
@render_ext = ext_for_output[book.output_format]
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
path = nil
|
81
|
+
try_folders = [ book.format_dir(@src), 'manuscript' ].uniq
|
82
|
+
try_folders.each do |dir|
|
83
|
+
path = File.join(dir, @src)
|
84
|
+
if File.exists?(path)
|
85
|
+
@path = path
|
86
|
+
break
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
unless @path
|
91
|
+
puts "Error. Cannot find #{@src} in folders #{try_folders.join(', ')}"
|
92
|
+
exit 2
|
93
|
+
end
|
94
|
+
|
82
95
|
@render_name = File.basename(@path).sub(/\.erb$/, '').sub(/\.[^\.]+$/, @render_ext)
|
83
96
|
@render_path = File.expand_path(
|
84
97
|
File.join(
|
@@ -200,6 +213,11 @@ module Prophecy
|
|
200
213
|
when '.md', '.mkd', '.markdown'
|
201
214
|
ret = Kramdown::Document.new(text).to_html
|
202
215
|
when '.tex'
|
216
|
+
# Is Pandoc installed?
|
217
|
+
unless system("pandoc --version > /dev/null 2>&1")
|
218
|
+
puts "Error. Pandoc not found, I'll need that for TeX to HTML conversion."
|
219
|
+
exit 2
|
220
|
+
end
|
203
221
|
File.open('./temp-chapter.tex', 'w'){|f| f << text }
|
204
222
|
r = system 'pandoc --smart --normalize --from=latex --to=html -o ./temp-chapter.xhtml ./temp-chapter.tex'
|
205
223
|
warn "WARNING: pandoc returned non-zero for #{self.to_s}" unless r
|
@@ -234,11 +252,16 @@ module Prophecy
|
|
234
252
|
|
235
253
|
case format
|
236
254
|
when '.html', '.xhtml'
|
255
|
+
# Is Pandoc installed?
|
256
|
+
unless system("pandoc --version > /dev/null 2>&1")
|
257
|
+
puts "Error. Pandoc not found, I'll need that for HTML to TeX conversion."
|
258
|
+
exit 2
|
259
|
+
end
|
237
260
|
File.open('./temp-chapter.html', 'w'){|f| f << text }
|
238
261
|
system 'pandoc --smart --normalize --chapters --from=html --to=latex -o ./temp-chapter.tex ./temp-chapter.html'
|
239
262
|
ret = IO.read('./temp-chapter.tex')
|
240
263
|
FileUtils.rm(['./temp-chapter.tex', './temp-chapter.html'])
|
241
|
-
when '.md'
|
264
|
+
when '.md', '.mkd', '.markdown'
|
242
265
|
ret = Kramdown::Document.new(text, options = {:latex_headers => %w{chapter section subsection subsubsection paragraph subparagraph}}).to_latex
|
243
266
|
when '.tex'
|
244
267
|
ret = text
|
data/lib/prophecy/cli.rb
CHANGED
@@ -18,14 +18,30 @@ module Prophecy
|
|
18
18
|
Prophecy::Generators::Assets.start
|
19
19
|
end
|
20
20
|
|
21
|
-
desc "epub", "
|
21
|
+
desc "epub", "Generate new EPUB from sources. This calls assets_compile, epub_clean_dir, epub_build, epub_compile."
|
22
22
|
def epub
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
epub_init
|
24
|
+
assets_compile
|
25
|
+
epub_clean_dir
|
26
|
+
epub_build
|
27
|
+
epub_compile
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "epub_clean_dir", "Delete everything in the EPUB build dir"
|
31
|
+
def epub_clean_dir
|
32
|
+
epub_init
|
33
|
+
clean_dir
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "epub_build", "Generate EPUB build files from the templates and manuscript"
|
37
|
+
def epub_build
|
38
|
+
epub_init
|
28
39
|
@book.generate_build
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "epub_compile", "Compile EPUB file from the build dir"
|
43
|
+
def epub_compile
|
44
|
+
epub_init
|
29
45
|
|
30
46
|
# Compile Epub with Zip
|
31
47
|
print "Compiling Epub with Zip... "
|
@@ -54,14 +70,30 @@ module Prophecy
|
|
54
70
|
#cmd = system("epubcheck builds/epub/book.epub")
|
55
71
|
end
|
56
72
|
|
57
|
-
desc "mobi", "
|
73
|
+
desc "mobi", "Generate new MOBI with Kindlegen from sources. This calls assets_compile, mobi_clean_dir, mobi_build, mobi_compile."
|
58
74
|
def mobi
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
75
|
+
mobi_init
|
76
|
+
assets_compile
|
77
|
+
mobi_clean_dir
|
78
|
+
mobi_build
|
79
|
+
mobi_compile
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "mobi_clean_dir", "Delete everything in the MOBI build dir"
|
83
|
+
def mobi_clean_dir
|
84
|
+
mobi_init
|
85
|
+
clean_dir
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "mobi_build", "Generate MOBI build files from the templates and manuscript"
|
89
|
+
def mobi_build
|
90
|
+
mobi_init
|
64
91
|
@book.generate_build
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "mobi_compile", "Compile MOBI file from the build dir"
|
95
|
+
def mobi_compile
|
96
|
+
mobi_init
|
65
97
|
|
66
98
|
# Compile Epub with Zip for conversion with kindlegen
|
67
99
|
print "Compiling Epub (for Mobi) with Zip... "
|
@@ -114,40 +146,91 @@ module Prophecy
|
|
114
146
|
puts "Error. See kindlestrip.log"
|
115
147
|
exit 2
|
116
148
|
end
|
149
|
+
end
|
117
150
|
|
151
|
+
desc "latex", "Generate new PDF with LaTeX from sources. This calls latex_clean_dir, latex_build, latex_compile"
|
152
|
+
def latex
|
153
|
+
latex_init
|
154
|
+
latex_clean_dir
|
155
|
+
latex_build
|
156
|
+
latex_compile
|
118
157
|
end
|
119
158
|
|
120
|
-
desc "
|
121
|
-
def
|
122
|
-
|
123
|
-
|
124
|
-
|
159
|
+
desc "latex_clean_dir", "Delete everything in the LaTeX build dir"
|
160
|
+
def latex_clean_dir
|
161
|
+
latex_init
|
162
|
+
clean_dir
|
163
|
+
end
|
164
|
+
|
165
|
+
desc "latex_build", "Generate LaTeX build files from the templates and manuscript"
|
166
|
+
def latex_build
|
167
|
+
latex_init
|
125
168
|
@book.generate_build
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
169
|
+
end
|
170
|
+
|
171
|
+
desc "latex_compile", "Compile PDF file from the LaTeX build dir"
|
172
|
+
def latex_compile
|
173
|
+
latex_init
|
174
|
+
|
175
|
+
# Is LuaLatex installed?
|
176
|
+
unless system("lualatex --version > /dev/null 2>&1")
|
177
|
+
puts "Error. LuaLaTeX not found."
|
178
|
+
exit 2
|
179
|
+
end
|
180
|
+
|
181
|
+
print "Running 'make' in #{@book.build_dir} ... "
|
182
|
+
|
183
|
+
cmd = "{ cd #{@book.build_dir}"
|
184
|
+
cmd += " && make"
|
185
|
+
cmd += " && cp book_main.pdf ../../publish/pdf/; } > lualatex.log 2>&1"
|
186
|
+
|
187
|
+
if system(cmd)
|
188
|
+
puts "OK"
|
189
|
+
puts "Find book_main.pdf in ./build/latex/ and ./publish/pdf"
|
190
|
+
else
|
191
|
+
puts "Error. See lualatex.log and ./build/latex/book_main.log"
|
192
|
+
exit 2
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# desc "to_markdown", "convert .tex files to markdown"
|
197
|
+
# def to_markdown
|
198
|
+
# @book = latex_init_book
|
199
|
+
#
|
200
|
+
# Dir[File.join(@book.tex_dir, '*.tex')].each do |f|
|
201
|
+
# dest = File.expand_path(File.join(@book.markdown_dir, File.basename(f).sub(/\.tex$/, '.md')))
|
202
|
+
# if File.exist?(dest)
|
203
|
+
# print "WARNING: destination exists: #{dest}\nOverwrite? [yN] "
|
204
|
+
# a = STDIN.gets.chomp()
|
205
|
+
# if a.downcase != 'y'
|
206
|
+
# puts "OK, skipping file"
|
207
|
+
# next
|
208
|
+
# end
|
209
|
+
# end
|
210
|
+
# r = system "/bin/bash #{File.join(@book.assets_dir, 'helpers/tex2md.sh')} '#{File.expand_path(f)}' '#{dest}'"
|
211
|
+
# warn "WARNING: tex2md.sh returned non-zero for #{f}" unless r
|
212
|
+
# end
|
213
|
+
# end
|
214
|
+
|
215
|
+
desc "assets_compile", "Compile assets (run compass, etc.) if there is a local assets folder"
|
216
|
+
def assets_compile
|
217
|
+
unless Dir.exists?('./assets')
|
218
|
+
return
|
219
|
+
end
|
220
|
+
puts "Running 'compass compile' ..."
|
221
|
+
if system 'cd assets && compass compile'
|
222
|
+
puts "OK"
|
223
|
+
else
|
224
|
+
puts "Error"
|
225
|
+
exit 2
|
145
226
|
end
|
146
227
|
end
|
147
228
|
|
148
229
|
private
|
149
230
|
|
150
|
-
def
|
231
|
+
def epub_init
|
232
|
+
@config ||= YAML::load(IO.read('book.yml'))
|
233
|
+
|
151
234
|
[ './epub_mobi.yml',
|
152
235
|
'./epub.yml' ].each do |c|
|
153
236
|
next if !File.exists?(c)
|
@@ -156,10 +239,12 @@ module Prophecy
|
|
156
239
|
end
|
157
240
|
|
158
241
|
@config['output_format'] ||= 'epub'
|
159
|
-
Prophecy::Book.new(@config)
|
242
|
+
@book ||= Prophecy::Book.new(@config)
|
160
243
|
end
|
161
244
|
|
162
|
-
def
|
245
|
+
def mobi_init
|
246
|
+
@config ||= YAML::load(IO.read('book.yml'))
|
247
|
+
|
163
248
|
[ './epub_mobi.yml',
|
164
249
|
'./mobi.yml' ].each do |c|
|
165
250
|
next if !File.exists?(c)
|
@@ -168,10 +253,12 @@ module Prophecy
|
|
168
253
|
end
|
169
254
|
|
170
255
|
@config['output_format'] ||= 'mobi'
|
171
|
-
Prophecy::Book.new(@config)
|
256
|
+
@book ||= Prophecy::Book.new(@config)
|
172
257
|
end
|
173
258
|
|
174
|
-
def
|
259
|
+
def latex_init
|
260
|
+
@config ||= YAML::load(IO.read('book.yml'))
|
261
|
+
|
175
262
|
[ './latex.yml', ].each do |c|
|
176
263
|
next if !File.exists?(c)
|
177
264
|
h = YAML::load(IO.read(c))
|
@@ -179,14 +266,12 @@ module Prophecy
|
|
179
266
|
end
|
180
267
|
|
181
268
|
@config['output_format'] ||= 'latex'
|
182
|
-
@book
|
183
|
-
end
|
184
|
-
|
185
|
-
def compile_assets
|
186
|
-
system 'cd assets && compass compile'
|
269
|
+
@book ||= Prophecy::Book.new(@config)
|
187
270
|
end
|
188
271
|
|
189
|
-
def clean_dir
|
272
|
+
def clean_dir
|
273
|
+
dir = @book.build_dir
|
274
|
+
puts "Cleaning #{dir} ..."
|
190
275
|
if Dir[File.join(dir, '*')].empty?
|
191
276
|
puts "#{dir} is empty."
|
192
277
|
return
|
@@ -25,17 +25,24 @@ date: <%= Time.now.strftime("%Y-%m-%d") %>
|
|
25
25
|
|
26
26
|
toc:
|
27
27
|
- { the_matter: frontmatter }
|
28
|
+
- { insert: "\\frontmatter*\n\\chapterstyle{frontmatter}", target: latex }
|
28
29
|
- { title: "Cover", src: 'cover.xhtml.erb', target: epub, layout: none, type: cover, linear: no }
|
29
30
|
- { title: "Title Page", src: 'titlepage.xhtml.erb', target: epub, type: title-page }
|
30
31
|
- { title: "Contents", src: 'toc.xhtml.erb', target: epub, type: toc }
|
32
|
+
- { insert: "\\cleartorecto\n\\tableofcontents", target: latex }
|
31
33
|
- preface.md
|
32
34
|
- { title: "Title Page", src: 'titlepage.xhtml.erb', target: mobi, type: text, class: title-page }
|
33
35
|
- { title: "Contents", src: 'toc.xhtml.erb', target: mobi, type: toc }
|
34
36
|
- { the_matter: mainmatter, section_number: 1 }
|
35
|
-
-
|
36
|
-
-
|
37
|
+
- { insert: "\\mainmatter*\n\\book{\\thetitle}\n\\setcounter{chapter}{0}\n\\chapterstyle{mainmatter}", target: latex }
|
38
|
+
- like-a-boat.md
|
37
39
|
- nameless-labyrinth.markdown
|
40
|
+
- time-machine.markdown
|
41
|
+
- { insert: '\appendix', target: latex }
|
42
|
+
- { section_name: "Appendix", section_number: 1 }
|
43
|
+
- further-comments.markdown
|
38
44
|
- { the_matter: backmatter }
|
45
|
+
- { insert: "\\backmatter\n\\bookmarksetup{startatroot}\n\\chapterstyle{backmatter}", target: latex }
|
39
46
|
- glossary.md
|
40
47
|
|
41
48
|
cover_image: "cover.jpg"
|
@@ -1,34 +1,28 @@
|
|
1
1
|
|
2
|
-
# Nameless Labyrinth
|
2
|
+
# The Nameless Labyrinth
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
smaller separate structures. The general shape of these things tended to be
|
12
|
-
conical, pyramidal, or terraced; though there were many perfect cylinders,
|
13
|
-
perfect cubes, clusters of cubes, and other rectangular forms, and a peculiar
|
14
|
-
sprinkling of angled edifices whose five-pointed ground plan roughly suggested
|
15
|
-
modern fortifications. The builders had made constant and expert use of the
|
16
|
-
principle of the arch, and domes had probably existed in the city's heyday.
|
4
|
+
> "I have seen the dark universe yawning\\
|
5
|
+
> Where the black planets roll without aim,\\
|
6
|
+
> Where they roll in their horror unheeded,\\
|
7
|
+
> without knowledge or lustre or name."
|
8
|
+
>
|
9
|
+
> Nemesis, 1917
|
10
|
+
> {:.attribution}
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
12
|
+
Yet now the sway of reason seemed irrefutably shaken, for this
|
13
|
+
Cyclopean maze of squared, curved, and angled blocks had features
|
14
|
+
which cut off all comfortable refuge. It was, very clearly, the
|
15
|
+
blasphemous city of the mirage in stark, objective, and
|
16
|
+
ineluctable reality. That damnable portent had had a material
|
17
|
+
basis after all—there had been some horizontal stratum of ice
|
18
|
+
dust in the upper air, and this shocking stone survival had
|
19
|
+
projected its image across the mountains according to the simple
|
20
|
+
laws of reflection, Of course, the phantom had been twisted and
|
21
|
+
exaggerated, and had contained things which the real source did
|
22
|
+
not contain; yet now, as we saw that real source, we thought it
|
23
|
+
even more hideous and menacing than its distant image.
|
24
|
+
|
25
|
+
[At the Mountains of Madness][1] by *H.P. Lovecraft*, 1931
|
26
|
+
|
27
|
+
[1]: http://en.wikisource.org/wiki/At_the_Mountains_of_Madness/Chapter_5
|
34
28
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
# The Time Machine
|
3
|
+
|
4
|
+
The Time Traveller (for so it will be convenient to speak of him)
|
5
|
+
was expounding a recondite matter to us. His grey eyes shone and
|
6
|
+
twinkled, and his usually pale face was flushed and animated. The
|
7
|
+
fire burned brightly, and the soft radiance of the incandescent
|
8
|
+
lights in the lilies of silver caught the bubbles that flashed
|
9
|
+
and passed in our glasses. Our chairs, being his patents,
|
10
|
+
embraced and caressed us rather than submitted to be sat upon,
|
11
|
+
and there was that luxurious after-dinner atmosphere when thought
|
12
|
+
roams gracefully free of the trammels of precision. And he put it
|
13
|
+
to us in this way -- marking the points with a lean forefinger --
|
14
|
+
as we sat and lazily admired his earnestness over this new
|
15
|
+
paradox (as we thought it) and his fecundity.
|
16
|
+
|
17
|
+
'You must follow me carefully. I shall have to controvert one or
|
18
|
+
two ideas that are almost universally accepted. The geometry, for
|
19
|
+
instance, they taught you at school is founded on a
|
20
|
+
misconception.'
|
21
|
+
|
22
|
+
[The Time Machine][1] by *H.G. Wells*, 1895
|
23
|
+
|
24
|
+
[1]: http://en.wikisource.org/wiki/The_Time_Machine_(Heinemann_text)/Chapter_I
|
25
|
+
|