kitabu 1.0.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -3
  3. data/.travis.yml +18 -0
  4. data/CHANGELOG.md +9 -0
  5. data/Gemfile.lock +67 -50
  6. data/README.md +235 -0
  7. data/attachments/browser-version.png +0 -0
  8. data/attachments/cover.png +0 -0
  9. data/attachments/kitabu.epub +0 -0
  10. data/attachments/kitabu.mobi +0 -0
  11. data/attachments/kitabu.pdf +0 -0
  12. data/{spec/support/mybook/output → examples/kitabu/output/epub/images}/.gitkeep +0 -0
  13. data/examples/kitabu/output/epub/images/kitabu-icon.png +0 -0
  14. data/examples/kitabu/output/epub/images/kitabu-icon.svg +19 -0
  15. data/examples/kitabu/output/epub/images/kitabu-word.png +0 -0
  16. data/examples/kitabu/output/epub/images/kitabu-word.svg +14 -0
  17. data/examples/kitabu/output/epub/images/kitabu.png +0 -0
  18. data/examples/kitabu/output/epub/images/kitabu.svg +20 -0
  19. data/examples/kitabu/output/epub/section_0.html +266 -0
  20. data/examples/kitabu/output/epub/section_1.html +246 -0
  21. data/examples/kitabu/output/epub/section_2.html +520 -0
  22. data/examples/kitabu/output/epub/section_3.html +282 -0
  23. data/examples/kitabu/output/epub/section_4.html +276 -0
  24. data/examples/kitabu/output/epub/styles/epub.css +437 -0
  25. data/examples/kitabu/output/epub/styles/html.css +712 -0
  26. data/examples/kitabu/output/epub/styles/pdf.css +840 -0
  27. data/examples/kitabu/output/epub/styles/print.css +1278 -0
  28. data/examples/kitabu/output/epub/toc.html +37 -0
  29. data/{spec/support/mybook/templates/epub/style.css → examples/kitabu/output/images/.gitkeep} +0 -0
  30. data/examples/kitabu/output/images/kitabu-icon.png +0 -0
  31. data/examples/kitabu/output/images/kitabu-icon.svg +19 -0
  32. data/examples/kitabu/output/images/kitabu-word.png +0 -0
  33. data/examples/kitabu/output/images/kitabu-word.svg +14 -0
  34. data/examples/kitabu/output/images/kitabu.png +0 -0
  35. data/examples/kitabu/output/images/kitabu.svg +20 -0
  36. data/examples/kitabu/output/kitabu.epub +0 -0
  37. data/examples/kitabu/output/kitabu.html +513 -0
  38. data/examples/kitabu/output/kitabu.mobi +0 -0
  39. data/examples/kitabu/output/kitabu.pdf +0 -0
  40. data/examples/kitabu/output/kitabu.pdf.html +729 -0
  41. data/examples/kitabu/output/kitabu.print.html +729 -0
  42. data/examples/kitabu/output/kitabu.print.pdf +0 -0
  43. data/examples/kitabu/output/kitabu.txt +440 -0
  44. data/examples/kitabu/output/styles/epub.css +437 -0
  45. data/examples/kitabu/output/styles/html.css +712 -0
  46. data/examples/kitabu/output/styles/pdf.css +840 -0
  47. data/examples/kitabu/output/styles/print.css +1278 -0
  48. data/kitabu.gemspec +7 -5
  49. data/lib/kitabu.rb +10 -20
  50. data/lib/kitabu/cli.rb +0 -5
  51. data/lib/kitabu/dependency.rb +0 -4
  52. data/lib/kitabu/exporter.rb +2 -0
  53. data/lib/kitabu/extensions/rouge.rb +9 -0
  54. data/lib/kitabu/generator.rb +9 -21
  55. data/lib/kitabu/helpers.rb +47 -0
  56. data/lib/kitabu/markdown.rb +31 -0
  57. data/lib/kitabu/parser.rb +21 -3
  58. data/lib/kitabu/parser/epub.rb +31 -18
  59. data/lib/kitabu/parser/html.rb +48 -29
  60. data/lib/kitabu/parser/mobi.rb +1 -1
  61. data/lib/kitabu/parser/pdf.rb +52 -8
  62. data/lib/kitabu/version.rb +2 -2
  63. data/spec/kitabu/cli/export_spec.rb +4 -4
  64. data/spec/kitabu/cli/new_spec.rb +2 -2
  65. data/spec/kitabu/markdown_spec.rb +24 -0
  66. data/spec/kitabu/parser/html_spec.rb +20 -25
  67. data/spec/kitabu/parser/mobi_spec.rb +14 -0
  68. data/spec/kitabu/parser/pdf_spec.rb +18 -1
  69. data/spec/kitabu/parser/txt_spec.rb +14 -0
  70. data/spec/spec_helper.rb +10 -6
  71. data/spec/support/mybook/config/helper.rb +4 -29
  72. data/spec/support/mybook/config/kitabu.yml +0 -10
  73. data/spec/support/mybook/templates/epub/cover.erb +4 -3
  74. data/{templates → spec/support/mybook/templates/epub}/cover.png +0 -0
  75. data/spec/support/mybook/templates/epub/page.erb +3 -2
  76. data/spec/support/mybook/templates/html/layout.erb +10 -13
  77. data/spec/support/mybook/templates/styles/epub.scss +3 -0
  78. data/spec/support/mybook/templates/styles/html.scss +3 -0
  79. data/spec/support/mybook/templates/styles/pdf.scss +3 -0
  80. data/spec/support/mybook/templates/styles/print.scss +3 -0
  81. data/spec/support/mybook/text/{01_Markdown_Chapter.markdown → 01_Markdown_Chapter.md} +2 -3
  82. data/spec/support/mybook/text/02_ERB_Chapter.md.erb +7 -0
  83. data/spec/support/mybook/text/{04_With_Directory/Some_Chapter.mkdn → 03_With_Directory/Some_Chapter.md} +0 -0
  84. data/spec/support/mybook/text/{CHANGELOG.textile → CHANGELOG.md} +2 -2
  85. data/spec/support/mybook/text/{TOC.textile → TOC.md} +0 -0
  86. data/spec/support/mybook/text/{_00_Introduction.markdown → _00_Introduction.md} +0 -0
  87. data/spec/support/shared.rb +14 -10
  88. data/templates/Gemfile +3 -3
  89. data/templates/Guardfile +1 -5
  90. data/templates/config.erb +5 -5
  91. data/templates/cover.erb +4 -3
  92. data/templates/epub.erb +3 -2
  93. data/templates/helper.rb +28 -29
  94. data/templates/images/.gitkeep +0 -0
  95. data/templates/images/kitabu-icon.png +0 -0
  96. data/templates/images/kitabu-icon.svg +19 -0
  97. data/templates/images/kitabu-word.png +0 -0
  98. data/templates/images/kitabu-word.svg +14 -0
  99. data/templates/images/kitabu.png +0 -0
  100. data/templates/images/kitabu.svg +20 -0
  101. data/{examples/RailsGuides/templates → templates/templates/epub}/cover.erb +4 -3
  102. data/templates/templates/epub/cover.png +0 -0
  103. data/templates/templates/epub/page.erb +16 -0
  104. data/templates/{layout.erb → templates/html/layout.erb} +22 -11
  105. data/templates/templates/styles/epub.scss +1 -0
  106. data/templates/templates/styles/files/_normalize.scss +427 -0
  107. data/templates/templates/styles/html.scss +252 -0
  108. data/templates/templates/styles/pdf.scss +371 -0
  109. data/templates/templates/styles/print.scss +2 -0
  110. data/templates/text/01_Getting_Started.md +26 -0
  111. data/templates/text/02_Creating_Chapters.md +22 -0
  112. data/templates/text/03_Syntax_Highlighting.erb +69 -0
  113. data/templates/text/04_Dynamic_Content.erb +64 -0
  114. data/templates/text/05_Exporting_Files.md +49 -0
  115. metadata +143 -83
  116. data/README.rdoc +0 -218
  117. data/examples/RailsGuides/config/helper.rb +0 -29
  118. data/examples/RailsGuides/config/kitabu.yml +0 -44
  119. data/examples/RailsGuides/images/challenge.png +0 -0
  120. data/examples/RailsGuides/images/posts_index.png +0 -0
  121. data/examples/RailsGuides/images/rails_welcome.png +0 -0
  122. data/examples/RailsGuides/output/RailsGuides.epub +0 -0
  123. data/examples/RailsGuides/output/RailsGuides.html +0 -1556
  124. data/examples/RailsGuides/output/RailsGuides.pdf +3 -4934
  125. data/examples/RailsGuides/templates/layout.css +0 -352
  126. data/examples/RailsGuides/templates/layout.erb +0 -43
  127. data/examples/RailsGuides/templates/syntax.css +0 -62
  128. data/examples/RailsGuides/templates/user.css +0 -19
  129. data/examples/RailsGuides/text/01_Guide_Assumptions.mkdn +0 -13
  130. data/examples/RailsGuides/text/02_What_is_Rails.mkdn +0 -106
  131. data/examples/RailsGuides/text/03_Creating_a_new_Rails_project.mkdn +0 -200
  132. data/examples/RailsGuides/text/04_Hello_Rails.mkdn +0 -62
  133. data/examples/RailsGuides/text/05_Getting_Up_and_Running_Quickly_with_Scaffolding.mkdn +0 -4
  134. data/examples/RailsGuides/text/06_Creating_a_resource.mkdn +0 -503
  135. data/examples/RailsGuides/text/07_Adding_a_second_model.mkdn +0 -232
  136. data/examples/RailsGuides/text/08_Refactoring.mkdn +0 -123
  137. data/examples/RailsGuides/text/09_Deleting_comments.mkdn +0 -57
  138. data/examples/RailsGuides/text/09_Security.mkdn +0 -56
  139. data/examples/RailsGuides/text/10_Building_a_multi_model_form.mkdn +0 -130
  140. data/examples/RailsGuides/text/11_View_helpers.mkdn +0 -50
  141. data/examples/RailsGuides/text/12_Whats_next.mkdn +0 -14
  142. data/examples/RailsGuides/text/13_Configuration_gotchas.mkdn +0 -10
  143. data/lib/kitabu/adapters/markdown.rb +0 -34
  144. data/lib/kitabu/extensions/redcloth.rb +0 -69
  145. data/lib/kitabu/syntax.rb +0 -130
  146. data/spec/kitabu/extensions/redcloth_spec.rb +0 -57
  147. data/spec/kitabu/syntax_spec.rb +0 -106
  148. data/spec/support/mybook/templates/html/layout.css +0 -353
  149. data/spec/support/mybook/templates/html/syntax.css +0 -58
  150. data/spec/support/mybook/templates/html/user.css +0 -1
  151. data/spec/support/mybook/text/02_Textile_Chapter.textile +0 -3
  152. data/spec/support/mybook/text/03_HTML_Chapter.html +0 -3
  153. data/templates/epub.css +0 -500
  154. data/templates/layout.css +0 -353
  155. data/templates/sample.md +0 -6
  156. data/templates/syntax.css +0 -58
  157. data/templates/user.css +0 -1
