kitabu 2.1.0 → 3.0.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 +5 -5
- data/.github/CODEOWNERS +4 -0
- data/.github/FUNDING.yml +4 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +38 -0
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ruby-tests.yml +61 -0
- data/.rubocop.yml +17 -0
- data/CHANGELOG.md +13 -2
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +79 -0
- data/Gemfile +2 -0
- data/LICENSE.md +20 -0
- data/README.md +103 -88
- data/Rakefile +7 -0
- data/bin/kitabu +4 -0
- data/kitabu.gemspec +21 -15
- data/lib/kitabu/cli.rb +54 -39
- data/lib/kitabu/dependency.rb +11 -5
- data/lib/kitabu/errors.rb +2 -0
- data/lib/kitabu/exporter/base.rb +11 -11
- data/lib/kitabu/exporter/css.rb +6 -15
- data/lib/kitabu/exporter/epub.rb +23 -17
- data/lib/kitabu/exporter/html.rb +27 -21
- data/lib/kitabu/exporter/mobi.rb +7 -1
- data/lib/kitabu/exporter/pdf.rb +9 -3
- data/lib/kitabu/exporter.rb +15 -16
- data/lib/kitabu/extensions/rouge.rb +6 -1
- data/lib/kitabu/extensions/string.rb +5 -3
- data/lib/kitabu/footnotes/base.rb +2 -0
- data/lib/kitabu/footnotes/html.rb +18 -13
- data/lib/kitabu/footnotes/pdf.rb +17 -11
- data/lib/kitabu/generator.rb +13 -8
- data/lib/kitabu/helpers.rb +12 -9
- data/lib/kitabu/markdown.rb +12 -10
- data/lib/kitabu/source_list.rb +15 -12
- data/lib/kitabu/stats.rb +3 -1
- data/lib/kitabu/syntax/highlight.rb +4 -11
- data/lib/kitabu/toc/epub.rb +5 -2
- data/lib/kitabu/toc/html/stream.rb +3 -1
- data/lib/kitabu/toc/html.rb +12 -8
- data/lib/kitabu/version.rb +4 -2
- data/lib/kitabu.rb +8 -10
- data/spec/kitabu/cli/export_spec.rb +6 -4
- data/spec/kitabu/cli/new_spec.rb +6 -4
- data/spec/kitabu/cli/permalinks_spec.rb +4 -2
- data/spec/kitabu/cli/stats_spec.rb +19 -15
- data/spec/kitabu/cli/version_spec.rb +3 -1
- data/spec/kitabu/exporter/css_spec.rb +3 -1
- data/spec/kitabu/exporter/epub_spec.rb +2 -0
- data/spec/kitabu/exporter/html_spec.rb +11 -9
- data/spec/kitabu/exporter/mobi_spec.rb +5 -5
- data/spec/kitabu/exporter/pdf_spec.rb +8 -4
- data/spec/kitabu/extensions/string_spec.rb +14 -9
- data/spec/kitabu/footnotes/html_spec.rb +35 -33
- data/spec/kitabu/generator_spec.rb +3 -1
- data/spec/kitabu/markdown_spec.rb +8 -6
- data/spec/kitabu/source_list_spec.rb +8 -2
- data/spec/kitabu/stats_spec.rb +10 -6
- data/spec/kitabu/toc/html_spec.rb +37 -21
- data/spec/spec_helper.rb +23 -8
- data/spec/support/exit_with_code.rb +7 -5
- data/spec/support/have_tag.rb +44 -32
- data/spec/support/helper.rb +5 -3
- data/spec/support/mybook/code/code.rb +2 -0
- data/spec/support/mybook/config/helper.rb +2 -0
- data/spec/support/shared.rb +8 -6
- data/templates/Gemfile +5 -3
- data/templates/Guardfile +3 -1
- data/templates/helper.rb +8 -6
- data/templates/templates/styles/epub.css +1 -0
- data/templates/templates/styles/files/normalize.css +351 -0
- data/templates/templates/styles/{html.scss → html.css} +28 -26
- data/templates/templates/styles/{pdf.scss → pdf.css} +49 -47
- data/templates/templates/styles/print.css +2 -0
- data/templates/text/01_Getting_Started.md +27 -9
- data/templates/text/02_Creating_Chapters.md +9 -3
- data/templates/text/{03_Syntax_Highlighting.erb → 03_Syntax_Highlighting.md.erb} +12 -7
- data/templates/text/04_Dynamic_Content.md.erb +48 -0
- data/templates/text/05_Exporting_Files.md +17 -8
- metadata +40 -48
- data/.gitmodules +0 -3
- data/.travis.yml +0 -18
- data/lib/kitabu/exporter/txt.rb +0 -18
- data/spec/kitabu/exporter/txt_spec.rb +0 -14
- data/templates/ebook.png +0 -0
- data/templates/templates/styles/epub.scss +0 -1
- data/templates/templates/styles/files/_normalize.scss +0 -427
- data/templates/templates/styles/print.scss +0 -2
- data/templates/text/04_Dynamic_Content.erb +0 -64
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import "./files/normalize.css";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
:root {
|
|
4
|
+
--frontcover-color: #5091b1;
|
|
5
|
+
--frontcover-darker-color: #40748e;
|
|
6
|
+
--frontcover-padding: 50px;
|
|
7
|
+
--page-height: 22.86cm;
|
|
8
|
+
--page-height: 19.05cm;
|
|
9
|
+
}
|
|
8
10
|
|
|
9
11
|
@page {
|
|
10
12
|
size: 19.05cm 22.86cm portrait;
|
|
@@ -36,8 +38,8 @@ $frontcover-padding: 50px;
|
|
|
36
38
|
|
|
37
39
|
@page frontcover {
|
|
38
40
|
margin: 0;
|
|
39
|
-
background:
|
|
40
|
-
border-left: 50px solid
|
|
41
|
+
background: var(--frontcover-color);
|
|
42
|
+
border-left: 50px solid var(--frontcover-darker-color);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
@page chapter {
|
|
@@ -47,7 +49,7 @@ $frontcover-padding: 50px;
|
|
|
47
49
|
@footnotes {
|
|
48
50
|
border-top: thin solid #777;
|
|
49
51
|
margin-top: 1em;
|
|
50
|
-
padding-top: .5em;
|
|
52
|
+
padding-top: 0.5em;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -69,14 +71,14 @@ body {
|
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
a {
|
|
72
|
-
color:
|
|
74
|
+
color: var(--frontcover-color);
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
.go-top {
|
|
76
78
|
display: none;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
/* White page */
|
|
80
82
|
.white-page {
|
|
81
83
|
page: white;
|
|
82
84
|
page-break-before: always;
|
|
@@ -84,7 +86,7 @@ a {
|
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
.white-page:before {
|
|
87
|
-
content:
|
|
89
|
+
content: "This page intentionally left blank";
|
|
88
90
|
text-transform: uppercase;
|
|
89
91
|
position: absolute;
|
|
90
92
|
left: 0;
|
|
@@ -94,10 +96,10 @@ a {
|
|
|
94
96
|
transform: translatey(-50%);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
/* Style frontcover */
|
|
98
100
|
.frontcover {
|
|
99
101
|
page: frontcover;
|
|
100
|
-
padding:
|
|
102
|
+
padding: var(--frontcover-padding);
|
|
101
103
|
padding-left: 0;
|
|
102
104
|
text-align: center;
|
|
103
105
|
font-family: sans-serif;
|
|
@@ -108,7 +110,7 @@ a {
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
.frontcover .logo {
|
|
111
|
-
background: url(
|
|
113
|
+
background: url("../images/kitabu-word.svg") no-repeat center bottom;
|
|
112
114
|
height: 150px;
|
|
113
115
|
margin-bottom: 35px;
|
|
114
116
|
}
|
|
@@ -121,13 +123,13 @@ a {
|
|
|
121
123
|
display: inline-block;
|
|
122
124
|
width: 400px;
|
|
123
125
|
font-size: 20px;
|
|
124
|
-
color: rgba(#fff, .7);
|
|
126
|
+
color: rgba(#fff, 0.7);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
.frontcover .description:after {
|
|
128
|
-
content:
|
|
130
|
+
content: "";
|
|
129
131
|
display: block;
|
|
130
|
-
background: url(
|
|
132
|
+
background: url("../images/kitabu-icon.svg") no-repeat center bottom;
|
|
131
133
|
background-size: 200px;
|
|
132
134
|
height: 300px;
|
|
133
135
|
margin-top: 50px;
|
|
@@ -135,18 +137,18 @@ a {
|
|
|
135
137
|
|
|
136
138
|
.frontcover .authors {
|
|
137
139
|
font-size: 24px;
|
|
138
|
-
padding:
|
|
140
|
+
padding: var(--frontcover-padding);
|
|
139
141
|
font-weight: bold;
|
|
140
142
|
margin-top: 30px;
|
|
141
|
-
color: rgba(#000, .4);
|
|
143
|
+
color: rgba(#000, 0.4);
|
|
142
144
|
text-transform: uppercase;
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
.frontcover .authors:before {
|
|
146
|
-
content:
|
|
148
|
+
content: "By ";
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
|
|
151
|
+
/* Style chapter */
|
|
150
152
|
.chapters {
|
|
151
153
|
counter-reset: chapter;
|
|
152
154
|
}
|
|
@@ -160,9 +162,9 @@ a {
|
|
|
160
162
|
.chapter > h2 {
|
|
161
163
|
font-family: sans-serif;
|
|
162
164
|
margin: -100px -100px 75px -100px;
|
|
163
|
-
background:
|
|
165
|
+
background: var(--frontcover-color);
|
|
164
166
|
padding: 100px;
|
|
165
|
-
color: rgba(#fff, .6);
|
|
167
|
+
color: rgba(#fff, 0.6);
|
|
166
168
|
font-size: 40px;
|
|
167
169
|
}
|
|
168
170
|
|
|
@@ -171,14 +173,14 @@ a {
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
.chapter > h2:before {
|
|
174
|
-
content:
|
|
176
|
+
content: "Chapter " counter(chapter);
|
|
175
177
|
display: block;
|
|
176
178
|
font-size: 18px;
|
|
177
179
|
text-transform: uppercase;
|
|
178
180
|
color: #fff;
|
|
179
181
|
}
|
|
180
182
|
|
|
181
|
-
|
|
183
|
+
/* Code highlighting */
|
|
182
184
|
p code,
|
|
183
185
|
li code {
|
|
184
186
|
font-size: 12px;
|
|
@@ -199,7 +201,7 @@ li code {
|
|
|
199
201
|
padding-right: 15px;
|
|
200
202
|
}
|
|
201
203
|
|
|
202
|
-
|
|
204
|
+
/* Format lexers list */
|
|
203
205
|
.lexers-list {
|
|
204
206
|
margin: 0;
|
|
205
207
|
padding: 0;
|
|
@@ -220,7 +222,7 @@ li code {
|
|
|
220
222
|
margin-top: 15px;
|
|
221
223
|
}
|
|
222
224
|
|
|
223
|
-
|
|
225
|
+
/* Table of contents */
|
|
224
226
|
.table-of-contents {
|
|
225
227
|
page: chapter;
|
|
226
228
|
font-family: sans-serif;
|
|
@@ -229,9 +231,9 @@ li code {
|
|
|
229
231
|
.table-of-contents > h2 {
|
|
230
232
|
font-family: sans-serif;
|
|
231
233
|
margin: -100px -100px 75px -100px;
|
|
232
|
-
background:
|
|
234
|
+
background: var(--frontcover-color);
|
|
233
235
|
padding: 100px;
|
|
234
|
-
color: rgba(#fff, .6);
|
|
236
|
+
color: rgba(#fff, 0.6);
|
|
235
237
|
font-size: 40px;
|
|
236
238
|
}
|
|
237
239
|
|
|
@@ -239,10 +241,10 @@ li code {
|
|
|
239
241
|
text-decoration: none;
|
|
240
242
|
}
|
|
241
243
|
|
|
242
|
-
.table-of-contents
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
.table-of-contents .level4,
|
|
245
|
+
.table-of-contents .level5,
|
|
246
|
+
.table-of-contents .level6 {
|
|
247
|
+
display: none;
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
.table-of-contents * + .level2 {
|
|
@@ -256,13 +258,13 @@ li code {
|
|
|
256
258
|
font-size: 20px;
|
|
257
259
|
position: relative;
|
|
258
260
|
padding-left: 25px;
|
|
261
|
+
}
|
|
259
262
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
263
|
+
.table-of-contents .level2 a:before {
|
|
264
|
+
content: target-counter(attr(href), page) " ";
|
|
265
|
+
position: absolute;
|
|
266
|
+
left: 0;
|
|
267
|
+
transform: translatex(-100%);
|
|
266
268
|
}
|
|
267
269
|
|
|
268
270
|
.table-of-contents .level3 {
|
|
@@ -276,21 +278,21 @@ li code {
|
|
|
276
278
|
.table-of-contents .level3 a {
|
|
277
279
|
position: relative;
|
|
278
280
|
color: #777;
|
|
281
|
+
}
|
|
279
282
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
283
|
+
.table-of-contents .level3 a:after {
|
|
284
|
+
content: leader(".") target-counter(attr(href), page) " ";
|
|
285
|
+
cursor: default;
|
|
284
286
|
}
|
|
285
287
|
|
|
286
|
-
|
|
288
|
+
/* Footnotes */
|
|
287
289
|
.footnote {
|
|
288
290
|
display: prince-footnote;
|
|
289
291
|
footnote-style-position: inside;
|
|
290
292
|
position: footnote;
|
|
291
293
|
}
|
|
292
294
|
|
|
293
|
-
|
|
295
|
+
/* Notes */
|
|
294
296
|
.note {
|
|
295
297
|
font-size: 13px;
|
|
296
298
|
float: right;
|
|
@@ -301,7 +303,7 @@ li code {
|
|
|
301
303
|
}
|
|
302
304
|
|
|
303
305
|
.note:before {
|
|
304
|
-
content:
|
|
306
|
+
content: "!";
|
|
305
307
|
display: inline-block;
|
|
306
308
|
font-size: 25px;
|
|
307
309
|
width: 10px;
|
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
## Getting Started
|
|
2
2
|
|
|
3
|
-
This guide is designed for beginners who want to get started with Kitabu from
|
|
3
|
+
This guide is designed for beginners who want to get started with Kitabu from
|
|
4
|
+
scratch. However, to get the most out of it, you need to have some prerequisites
|
|
5
|
+
installed:
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
- The [Ruby](http://ruby-lang.org) interpreter version 2.0.0 or greater.
|
|
8
|
+
- The [PrinceXML](http://princexml.com) converter version 9.0 or greater.
|
|
9
|
+
- The [KindleGen](http://www.amazon.com/gp/feature.html?docId=1000765211)
|
|
10
|
+
converter.
|
|
8
11
|
|
|
9
12
|
### Installing Ruby
|
|
10
13
|
|
|
11
|
-
To install Ruby, consider using [RVM](http://rvm.io) or
|
|
14
|
+
To install Ruby, consider using [RVM](http://rvm.io) or
|
|
15
|
+
[rbenv](http://rbenv.org), both available for Mac OSX and Linux distros. If
|
|
16
|
+
you're running a Windows, well, I can't help you. I don't even know if Kitabu
|
|
17
|
+
runs over Windows boxes, so if you find any bugs, make sure you
|
|
18
|
+
[let me know](http://github.com/fnando/kitabu/issues).
|
|
12
19
|
|
|
13
20
|
### Installing PrinceXML
|
|
14
21
|
|
|
15
|
-
[PrinceXML](http://princexml.com) is the best HTML to PDF converter available.
|
|
22
|
+
[PrinceXML](http://princexml.com) is the best HTML to PDF converter available.
|
|
23
|
+
You can use advanced CSS features to style your book in any way you want. But
|
|
24
|
+
good things don't come for free, and PrinceXML is no exception. The Professional
|
|
25
|
+
License, which you grant you a installation on a single computer by a single
|
|
26
|
+
user costs 495USD. If you don't like the price tag, consider using
|
|
27
|
+
[DocRaptor](http://docraptor.com) when you're ready to publish your book.
|
|
16
28
|
|
|
17
|
-
To install PrinceXML, go to the website and download the correct version for
|
|
29
|
+
To install PrinceXML, go to the website and download the correct version for
|
|
30
|
+
your platform; you can choose from Mac OSX, to Linux and Windows.
|
|
18
31
|
|
|
19
32
|
### Installing KindleGen
|
|
20
33
|
|
|
21
|
-
KindleGen is the command-line tool that allows you to convert e-pubs into
|
|
34
|
+
KindleGen is the command-line tool that allows you to convert e-pubs into
|
|
35
|
+
`.mobi` files. You can't sell these files, though.[^1] So if that's the case,
|
|
36
|
+
consider using [Calibre](http://calibre-ebook.com/) for this task.[^2]
|
|
22
37
|
|
|
23
|
-
If you're running [Homebrew](http://brew.sh) on the Mac OSX, you can install it
|
|
38
|
+
If you're running [Homebrew](http://brew.sh) on the Mac OSX, you can install it
|
|
39
|
+
with `brew install kindlegen`. Go to
|
|
40
|
+
[KindleGen's website](http://www.amazon.com/gp/feature.html?docId=1000765211)
|
|
41
|
+
and download the appropriate installer otherwise.
|
|
24
42
|
|
|
25
43
|
[^1]: You can, but that would be a violation of Amazon's terms of use.
|
|
26
44
|
[^2]: Calibre is not perfect, but does a good job.
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
## Creating Chapters
|
|
2
2
|
|
|
3
|
-
You can create chapters by having multiple files or directories. They're
|
|
3
|
+
You can create chapters by having multiple files or directories. They're
|
|
4
|
+
alphabetically sorted, so make sure you use a prefixed file name like
|
|
5
|
+
`01_Introduction.md` as the file name.
|
|
4
6
|
|
|
5
|
-
If you're going to write a long book, make sure you use the directory
|
|
7
|
+
If you're going to write a long book, make sure you use the directory
|
|
8
|
+
organization. This way you can have smaller text files, which will be easier to
|
|
9
|
+
read and change as you go. A file structure suggestion for a book about
|
|
10
|
+
[Ruby on Rails](http://guides.rubyonrails.com) would be:
|
|
6
11
|
|
|
7
12
|
```text
|
|
8
13
|
getting-started-with-rails
|
|
@@ -19,4 +24,5 @@ getting-started-with-rails
|
|
|
19
24
|
└── ...
|
|
20
25
|
```
|
|
21
26
|
|
|
22
|
-
Notice that the file name does not need to be readable, but it will make your
|
|
27
|
+
Notice that the file name does not need to be readable, but it will make your
|
|
28
|
+
life easier.
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
### What about the syntax
|
|
4
4
|
|
|
5
|
-
Kitabu uses [Route](http://rubygems.org/gems/rouge) as the syntax highlight
|
|
5
|
+
Kitabu uses [Route](http://rubygems.org/gems/rouge) as the syntax highlight
|
|
6
|
+
formatter. It emits an output compatible with stylesheets designed for
|
|
7
|
+
[pygments](https://pygments.org), the Python library used by many.
|
|
6
8
|
|
|
7
|
-
To highlight a code block, use the fenced block syntax. The following example
|
|
9
|
+
To highlight a code block, use the fenced block syntax. The following example
|
|
10
|
+
would be formatted as Ruby.
|
|
8
11
|
|
|
9
12
|
```ruby
|
|
10
13
|
class User
|
|
@@ -30,9 +33,9 @@ class User
|
|
|
30
33
|
end
|
|
31
34
|
```
|
|
32
35
|
|
|
33
|
-
<% note do %>
|
|
34
|
-
|
|
35
|
-
<% end %>
|
|
36
|
+
<% note do %> If you're using Sublime Text, make sure you install the
|
|
37
|
+
[Markdown Extended](https://packagecontrol.io/packages/Markdown%20Extended)
|
|
38
|
+
plugin; it enables code syntax highlighting on your Markdown files. <% end %>
|
|
36
39
|
|
|
37
40
|
You can also provide inline options such as line numbers and inline rendering.
|
|
38
41
|
|
|
@@ -62,8 +65,10 @@ end
|
|
|
62
65
|
|
|
63
66
|
### Lexers
|
|
64
67
|
|
|
65
|
-
Rouge comes with dozens of lexers. Check out this list, generated dynamically
|
|
68
|
+
Rouge comes with dozens of lexers. Check out this list, generated dynamically
|
|
69
|
+
when you export your e-book.
|
|
66
70
|
|
|
67
71
|
<%= lexers_list %>
|
|
68
72
|
|
|
69
|
-
And if what you want is not on this list, make you
|
|
73
|
+
And if what you want is not on this list, make you
|
|
74
|
+
[open a ticket](https://github.com/jneen/rouge/issues) on the project.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## Dynamic Content
|
|
2
|
+
|
|
3
|
+
Sometimes you may find useful to generate content dynamically. Maybe you're
|
|
4
|
+
going to read some configuration file, or maybe you just want to define some
|
|
5
|
+
helpers. Kitabu has support for ERb files; all you need to do is naming your
|
|
6
|
+
text file as `.md.erb`.
|
|
7
|
+
|
|
8
|
+
On the previous chapter, we listed all supported Rouge lexers. To do that, I
|
|
9
|
+
created a helper that looks like this:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
<%= File.read("./config/helper.rb") %>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
To use it, I just needed to add `<%%= lexers_list %>` to my text file. This
|
|
16
|
+
allows you to create anything you need!
|
|
17
|
+
|
|
18
|
+
Kitabu comes with some built-in helpers, such as `note`. With this helper, you
|
|
19
|
+
can create a note that generates a HTML structure, so you can easily style it.
|
|
20
|
+
The syntax for using the `note` helper is `note(type, &block)`.
|
|
21
|
+
|
|
22
|
+
```erb
|
|
23
|
+
<%% note do %>
|
|
24
|
+
Some text that will be parsed as Markdown.
|
|
25
|
+
<%% end %>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
By default, this will generate a `<div class="note info">` tag, but you can use
|
|
29
|
+
anything you want.
|
|
30
|
+
|
|
31
|
+
```erb
|
|
32
|
+
<%% note :warning do %>
|
|
33
|
+
Some text that will be parsed as Markdown.
|
|
34
|
+
<%% end %>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
[Check out the source](https://github.com/fnando/kitabu/blob/cleanup/lib/kitabu/helpers.rb)
|
|
38
|
+
for a sample on how to create block helpers like `note`.
|
|
39
|
+
|
|
40
|
+
### Escaping ERb code
|
|
41
|
+
|
|
42
|
+
If you want to write a book about Rails, you're likely to use lots of ERb tags.
|
|
43
|
+
In this case, make sure you escape the `<%% %>` and `<%%= %>` markers as
|
|
44
|
+
`<%%% %>` and `<%%%= %>`; otherwise you'll have a syntax error.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
<%%%= Date.today %>
|
|
48
|
+
```
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
## Exporting Files
|
|
2
2
|
|
|
3
|
-
You can generate files as you go. Just execute `kitabu export` from your book's
|
|
3
|
+
You can generate files as you go. Just execute `kitabu export` from your book's
|
|
4
|
+
root directory.
|
|
4
5
|
|
|
5
6
|
```
|
|
6
7
|
$ kitabu export
|
|
7
8
|
** e-book has been exported
|
|
8
9
|
```
|
|
9
10
|
|
|
10
|
-
This command will generate all supported formats[^1]. The generated files will
|
|
11
|
+
This command will generate all supported formats[^1]. The generated files will
|
|
12
|
+
be placed on your `output` directory; the following output list only the
|
|
13
|
+
relevant files.
|
|
11
14
|
|
|
12
15
|
```
|
|
13
16
|
$ tree output
|
|
@@ -20,7 +23,6 @@ output
|
|
|
20
23
|
├── kitabu.mobi
|
|
21
24
|
├── kitabu.pdf
|
|
22
25
|
├── kitabu.print.pdf
|
|
23
|
-
├── kitabu.txt
|
|
24
26
|
└── styles
|
|
25
27
|
├── epub.css
|
|
26
28
|
├── html.css
|
|
@@ -28,22 +30,29 @@ output
|
|
|
28
30
|
└── print.css
|
|
29
31
|
```
|
|
30
32
|
|
|
31
|
-
This can take a while depending on your book size, but usually the process is
|
|
33
|
+
This can take a while depending on your book size, but usually the process is
|
|
34
|
+
pretty fast. If you want to generate a specific format faster, provide the
|
|
35
|
+
`--only` flag.
|
|
32
36
|
|
|
33
37
|
```
|
|
34
38
|
$ kitabu export --only pdf
|
|
35
39
|
```
|
|
36
40
|
|
|
37
|
-
You can also automatically generate files when something changes. You can use
|
|
41
|
+
You can also automatically generate files when something changes. You can use
|
|
42
|
+
[Guard](http://rubygems.org/gems/guard) for this, and Kitabu even generates a
|
|
43
|
+
sample file for you. All you have to do is running `bundle exec guard`.
|
|
38
44
|
|
|
39
45
|
```
|
|
40
46
|
$ bundle exec guard
|
|
41
|
-
20:38:10 - INFO - Guard is now watching at '
|
|
47
|
+
20:38:10 - INFO - Guard is now watching at 'kitabu/examples/kitabu'
|
|
42
48
|
** e-book has been exported
|
|
43
49
|
```
|
|
44
50
|
|
|
45
51
|
### Exporting PDF with DocRaptor
|
|
46
52
|
|
|
47
|
-
After exporting your files (you can use `--only pdf` for this), upload files to
|
|
53
|
+
After exporting your files (you can use `--only pdf` for this), upload files to
|
|
54
|
+
somewhere public, possibly your [Dropbox](http://dropbox.com) account. You can
|
|
55
|
+
even use curl; since the command is quite long, you can view it at
|
|
56
|
+
<https://gist.github.com/fnando/de555a08e7aab14a661a>.
|
|
48
57
|
|
|
49
|
-
[^1]: Depend on Prince
|
|
58
|
+
[^1]: Depend on Prince and Calibre being available on your `$PATH`.
|