@@ -0,0 +1,440 @@
1
+
2
+
3
+
4
+
5
+
6
+ This guide will help you understand how all of the pieces fit together on
7
+ Kitabu.
8
+ Nando Vieira
9
+
10
+ Contents
11
+
12
+ Getting_Started
13
+ Installing_Ruby
14
+ Installing_PrinceXML
15
+ Installing_KindleGen
16
+ Creating_Chapters
17
+ Syntax_Highlighting
18
+ What_about_the_syntax
19
+ Lexers
20
+ Dynamic_Content
21
+ Escaping_ERb_code
22
+ Exporting_Files
23
+ Exporting_PDF_with_DocRaptor
24
+
25
+ Getting Started
26
+
27
+ This guide is designed for beginners who want to get started with Kitabu from
28
+ scratch. However, to get the most out of it, you need to have some
29
+ prerequisites installed:
30
+
31
+ * The Ruby interpreter version 2.0.0 or greater.
32
+ * The PrinceXML converter version 9.0 or greater.
33
+ * The KindleGen converter.
34
+
35
+
36
+ Installing Ruby
37
+
38
+ To install Ruby, consider using RVM or rbenv, both available for Mac OSX and
39
+ Linux distros. If you’re running a Windows, well, I can’t help you. I
40
+ don’t even know if Kitabu runs over Windows boxes, so if you find any bugs,
41
+ make sure you let_me_know.
42
+
43
+ Installing PrinceXML
44
+
45
+ PrinceXML is the best HTML to PDF converter available. You can use advanced CSS
46
+ features to style your book in any way you want. But good things don’t come
47
+ for free, and PrinceXML is no exception. The Professional License, which you
48
+ grant you a installation on a single computer by a single user costs 495USD. If
49
+ you don’t like the price tag, consider using DocRaptor when you’re ready to
50
+ publish your book.
51
+ To install PrinceXML, go to the website and download the correct version for
52
+ your platform; you can choose from Mac OSX, to Linux and Windows.
53
+
54
+ Installing KindleGen
55
+
56
+ KindleGen is the command-line tool that allows you to convert e-pubs into .mobi
57
+ files. You can’t sell these files, though.1 So if that’s the case, consider
58
+ using Calibre for this task.2
59
+ If you’re running Homebrew on the Mac OSX, you can install it with brew
60
+ install kindlegen. Go to KindleGen’s_website and download the appropriate
61
+ installer otherwise.
62
+ -------------------------------------------------------------------------------
63
+
64
+ 1. You can, but that would be a violation of Amazon’s terms of use.� ↩
65
+ 2. Calibre is not perfect, but does a good job.� ↩
66
+
67
+
68
+ Creating Chapters
69
+
70
+ You can create chapters by having multiple files or directories. They’re
71
+ alphabetically sorted, so make sure you use a prefixed file name like
72
+ 01_Introduction.md as the file name.
73
+ If you’re going to write a long book, make sure you use the directory
74
+ organization. This way you can have smaller text files, which will be easier to
75
+ read and change as you go. A file structure suggestion for a book about Ruby_on
76
+ Rails would be:
77
+
78
+ getting-started-with-rails
79
+ ├── text
80
+ � � └── 01_Guide_Assumptions.md
81
+ � � └── 02_Whats_Rails.md
82
+ � � └── 03_Creating_A_New_Project
83
+ � � └── 01_Installing_Rails.md
84
+ � � └── 02_Creating_The_Blog_Application.md
85
+ � � └── 04_Hello_Rails
86
+ � � └── 01_Starting_Up_The_Web_Server.md
87
+ � � └── 02_Say_Hello_Rails.md
88
+ � � └── 03_Setting_The_Application_Home_Page.md
89
+ � � └── ...
90
+
91
+ Notice that the file name does not need to be readable, but it will make your
92
+ life easier.
93
+
94
+ Syntax Highlighting
95
+
96
+
97
+ What about the syntax
98
+
99
+ Kitabu uses Route as the syntax highlight formatter. It emits an output
100
+ compatible with stylesheets designed for pygments, the Python library used by
101
+ many.
102
+ To highlight a code block, use the fenced block syntax. The following example
103
+ would be formatted as Ruby.
104
+
105
+ ```ruby
106
+ class User
107
+ attr_accessor :name, :email
108
+
109
+ def initialize(name, email)
110
+ @name = name
111
+ @email = email
112
+ end
113
+ end
114
+ ```
115
+
116
+ The output would be something like this:
117
+
118
+ class User
119
+ attr_accessor :name, :email
120
+
121
+ def initialize(name, email)
122
+ @name = name
123
+ @email = email
124
+ end
125
+ end
126
+
127
+ If you’re using Sublime Text, make sure you install the Markdown_Extended
128
+ plugin; it enables code syntax highlighting on your Markdown files.
129
+ You can also provide inline options such as line numbers and inline rendering.
130
+
131
+ ```ruby?line_numbers=1
132
+ class User
133
+ attr_accessor :name, :email
134
+
135
+ def initialize(name, email)
136
+ @name = name
137
+ @email = email
138
+ end
139
+ end
140
+ ```
141
+
142
+ This would be rendered like this:
143
+
144
+
145
+ 1 class User
146
+ 2 attr_accessor :name, :email
147
+ 3
148
+ 4 def initialize(name, email)
149
+ 5 @name = name
150
+ 6 @email = email
151
+ 7 end
152
+ 8 end
153
+
154
+
155
+
156
+ Lexers
157
+
158
+ Rouge comes with dozens of lexers. Check out this list, generated dynamically
159
+ when you export your e-book.
160
+
161
+ * Apache apache
162
+ configuration files for Apache web server
163
+ * AppleScript applescript
164
+ The AppleScript scripting language by Apple Inc. (http://developer.apple.com/
165
+ applescript/)
166
+ * C c
167
+ The C programming language
168
+ * Clojure clojure
169
+ The Clojure programming language (clojure.org)
170
+ * CoffeeScript coffeescript
171
+ The Coffeescript programming language (coffeescript.org)
172
+ * Common Lisp common_lisp
173
+ The Common Lisp variant of Lisp (common-lisp.net)
174
+ * Config File conf
175
+ A generic lexer for configuration files
176
+ * C++ cpp
177
+ The C++ programming language
178
+ * C# csharp
179
+ a multi-paradigm language targeting .NET
180
+ * CSS css
181
+ Cascading Style Sheets, used to style web pages
182
+ * Dart dart
183
+ The Dart programming language (dartlang.com)
184
+ * diff diff
185
+ Lexes unified diffs or patches
186
+ * Elixir elixir
187
+ Elixir language (elixir-lang.org)
188
+ * ERB erb
189
+ Embedded ruby template files
190
+ * Erlang erlang
191
+ The Erlang programming language (erlang.org)
192
+ * Factor factor
193
+ Factor, the practical stack language (factorcode.org)
194
+ * Gherkin gherkin
195
+ A business-readable spec DSL ( github.com/cucumber/cucumber/wiki/Gherkin )
196
+ * Go go
197
+ The Go programming language (http://golang.org)
198
+ * Groovy groovy
199
+ The Groovy programming language (groovy.codehaus.org)
200
+ * Haml haml
201
+ The Haml templating system for Ruby (haml.info)
202
+ * Handlebars handlebars
203
+ the Handlebars and Mustache templating languages
204
+ * Haskell haskell
205
+ The Haskell programming language (haskell.org)
206
+ * HTML html
207
+ HTML, the markup language of the web
208
+ * HTTP http
209
+ http requests and responses
210
+ * INI ini
211
+ the INI configuration format
212
+ * Io io
213
+ The IO programming language (http://iolanguage.com)
214
+ * Java java
215
+ The Java programming language (java.com)
216
+ * JavaScript javascript
217
+ JavaScript, the browser scripting language
218
+ * Json json
219
+ JavaScript Object Notation (json.org)
220
+ * Liquid liquid
221
+ Liquid is a templating engine for Ruby (liquidmarkup.org)
222
+ * Literate CoffeeScript literate_coffeescript
223
+ Literate coffeescript
224
+ * Literate Haskell literate_haskell
225
+ Literate haskell
226
+ * LLVM llvm
227
+ The LLVM Compiler Infrastructure (http://llvm.org/)
228
+ * Lua lua
229
+ Lua (http://www.lua.org)
230
+ * Make make
231
+ Makefile syntax
232
+ * Markdown markdown
233
+ Markdown, a light-weight markup language for authors
234
+ * MATLAB matlab
235
+ Matlab
236
+ * MoonScript moonscript
237
+ Moonscript (http://www.moonscript.org)
238
+ * nginx nginx
239
+ configuration files for the nginx web server (nginx.org)
240
+ * Nim nim
241
+ The Nim programming language (http://nim-lang.org/)
242
+ * Objective-C objective_c
243
+ an extension of C commonly used to write Apple software
244
+ * OCaml ocaml
245
+ Objective CAML (ocaml.org)
246
+ * Perl perl
247
+ The Perl scripting language (perl.org)
248
+ * PHP php
249
+ The PHP scripting language (php.net)
250
+ * Plain Text plaintext
251
+ A boring lexer that doesn’t highlight anything
252
+ * Prolog prolog
253
+ The Prolog programming language (http://en.wikipedia.org/wiki/Prolog)
254
+ * .properties properties
255
+ .properties config files for Java
256
+ * Puppet puppet
257
+ The Puppet configuration management language (puppetlabs.org)
258
+ * Python python
259
+ The Python programming language (python.org)
260
+ * QML qml
261
+ QML, a UI markup language
262
+ * R r
263
+ The R statistics language (r-project.org)
264
+ * Racket racket
265
+ Racket is a Lisp descended from Scheme (racket-lang.org)
266
+ * Ruby ruby
267
+ The Ruby programming language (ruby-lang.org)
268
+ * Rust rust
269
+ The Rust programming language (rust-lang.org)
270
+ * Sass sass
271
+ The Sass stylesheet language language (sass-lang.com)
272
+ * Scala scala
273
+ The Scala programming language (scala-lang.org)
274
+ * Scheme scheme
275
+ The Scheme variant of Lisp
276
+ * SCSS scss
277
+ SCSS stylesheets (sass-lang.com)
278
+ * sed sed
279
+ sed, the ultimate stream editor
280
+ * shell shell
281
+ Various shell languages, including sh and bash
282
+ * Slim slim
283
+ The Slim template language
284
+ * Smalltalk smalltalk
285
+ The Smalltalk programming language
286
+ * SML sml
287
+ Standard ML
288
+ * SQL sql
289
+ Structured Query Language, for relational databases
290
+ * Swift swift
291
+ Multi paradigm, compiled programming language developed by Apple for iOS and
292
+ OS X development. (developer.apple.com/swift)
293
+ * Tcl tcl
294
+ The Tool Command Language (tcl.tk)
295
+ * TeX tex
296
+ The TeX typesetting system
297
+ * TOML toml
298
+ the TOML configuration format (https://github.com/mojombo/toml)
299
+ * Visual Basic vb
300
+ Visual Basic
301
+ * VimL viml
302
+ VimL, the scripting language for the Vim editor (vim.org)
303
+ * XML xml
304
+ XML
305
+ * YAML yaml
306
+ Yaml Ain’t Markup Language (yaml.org)
307
+
308
+ And if what you want is not on this list, make you open_a_ticket on the
309
+ project.
310
+
311
+ Dynamic Content
312
+
313
+ Sometimes you may find useful to generate content dynamically. Maybe you’re
314
+ going to read some configuration file, or maybe you just want to define some
315
+ helpers. Kitabu has support for ERb files; all you need to do is naming your
316
+ text file as .erb.
317
+ On the previous chapter, we listed all supported Rouge lexers. To do that, I
318
+ created a helper that looks like this:
319
+
320
+ module Kitabu
321
+ module Helpers
322
+ def lexers_list
323
+ buffer = '<ul class="lexers">'
324
+
325
+ Rouge::Lexers.constants.each do |const|
326
+ lexer = Rouge::Lexers.const_get(const)
327
+
328
+ begin
329
+ title = lexer.title
330
+ tag = lexer.tag
331
+ description = lexer.desc
332
+ rescue Exception => e
333
+ next
334
+ end
335
+
336
+ buffer << '<li>'
337
+ buffer << "<strong>#{title}</strong> "
338
+ buffer << "<code>#{tag}</code><br>"
339
+ buffer << "<span>#{description}</span>"
340
+ buffer << '</li>'
341
+ end
342
+
343
+ buffer << '</ul>'
344
+ buffer
345
+ end
346
+ end
347
+ end
348
+
349
+ To use it, I just needed to add <%= lexers_list %> to my text file. This
350
+ allows you to create anything you need!
351
+ Kitabu comes with some built-in helpers, such as note. With this helper, you
352
+ can create a note that generates a HTML structure, so you can easily style it.
353
+ The syntax for using the note helper is note(type, &block).
354
+
355
+ <% note do %>
356
+ Some text that will be parsed as Markdown.
357
+ <% end %>
358
+
359
+ By default, this will generate a <div class="note info"> tag, but you can
360
+ use anything you want.
361
+
362
+ <% note :warning do %>
363
+ Some text that will be parsed as Markdown.
364
+ <% end %>
365
+
366
+ Check_out_the_source for a sample on how to create block helpers like note.
367
+
368
+ Escaping ERb code
369
+
370
+ If you want to write a book about Rails, you’re likely to use lots of ERb
371
+ tags. In this case, make sure you escape the and markers as <% %> and
372
+ <%= %>; otherwise you’ll have a syntax error.
373
+
374
+ <%%= Date.today %>
375
+
376
+
377
+ Exporting Files
378
+
379
+ You can generate files as you go. Just execute kitabu export from your book’s
380
+ root directory.
381
+
382
+ $ kitabu export
383
+ ** e-book has been exported
384
+
385
+ This command will generate all supported formats1. The generated files will be
386
+ placed on your output directory; the following output list only the relevant
387
+ files.
388
+
389
+ $ tree output
390
+ output
391
+ ├── images
392
+ │� � ├── kitabu.png
393
+ │� � └── kitabu.svg
394
+ ├── kitabu.epub
395
+ ├── kitabu.html
396
+ ├── kitabu.mobi
397
+ ├── kitabu.pdf
398
+ ├── kitabu.print.pdf
399
+ ├── kitabu.txt
400
+ └── styles
401
+ ├── epub.css
402
+ ├── html.css
403
+ ├── pdf.css
404
+ └── print.css
405
+
406
+ This can take a while depending on your book size, but usually the process is
407
+ pretty fast. If you want to generate a specific format faster, provide the --
408
+ only flag.
409
+
410
+ $ kitabu export --only pdf
411
+
412
+ You can also automatically generate files when something changes. You can use
413
+ Guard for this, and Kitabu even generates a sample file for you. All you have
414
+ to do is running bundle exec guard.
415
+
416
+ $ bundle exec guard
417
+ 20:38:10 - INFO - Guard is now watching at '/Users/fnando/Projects/kitabu/
418
+ examples/kitabu'
419
+ ** e-book has been exported
420
+
421
+
422
+ Exporting PDF with DocRaptor
423
+
424
+ After exporting your files (you can use --only pdf for this), upload files to
425
+ somewhere public, possibly your Dropbox account. You can even use curl; since
426
+ the command is quite long, you can view it at https://gist.github.com/fnando/
427
+ de555a08e7aab14a661a.
428
+ -------------------------------------------------------------------------------
429
+
430
+ 1. Depend on Prince, html2text and KindleGen being available on your
431
+ $PATH.� ↩
432
+
433
+
434
+ Kitabu
435
+
436
+ This guide will help you understand how all of the pieces fit together on
437
+ Kitabu.
438
+ Nando Vieira
439
+ Copyright (C) 2015 Nando Vieira.
440
+
@@ -0,0 +1,437 @@
1
+ /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
2
+ /**
3
+ * 1. Set default font family to sans-serif.
4
+ * 2. Prevent iOS text size adjust after orientation change, without disabling
5
+ * user zoom.
6
+ */
7
+ /* line 9, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
8
+ html {
9
+ font-family: sans-serif;
10
+ /* 1 */
11
+ -ms-text-size-adjust: 100%;
12
+ /* 2 */
13
+ -webkit-text-size-adjust: 100%;
14
+ /* 2 */
15
+ }
16
+
17
+ /**
18
+ * Remove default margin.
19
+ */
20
+ /* line 19, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
21
+ body {
22
+ margin: 0;
23
+ }
24
+
25
+ /* HTML5 display definitions
26
+ ========================================================================== */
27
+ /**
28
+ * Correct `block` display not defined for any HTML5 element in IE 8/9.
29
+ * Correct `block` display not defined for `details` or `summary` in IE 10/11
30
+ * and Firefox.
31
+ * Correct `block` display not defined for `main` in IE 11.
32
+ */
33
+ /* line 33, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
34
+ article,
35
+ aside,
36
+ details,
37
+ figcaption,
38
+ figure,
39
+ footer,
40
+ header,
41
+ hgroup,
42
+ main,
43
+ menu,
44
+ nav,
45
+ section,
46
+ summary {
47
+ display: block;
48
+ }
49
+
50
+ /**
51
+ * 1. Correct `inline-block` display not defined in IE 8/9.
52
+ * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
53
+ */
54
+ /* line 54, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
55
+ audio,
56
+ canvas,
57
+ progress,
58
+ video {
59
+ display: inline-block;
60
+ /* 1 */
61
+ vertical-align: baseline;
62
+ /* 2 */
63
+ }
64
+
65
+ /**
66
+ * Prevent modern browsers from displaying `audio` without controls.
67
+ * Remove excess height in iOS 5 devices.
68
+ */
69
+ /* line 67, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
70
+ audio:not([controls]) {
71
+ display: none;
72
+ height: 0;
73
+ }
74
+
75
+ /**
76
+ * Address `[hidden]` styling not present in IE 8/9/10.
77
+ * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
78
+ */
79
+ /* line 77, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
80
+ [hidden],
81
+ template {
82
+ display: none;
83
+ }
84
+
85
+ /* Links
86
+ ========================================================================== */
87
+ /**
88
+ * Remove the gray background color from active links in IE 10.
89
+ */
90
+ /* line 89, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
91
+ a {
92
+ background-color: transparent;
93
+ }
94
+
95
+ /**
96
+ * Improve readability when focused and also mouse hovered in all browsers.
97
+ */
98
+ /* line 97, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
99
+ a:active,
100
+ a:hover {
101
+ outline: 0;
102
+ }
103
+
104
+ /* Text-level semantics
105
+ ========================================================================== */
106
+ /**
107
+ * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
108
+ */
109
+ /* line 109, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
110
+ abbr[title] {
111
+ border-bottom: 1px dotted;
112
+ }
113
+
114
+ /**
115
+ * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
116
+ */
117
+ /* line 117, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
118
+ b,
119
+ strong {
120
+ font-weight: bold;
121
+ }
122
+
123
+ /**
124
+ * Address styling not present in Safari and Chrome.
125
+ */
126
+ /* line 126, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
127
+ dfn {
128
+ font-style: italic;
129
+ }
130
+
131
+ /**
132
+ * Address variable `h1` font-size and margin within `section` and `article`
133
+ * contexts in Firefox 4+, Safari, and Chrome.
134
+ */
135
+ /* line 135, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
136
+ h1 {
137
+ font-size: 2em;
138
+ margin: 0.67em 0;
139
+ }
140
+
141
+ /**
142
+ * Address styling not present in IE 8/9.
143
+ */
144
+ /* line 144, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
145
+ mark {
146
+ background: #ff0;
147
+ color: #000;
148
+ }
149
+
150
+ /**
151
+ * Address inconsistent and variable font size in all browsers.
152
+ */
153
+ /* line 153, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
154
+ small {
155
+ font-size: 80%;
156
+ }
157
+
158
+ /**
159
+ * Prevent `sub` and `sup` affecting `line-height` in all browsers.
160
+ */
161
+ /* line 161, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
162
+ sub,
163
+ sup {
164
+ font-size: 75%;
165
+ line-height: 0;
166
+ position: relative;
167
+ vertical-align: baseline;
168
+ }
169
+
170
+ /* line 169, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
171
+ sup {
172
+ top: -0.5em;
173
+ }
174
+
175
+ /* line 173, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
176
+ sub {
177
+ bottom: -0.25em;
178
+ }
179
+
180
+ /* Embedded content
181
+ ========================================================================== */
182
+ /**
183
+ * Remove border when inside `a` element in IE 8/9/10.
184
+ */
185
+ /* line 184, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
186
+ img {
187
+ border: 0;
188
+ }
189
+
190
+ /**
191
+ * Correct overflow not hidden in IE 9/10/11.
192
+ */
193
+ /* line 192, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
194
+ svg:not(:root) {
195
+ overflow: hidden;
196
+ }
197
+
198
+ /* Grouping content
199
+ ========================================================================== */
200
+ /**
201
+ * Address margin not present in IE 8/9 and Safari.
202
+ */
203
+ /* line 203, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
204
+ figure {
205
+ margin: 1em 40px;
206
+ }
207
+
208
+ /**
209
+ * Address differences between Firefox and other browsers.
210
+ */
211
+ /* line 211, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
212
+ hr {
213
+ -moz-box-sizing: content-box;
214
+ box-sizing: content-box;
215
+ height: 0;
216
+ }
217
+
218
+ /**
219
+ * Contain overflow in all browsers.
220
+ */
221
+ /* line 221, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
222
+ pre {
223
+ overflow: auto;
224
+ }
225
+
226
+ /**
227
+ * Address odd `em`-unit font size rendering in all browsers.
228
+ */
229
+ /* line 229, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
230
+ code,
231
+ kbd,
232
+ pre,
233
+ samp {
234
+ font-family: monospace, monospace;
235
+ font-size: 1em;
236
+ }
237
+
238
+ /* Forms
239
+ ========================================================================== */
240
+ /**
241
+ * Known limitation: by default, Chrome and Safari on OS X allow very limited
242
+ * styling of `select`, unless a `border` property is set.
243
+ */
244
+ /**
245
+ * 1. Correct color not being inherited.
246
+ * Known issue: affects color of disabled elements.
247
+ * 2. Correct font properties not being inherited.
248
+ * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
249
+ */
250
+ /* line 252, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
251
+ button,
252
+ input,
253
+ optgroup,
254
+ select,
255
+ textarea {
256
+ color: inherit;
257
+ /* 1 */
258
+ font: inherit;
259
+ /* 2 */
260
+ margin: 0;
261
+ /* 3 */
262
+ }
263
+
264
+ /**
265
+ * Address `overflow` set to `hidden` in IE 8/9/10/11.
266
+ */
267
+ /* line 266, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
268
+ button {
269
+ overflow: visible;
270
+ }
271
+
272
+ /**
273
+ * Address inconsistent `text-transform` inheritance for `button` and `select`.
274
+ * All other form control elements do not inherit `text-transform` values.
275
+ * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
276
+ * Correct `select` style inheritance in Firefox.
277
+ */
278
+ /* line 277, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
279
+ button,
280
+ select {
281
+ text-transform: none;
282
+ }
283
+
284
+ /**
285
+ * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
286
+ * and `video` controls.
287
+ * 2. Correct inability to style clickable `input` types in iOS.
288
+ * 3. Improve usability and consistency of cursor style between image-type
289
+ * `input` and others.
290
+ */
291
+ /* line 290, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
292
+ button,
293
+ html input[type="button"],
294
+ input[type="reset"],
295
+ input[type="submit"] {
296
+ -webkit-appearance: button;
297
+ /* 2 */
298
+ cursor: pointer;
299
+ /* 3 */
300
+ }
301
+
302
+ /**
303
+ * Re-set default cursor for disabled elements.
304
+ */
305
+ /* line 302, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
306
+ button[disabled],
307
+ html input[disabled] {
308
+ cursor: default;
309
+ }
310
+
311
+ /**
312
+ * Remove inner padding and border in Firefox 4+.
313
+ */
314
+ /* line 311, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
315
+ button::-moz-focus-inner,
316
+ input::-moz-focus-inner {
317
+ border: 0;
318
+ padding: 0;
319
+ }
320
+
321
+ /**
322
+ * Address Firefox 4+ setting `line-height` on `input` using `!important` in
323
+ * the UA stylesheet.
324
+ */
325
+ /* line 322, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
326
+ input {
327
+ line-height: normal;
328
+ }
329
+
330
+ /**
331
+ * It's recommended that you don't attempt to style these elements.
332
+ * Firefox's implementation doesn't respect box-sizing, padding, or width.
333
+ *
334
+ * 1. Address box sizing set to `content-box` in IE 8/9/10.
335
+ * 2. Remove excess padding in IE 8/9/10.
336
+ */
337
+ /* line 334, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
338
+ input[type="checkbox"],
339
+ input[type="radio"] {
340
+ box-sizing: border-box;
341
+ /* 1 */
342
+ padding: 0;
343
+ /* 2 */
344
+ }
345
+
346
+ /**
347
+ * Fix the cursor style for Chrome's increment/decrement buttons. For certain
348
+ * `font-size` values of the `input`, it causes the cursor style of the
349
+ * decrement button to change from `default` to `text`.
350
+ */
351
+ /* line 346, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
352
+ input[type="number"]::-webkit-inner-spin-button,
353
+ input[type="number"]::-webkit-outer-spin-button {
354
+ height: auto;
355
+ }
356
+
357
+ /**
358
+ * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
359
+ * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
360
+ * (include `-moz` to future-proof).
361
+ */
362
+ /* line 357, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
363
+ input[type="search"] {
364
+ -webkit-appearance: textfield;
365
+ /* 1 */
366
+ -moz-box-sizing: content-box;
367
+ -webkit-box-sizing: content-box;
368
+ /* 2 */
369
+ box-sizing: content-box;
370
+ }
371
+
372
+ /**
373
+ * Remove inner padding and search cancel button in Safari and Chrome on OS X.
374
+ * Safari (but not Chrome) clips the cancel button when the search input has
375
+ * padding (and `textfield` appearance).
376
+ */
377
+ /* line 370, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
378
+ input[type="search"]::-webkit-search-cancel-button,
379
+ input[type="search"]::-webkit-search-decoration {
380
+ -webkit-appearance: none;
381
+ }
382
+
383
+ /**
384
+ * Define consistent border, margin, and padding.
385
+ */
386
+ /* line 379, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
387
+ fieldset {
388
+ border: 1px solid #c0c0c0;
389
+ margin: 0 2px;
390
+ padding: 0.35em 0.625em 0.75em;
391
+ }
392
+
393
+ /**
394
+ * 1. Correct `color` not being inherited in IE 8/9/10/11.
395
+ * 2. Remove padding so people aren't caught out if they zero out fieldsets.
396
+ */
397
+ /* line 390, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
398
+ legend {
399
+ border: 0;
400
+ /* 1 */
401
+ padding: 0;
402
+ /* 2 */
403
+ }
404
+
405
+ /**
406
+ * Remove default vertical scrollbar in IE 8/9/10/11.
407
+ */
408
+ /* line 399, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
409
+ textarea {
410
+ overflow: auto;
411
+ }
412
+
413
+ /**
414
+ * Don't inherit the `font-weight` (applied by a rule above).
415
+ * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
416
+ */
417
+ /* line 408, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
418
+ optgroup {
419
+ font-weight: bold;
420
+ }
421
+
422
+ /* Tables
423
+ ========================================================================== */
424
+ /**
425
+ * Remove most spacing between table cells.
426
+ */
427
+ /* line 419, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
428
+ table {
429
+ border-collapse: collapse;
430
+ border-spacing: 0;
431
+ }
432
+
433
+ /* line 424, /Users/fnando/Projects/kitabu/examples/kitabu/templates/styles/files/_normalize.scss */
434
+ td,
435
+ th {
436
+ padding: 0;
437
+ }