kitabu 1.0.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -3
- data/.travis.yml +18 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +67 -50
- data/README.md +235 -0
- data/attachments/browser-version.png +0 -0
- data/attachments/cover.png +0 -0
- data/attachments/kitabu.epub +0 -0
- data/attachments/kitabu.mobi +0 -0
- data/attachments/kitabu.pdf +0 -0
- data/{spec/support/mybook/output → examples/kitabu/output/epub/images}/.gitkeep +0 -0
- data/examples/kitabu/output/epub/images/kitabu-icon.png +0 -0
- data/examples/kitabu/output/epub/images/kitabu-icon.svg +19 -0
- data/examples/kitabu/output/epub/images/kitabu-word.png +0 -0
- data/examples/kitabu/output/epub/images/kitabu-word.svg +14 -0
- data/examples/kitabu/output/epub/images/kitabu.png +0 -0
- data/examples/kitabu/output/epub/images/kitabu.svg +20 -0
- data/examples/kitabu/output/epub/section_0.html +266 -0
- data/examples/kitabu/output/epub/section_1.html +246 -0
- data/examples/kitabu/output/epub/section_2.html +520 -0
- data/examples/kitabu/output/epub/section_3.html +282 -0
- data/examples/kitabu/output/epub/section_4.html +276 -0
- data/examples/kitabu/output/epub/styles/epub.css +437 -0
- data/examples/kitabu/output/epub/styles/html.css +712 -0
- data/examples/kitabu/output/epub/styles/pdf.css +840 -0
- data/examples/kitabu/output/epub/styles/print.css +1278 -0
- data/examples/kitabu/output/epub/toc.html +37 -0
- data/{spec/support/mybook/templates/epub/style.css → examples/kitabu/output/images/.gitkeep} +0 -0
- data/examples/kitabu/output/images/kitabu-icon.png +0 -0
- data/examples/kitabu/output/images/kitabu-icon.svg +19 -0
- data/examples/kitabu/output/images/kitabu-word.png +0 -0
- data/examples/kitabu/output/images/kitabu-word.svg +14 -0
- data/examples/kitabu/output/images/kitabu.png +0 -0
- data/examples/kitabu/output/images/kitabu.svg +20 -0
- data/examples/kitabu/output/kitabu.epub +0 -0
- data/examples/kitabu/output/kitabu.html +513 -0
- data/examples/kitabu/output/kitabu.mobi +0 -0
- data/examples/kitabu/output/kitabu.pdf +0 -0
- data/examples/kitabu/output/kitabu.pdf.html +729 -0
- data/examples/kitabu/output/kitabu.print.html +729 -0
- data/examples/kitabu/output/kitabu.print.pdf +0 -0
- data/examples/kitabu/output/kitabu.txt +440 -0
- data/examples/kitabu/output/styles/epub.css +437 -0
- data/examples/kitabu/output/styles/html.css +712 -0
- data/examples/kitabu/output/styles/pdf.css +840 -0
- data/examples/kitabu/output/styles/print.css +1278 -0
- data/kitabu.gemspec +7 -5
- data/lib/kitabu.rb +10 -20
- data/lib/kitabu/cli.rb +0 -5
- data/lib/kitabu/dependency.rb +0 -4
- data/lib/kitabu/exporter.rb +2 -0
- data/lib/kitabu/extensions/rouge.rb +9 -0
- data/lib/kitabu/generator.rb +9 -21
- data/lib/kitabu/helpers.rb +47 -0
- data/lib/kitabu/markdown.rb +31 -0
- data/lib/kitabu/parser.rb +21 -3
- data/lib/kitabu/parser/epub.rb +31 -18
- data/lib/kitabu/parser/html.rb +48 -29
- data/lib/kitabu/parser/mobi.rb +1 -1
- data/lib/kitabu/parser/pdf.rb +52 -8
- data/lib/kitabu/version.rb +2 -2
- data/spec/kitabu/cli/export_spec.rb +4 -4
- data/spec/kitabu/cli/new_spec.rb +2 -2
- data/spec/kitabu/markdown_spec.rb +24 -0
- data/spec/kitabu/parser/html_spec.rb +20 -25
- data/spec/kitabu/parser/mobi_spec.rb +14 -0
- data/spec/kitabu/parser/pdf_spec.rb +18 -1
- data/spec/kitabu/parser/txt_spec.rb +14 -0
- data/spec/spec_helper.rb +10 -6
- data/spec/support/mybook/config/helper.rb +4 -29
- data/spec/support/mybook/config/kitabu.yml +0 -10
- data/spec/support/mybook/templates/epub/cover.erb +4 -3
- data/{templates → spec/support/mybook/templates/epub}/cover.png +0 -0
- data/spec/support/mybook/templates/epub/page.erb +3 -2
- data/spec/support/mybook/templates/html/layout.erb +10 -13
- data/spec/support/mybook/templates/styles/epub.scss +3 -0
- data/spec/support/mybook/templates/styles/html.scss +3 -0
- data/spec/support/mybook/templates/styles/pdf.scss +3 -0
- data/spec/support/mybook/templates/styles/print.scss +3 -0
- data/spec/support/mybook/text/{01_Markdown_Chapter.markdown → 01_Markdown_Chapter.md} +2 -3
- data/spec/support/mybook/text/02_ERB_Chapter.md.erb +7 -0
- data/spec/support/mybook/text/{04_With_Directory/Some_Chapter.mkdn → 03_With_Directory/Some_Chapter.md} +0 -0
- data/spec/support/mybook/text/{CHANGELOG.textile → CHANGELOG.md} +2 -2
- data/spec/support/mybook/text/{TOC.textile → TOC.md} +0 -0
- data/spec/support/mybook/text/{_00_Introduction.markdown → _00_Introduction.md} +0 -0
- data/spec/support/shared.rb +14 -10
- data/templates/Gemfile +3 -3
- data/templates/Guardfile +1 -5
- data/templates/config.erb +5 -5
- data/templates/cover.erb +4 -3
- data/templates/epub.erb +3 -2
- data/templates/helper.rb +28 -29
- data/templates/images/.gitkeep +0 -0
- data/templates/images/kitabu-icon.png +0 -0
- data/templates/images/kitabu-icon.svg +19 -0
- data/templates/images/kitabu-word.png +0 -0
- data/templates/images/kitabu-word.svg +14 -0
- data/templates/images/kitabu.png +0 -0
- data/templates/images/kitabu.svg +20 -0
- data/{examples/RailsGuides/templates → templates/templates/epub}/cover.erb +4 -3
- data/templates/templates/epub/cover.png +0 -0
- data/templates/templates/epub/page.erb +16 -0
- data/templates/{layout.erb → templates/html/layout.erb} +22 -11
- data/templates/templates/styles/epub.scss +1 -0
- data/templates/templates/styles/files/_normalize.scss +427 -0
- data/templates/templates/styles/html.scss +252 -0
- data/templates/templates/styles/pdf.scss +371 -0
- data/templates/templates/styles/print.scss +2 -0
- data/templates/text/01_Getting_Started.md +26 -0
- data/templates/text/02_Creating_Chapters.md +22 -0
- data/templates/text/03_Syntax_Highlighting.erb +69 -0
- data/templates/text/04_Dynamic_Content.erb +64 -0
- data/templates/text/05_Exporting_Files.md +49 -0
- metadata +143 -83
- data/README.rdoc +0 -218
- data/examples/RailsGuides/config/helper.rb +0 -29
- data/examples/RailsGuides/config/kitabu.yml +0 -44
- data/examples/RailsGuides/images/challenge.png +0 -0
- data/examples/RailsGuides/images/posts_index.png +0 -0
- data/examples/RailsGuides/images/rails_welcome.png +0 -0
- data/examples/RailsGuides/output/RailsGuides.epub +0 -0
- data/examples/RailsGuides/output/RailsGuides.html +0 -1556
- data/examples/RailsGuides/output/RailsGuides.pdf +3 -4934
- data/examples/RailsGuides/templates/layout.css +0 -352
- data/examples/RailsGuides/templates/layout.erb +0 -43
- data/examples/RailsGuides/templates/syntax.css +0 -62
- data/examples/RailsGuides/templates/user.css +0 -19
- data/examples/RailsGuides/text/01_Guide_Assumptions.mkdn +0 -13
- data/examples/RailsGuides/text/02_What_is_Rails.mkdn +0 -106
- data/examples/RailsGuides/text/03_Creating_a_new_Rails_project.mkdn +0 -200
- data/examples/RailsGuides/text/04_Hello_Rails.mkdn +0 -62
- data/examples/RailsGuides/text/05_Getting_Up_and_Running_Quickly_with_Scaffolding.mkdn +0 -4
- data/examples/RailsGuides/text/06_Creating_a_resource.mkdn +0 -503
- data/examples/RailsGuides/text/07_Adding_a_second_model.mkdn +0 -232
- data/examples/RailsGuides/text/08_Refactoring.mkdn +0 -123
- data/examples/RailsGuides/text/09_Deleting_comments.mkdn +0 -57
- data/examples/RailsGuides/text/09_Security.mkdn +0 -56
- data/examples/RailsGuides/text/10_Building_a_multi_model_form.mkdn +0 -130
- data/examples/RailsGuides/text/11_View_helpers.mkdn +0 -50
- data/examples/RailsGuides/text/12_Whats_next.mkdn +0 -14
- data/examples/RailsGuides/text/13_Configuration_gotchas.mkdn +0 -10
- data/lib/kitabu/adapters/markdown.rb +0 -34
- data/lib/kitabu/extensions/redcloth.rb +0 -69
- data/lib/kitabu/syntax.rb +0 -130
- data/spec/kitabu/extensions/redcloth_spec.rb +0 -57
- data/spec/kitabu/syntax_spec.rb +0 -106
- data/spec/support/mybook/templates/html/layout.css +0 -353
- data/spec/support/mybook/templates/html/syntax.css +0 -58
- data/spec/support/mybook/templates/html/user.css +0 -1
- data/spec/support/mybook/text/02_Textile_Chapter.textile +0 -3
- data/spec/support/mybook/text/03_HTML_Chapter.html +0 -3
- data/templates/epub.css +0 -500
- data/templates/layout.css +0 -353
- data/templates/sample.md +0 -6
- data/templates/syntax.css +0 -58
- data/templates/user.css +0 -1
@@ -0,0 +1,37 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
3
|
+
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
6
|
+
<link rel="stylesheet" type="text/css" href="epub.css"/>
|
7
|
+
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
|
8
|
+
<title>Table of Contents</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="toc">
|
12
|
+
<ul>
|
13
|
+
|
14
|
+
<li>
|
15
|
+
<a href="section_0.html">Getting Started</a>
|
16
|
+
</li>
|
17
|
+
|
18
|
+
<li>
|
19
|
+
<a href="section_1.html">Creating Chapters</a>
|
20
|
+
</li>
|
21
|
+
|
22
|
+
<li>
|
23
|
+
<a href="section_2.html">Syntax Highlighting</a>
|
24
|
+
</li>
|
25
|
+
|
26
|
+
<li>
|
27
|
+
<a href="section_3.html">Dynamic Content</a>
|
28
|
+
</li>
|
29
|
+
|
30
|
+
<li>
|
31
|
+
<a href="section_4.html">Exporting Files</a>
|
32
|
+
</li>
|
33
|
+
|
34
|
+
</ul>
|
35
|
+
</div>
|
36
|
+
</body>
|
37
|
+
</html>
|
data/{spec/support/mybook/templates/epub/style.css → examples/kitabu/output/images/.gitkeep}
RENAMED
File without changes
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg width="79px" height="108px" viewBox="0 0 79 108" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
3
|
+
<!-- Generator: Sketch 3.2.2 (9983) - http://www.bohemiancoding.com/sketch -->
|
4
|
+
<title>kitabu-icon</title>
|
5
|
+
<desc>Created with Sketch.</desc>
|
6
|
+
<defs></defs>
|
7
|
+
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
8
|
+
<g id="Artboard-1" sketch:type="MSArtboardGroup" transform="translate(-731.000000, -27.000000)" fill="#FFFFFF">
|
9
|
+
<g id="kitabu-icon" sketch:type="MSLayerGroup" transform="translate(731.000000, 27.000000)">
|
10
|
+
<g id="icon" transform="translate(0.895522, 0.000000)" sketch:type="MSShapeGroup">
|
11
|
+
<path d="M22.5432836,0.158684932 L22.5432836,0.225876712 L0.0402985075,22.6918219 L0.0402985075,107.69689 L77.9477612,107.69689 L77.9477612,0.158684932 L22.5432836,0.158684932 L22.5432836,0.158684932 Z M68.9925373,98.7379863 L8.99552239,98.7379863 L8.99552239,31.650726 L31.4985075,31.650726 L31.4985075,9.11758904 L68.9925373,9.11758904 L68.9925373,98.7379863 L68.9925373,98.7379863 Z" id="Fill-811"></path>
|
12
|
+
<path d="M16.9567164,41.0710137 L53.0014925,41.0710137 L53.0014925,48.2246986 L16.9567164,48.2246986 L16.9567164,41.0710137 Z" id="Fill-812"></path>
|
13
|
+
<path d="M16.9567164,57.1895753 L42.4641791,57.1895753 L42.4641791,64.3432603 L16.9567164,64.3432603 L16.9567164,57.1895753 Z" id="Fill-813"></path>
|
14
|
+
<path d="M16.9567164,73.2006301 L60.7552239,73.2006301 L60.7552239,80.3543151 L16.9567164,80.3543151 L16.9567164,73.2006301 Z" id="Fill-814"></path>
|
15
|
+
</g>
|
16
|
+
</g>
|
17
|
+
</g>
|
18
|
+
</g>
|
19
|
+
</svg>
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg width="197px" height="63px" viewBox="0 0 197 63" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
3
|
+
<!-- Generator: Sketch 3.2.2 (9983) - http://www.bohemiancoding.com/sketch -->
|
4
|
+
<title>kitabu-word</title>
|
5
|
+
<desc>Created with Sketch.</desc>
|
6
|
+
<defs></defs>
|
7
|
+
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
8
|
+
<g id="Artboard-1" sketch:type="MSArtboardGroup" transform="translate(-76.000000, -61.000000)" fill="#FFFFFF">
|
9
|
+
<g id="kitabu-word" sketch:type="MSLayerGroup" transform="translate(76.000000, 61.000000)">
|
10
|
+
<path d="M28.5288568,61.6462919 C30.9812881,61.6462919 32.9263198,59.7041663 32.9263198,57.2553991 C32.9263198,56.4109967 32.67262,55.482154 31.9960872,54.5533113 L19.5647976,38.2563439 L30.6430217,29.8123193 C31.7423874,28.9679169 32.3343536,27.6168729 32.3343536,26.3502692 C32.3343536,23.9015021 30.3893219,21.9593765 27.9368906,21.9593765 C26.9220914,21.9593765 26.0764255,22.2126972 24.9770597,23.0570997 L9.67050582,35.0476145 L9.67050582,5.24020784 C9.67050582,2.70700047 7.64090751,0.849315068 5.10390963,0.849315068 C2.48234515,0.849315068 0.537313433,2.70700047 0.537313433,5.24020784 L0.537313433,57.2553991 C0.537313433,59.7886065 2.48234515,61.6462919 5.10390963,61.6462919 C7.64090751,61.6462919 9.67050582,59.7886065 9.67050582,57.2553991 L9.67050582,45.0960038 L12.3766369,42.9849976 L24.9770597,59.8730468 C25.7381591,60.8863297 26.9220914,61.6462919 28.5288568,61.6462919 L28.5288568,61.6462919 Z M47.9791739,26.5191497 C47.9791739,23.9859424 45.9495756,21.9593765 43.4125777,21.9593765 C40.8755798,21.9593765 38.8459815,23.9859424 38.8459815,26.5191497 L38.8459815,57.0865187 C38.8459815,59.619726 40.8755798,61.6462919 43.4125777,61.6462919 C45.9495756,61.6462919 47.9791739,59.619726 47.9791739,57.0865187 L47.9791739,26.5191497 Z M43.4125777,17.3996032 C46.9643747,17.3996032 48.9094065,15.3730373 48.9094065,12.0798677 C48.9094065,8.19561644 46.9643747,6.50681153 43.4125777,6.50681153 C39.9453473,6.50681153 38.0003155,8.19561644 38.0003155,12.0798677 C38.0003155,15.3730373 39.9453473,17.3996032 43.4125777,17.3996032 L43.4125777,17.3996032 Z M59.3956644,22.6348984 L57.4506327,22.6348984 C55.3364678,22.6348984 53.6451358,24.3237034 53.6451358,26.4347095 C53.6451358,28.5457156 55.3364678,30.2345205 57.4506327,30.2345205 L59.3956644,30.2345205 L59.3956644,50.1624185 C59.3956644,56.8331979 64.0468272,61.6462919 71.5732542,61.6462919 C73.7719857,61.6462919 75.5478843,59.8730468 75.5478843,57.6776004 C75.5478843,55.482154 73.7719857,53.7089088 71.5732542,53.7089088 C70.0510555,53.7089088 68.3597236,52.6111856 68.3597236,50.66906 L68.3597236,30.2345205 L72.1652204,30.2345205 C74.2793853,30.2345205 75.9707172,28.5457156 75.9707172,26.4347095 C75.9707172,24.3237034 74.2793853,22.6348984 72.1652204,22.6348984 L68.3597236,22.6348984 L68.3597236,15.5419178 C68.3597236,13.0931507 66.3301253,11.0665848 63.877694,11.0665848 C61.4252627,11.0665848 59.3956644,13.0931507 59.3956644,15.5419178 L59.3956644,22.6348984 Z M97.4506327,29.5589986 C102.355495,29.5589986 105.146193,32.092206 105.146193,35.892017 L105.146193,37.4119414 L94.0679688,37.4119414 C86.710675,37.4119414 80.3681802,41.4650732 80.3681802,49.3180161 C80.3681802,56.9176382 85.865009,62.0684932 94.1525354,62.0684932 C99.2265312,62.0684932 102.947461,60.8018895 105.23076,57.1709589 C105.23076,59.619726 107.260358,61.6462919 109.712789,61.6462919 C112.16522,61.6462919 114.194819,59.619726 114.194819,57.1709589 L114.194819,35.554256 C114.194819,26.60359 107.936891,21.452735 97.4506327,21.452735 C90.1779054,21.452735 85.9495756,24.2392631 83.5817109,26.8569107 C82.8206115,27.7013132 82.4823451,28.7145961 82.4823451,29.6434388 C82.4823451,31.8388852 84.2582437,33.6121304 86.4569752,33.6121304 C87.4717743,33.6121304 88.1483071,33.3588096 88.9939731,32.7677279 C91.108138,31.2478035 93.7297024,29.5589986 97.4506327,29.5589986 L97.4506327,29.5589986 Z M96.5204001,54.468871 C91.7846707,54.468871 89.5013726,52.5267454 89.5013726,49.3180161 C89.5013726,46.2781672 91.5309709,44.5049221 95.2519012,44.5049221 L105.146193,44.5049221 L105.146193,46.8692489 C105.146193,51.5979027 101.00243,54.468871 96.5204001,54.468871 L96.5204001,54.468871 Z M131.361838,33.5276901 C131.361838,33.5276901 134.659935,29.2212376 139.733931,29.2212376 C145.484459,29.2212376 148.782557,33.4432499 148.782557,41.8028342 C148.782557,50.0779783 145.569026,54.2999906 139.733931,54.2999906 C134.829068,54.2999906 131.361838,51.006821 131.361838,45.180444 L131.361838,33.5276901 Z M140.664163,21.452735 C136.604967,21.452735 133.05317,23.1415399 131.361838,24.8303448 L131.361838,5.40908833 C131.361838,2.87588096 129.332239,0.849315068 126.795242,0.849315068 C124.258244,0.849315068 122.228645,2.87588096 122.228645,5.40908833 L122.228645,45.180444 C122.228645,56.4109967 129.501373,62.0684932 139.733931,62.0684932 C151.150421,62.0684932 157.831182,55.5665942 157.831182,41.8028342 C157.831182,28.0390742 151.319554,21.452735 140.664163,21.452735 L140.664163,21.452735 Z M167.894607,21.9593765 C165.357609,21.9593765 163.328011,23.9859424 163.328011,26.5191497 L163.328011,46.193727 C163.328011,54.468871 166.456975,62.0684932 180.072197,62.0684932 C193.602853,62.0684932 196.731817,54.468871 196.731817,46.193727 L196.731817,26.5191497 C196.731817,23.9859424 194.702218,21.9593765 192.16522,21.9593765 C189.628223,21.9593765 187.598624,23.9859424 187.598624,26.5191497 L187.598624,46.193727 C187.598624,50.0779783 186.245559,53.7933491 180.072197,53.7933491 C173.814269,53.7933491 172.461203,50.0779783 172.461203,46.193727 L172.461203,26.5191497 C172.461203,23.9859424 170.431605,21.9593765 167.894607,21.9593765 L167.894607,21.9593765 Z" id="kitabu" sketch:type="MSShapeGroup"></path>
|
11
|
+
</g>
|
12
|
+
</g>
|
13
|
+
</g>
|
14
|
+
</svg>
|
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg width="299px" height="108px" viewBox="0 0 299 108" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
|
3
|
+
<!-- Generator: Sketch 3.2.2 (9983) - http://www.bohemiancoding.com/sketch -->
|
4
|
+
<title>kitabu</title>
|
5
|
+
<desc>Created with Sketch.</desc>
|
6
|
+
<defs></defs>
|
7
|
+
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
|
8
|
+
<g id="Artboard-1" sketch:type="MSArtboardGroup" transform="translate(-306.000000, -171.000000)" fill="#FFFFFF">
|
9
|
+
<g id="kitabu" sketch:type="MSLayerGroup" transform="translate(306.000000, 171.000000)">
|
10
|
+
<g id="icon" transform="translate(220.895522, 0.000000)" sketch:type="MSShapeGroup">
|
11
|
+
<path d="M22.5432836,0.158684932 L22.5432836,0.225876712 L0.0402985075,22.6918219 L0.0402985075,107.69689 L77.9477612,107.69689 L77.9477612,0.158684932 L22.5432836,0.158684932 L22.5432836,0.158684932 Z M68.9925373,98.7379863 L8.99552239,98.7379863 L8.99552239,31.650726 L31.4985075,31.650726 L31.4985075,9.11758904 L68.9925373,9.11758904 L68.9925373,98.7379863 L68.9925373,98.7379863 Z" id="Fill-811"></path>
|
12
|
+
<path d="M16.9567164,41.0710137 L53.0014925,41.0710137 L53.0014925,48.2246986 L16.9567164,48.2246986 L16.9567164,41.0710137 Z" id="Fill-812"></path>
|
13
|
+
<path d="M16.9567164,57.1895753 L42.4641791,57.1895753 L42.4641791,64.3432603 L16.9567164,64.3432603 L16.9567164,57.1895753 Z" id="Fill-813"></path>
|
14
|
+
<path d="M16.9567164,73.2006301 L60.7552239,73.2006301 L60.7552239,80.3543151 L16.9567164,80.3543151 L16.9567164,73.2006301 Z" id="Fill-814"></path>
|
15
|
+
</g>
|
16
|
+
<path d="M28.5288568,92.6462919 C30.9812881,92.6462919 32.9263198,90.7041663 32.9263198,88.2553991 C32.9263198,87.4109967 32.67262,86.482154 31.9960872,85.5533113 L19.5647976,69.2563439 L30.6430217,60.8123193 C31.7423874,59.9679169 32.3343536,58.6168729 32.3343536,57.3502692 C32.3343536,54.9015021 30.3893219,52.9593765 27.9368906,52.9593765 C26.9220914,52.9593765 26.0764255,53.2126972 24.9770597,54.0570997 L9.67050582,66.0476145 L9.67050582,36.2402078 C9.67050582,33.7070005 7.64090751,31.8493151 5.10390963,31.8493151 C2.48234515,31.8493151 0.537313433,33.7070005 0.537313433,36.2402078 L0.537313433,88.2553991 C0.537313433,90.7886065 2.48234515,92.6462919 5.10390963,92.6462919 C7.64090751,92.6462919 9.67050582,90.7886065 9.67050582,88.2553991 L9.67050582,76.0960038 L12.3766369,73.9849976 L24.9770597,90.8730468 C25.7381591,91.8863297 26.9220914,92.6462919 28.5288568,92.6462919 L28.5288568,92.6462919 Z M47.9791739,57.5191497 C47.9791739,54.9859424 45.9495756,52.9593765 43.4125777,52.9593765 C40.8755798,52.9593765 38.8459815,54.9859424 38.8459815,57.5191497 L38.8459815,88.0865187 C38.8459815,90.619726 40.8755798,92.6462919 43.4125777,92.6462919 C45.9495756,92.6462919 47.9791739,90.619726 47.9791739,88.0865187 L47.9791739,57.5191497 Z M43.4125777,48.3996032 C46.9643747,48.3996032 48.9094065,46.3730373 48.9094065,43.0798677 C48.9094065,39.1956164 46.9643747,37.5068115 43.4125777,37.5068115 C39.9453473,37.5068115 38.0003155,39.1956164 38.0003155,43.0798677 C38.0003155,46.3730373 39.9453473,48.3996032 43.4125777,48.3996032 L43.4125777,48.3996032 Z M59.3956644,53.6348984 L57.4506327,53.6348984 C55.3364678,53.6348984 53.6451358,55.3237034 53.6451358,57.4347095 C53.6451358,59.5457156 55.3364678,61.2345205 57.4506327,61.2345205 L59.3956644,61.2345205 L59.3956644,81.1624185 C59.3956644,87.8331979 64.0468272,92.6462919 71.5732542,92.6462919 C73.7719857,92.6462919 75.5478843,90.8730468 75.5478843,88.6776004 C75.5478843,86.482154 73.7719857,84.7089088 71.5732542,84.7089088 C70.0510555,84.7089088 68.3597236,83.6111856 68.3597236,81.66906 L68.3597236,61.2345205 L72.1652204,61.2345205 C74.2793853,61.2345205 75.9707172,59.5457156 75.9707172,57.4347095 C75.9707172,55.3237034 74.2793853,53.6348984 72.1652204,53.6348984 L68.3597236,53.6348984 L68.3597236,46.5419178 C68.3597236,44.0931507 66.3301253,42.0665848 63.877694,42.0665848 C61.4252627,42.0665848 59.3956644,44.0931507 59.3956644,46.5419178 L59.3956644,53.6348984 Z M97.4506327,60.5589986 C102.355495,60.5589986 105.146193,63.092206 105.146193,66.892017 L105.146193,68.4119414 L94.0679688,68.4119414 C86.710675,68.4119414 80.3681802,72.4650732 80.3681802,80.3180161 C80.3681802,87.9176382 85.865009,93.0684932 94.1525354,93.0684932 C99.2265312,93.0684932 102.947461,91.8018895 105.23076,88.1709589 C105.23076,90.619726 107.260358,92.6462919 109.712789,92.6462919 C112.16522,92.6462919 114.194819,90.619726 114.194819,88.1709589 L114.194819,66.554256 C114.194819,57.60359 107.936891,52.452735 97.4506327,52.452735 C90.1779054,52.452735 85.9495756,55.2392631 83.5817109,57.8569107 C82.8206115,58.7013132 82.4823451,59.7145961 82.4823451,60.6434388 C82.4823451,62.8388852 84.2582437,64.6121304 86.4569752,64.6121304 C87.4717743,64.6121304 88.1483071,64.3588096 88.9939731,63.7677279 C91.108138,62.2478035 93.7297024,60.5589986 97.4506327,60.5589986 L97.4506327,60.5589986 Z M96.5204001,85.468871 C91.7846707,85.468871 89.5013726,83.5267454 89.5013726,80.3180161 C89.5013726,77.2781672 91.5309709,75.5049221 95.2519012,75.5049221 L105.146193,75.5049221 L105.146193,77.8692489 C105.146193,82.5979027 101.00243,85.468871 96.5204001,85.468871 L96.5204001,85.468871 Z M131.361838,64.5276901 C131.361838,64.5276901 134.659935,60.2212376 139.733931,60.2212376 C145.484459,60.2212376 148.782557,64.4432499 148.782557,72.8028342 C148.782557,81.0779783 145.569026,85.2999906 139.733931,85.2999906 C134.829068,85.2999906 131.361838,82.006821 131.361838,76.180444 L131.361838,64.5276901 Z M140.664163,52.452735 C136.604967,52.452735 133.05317,54.1415399 131.361838,55.8303448 L131.361838,36.4090883 C131.361838,33.875881 129.332239,31.8493151 126.795242,31.8493151 C124.258244,31.8493151 122.228645,33.875881 122.228645,36.4090883 L122.228645,76.180444 C122.228645,87.4109967 129.501373,93.0684932 139.733931,93.0684932 C151.150421,93.0684932 157.831182,86.5665942 157.831182,72.8028342 C157.831182,59.0390742 151.319554,52.452735 140.664163,52.452735 L140.664163,52.452735 Z M167.894607,52.9593765 C165.357609,52.9593765 163.328011,54.9859424 163.328011,57.5191497 L163.328011,77.193727 C163.328011,85.468871 166.456975,93.0684932 180.072197,93.0684932 C193.602853,93.0684932 196.731817,85.468871 196.731817,77.193727 L196.731817,57.5191497 C196.731817,54.9859424 194.702218,52.9593765 192.16522,52.9593765 C189.628223,52.9593765 187.598624,54.9859424 187.598624,57.5191497 L187.598624,77.193727 C187.598624,81.0779783 186.245559,84.7933491 180.072197,84.7933491 C173.814269,84.7933491 172.461203,81.0779783 172.461203,77.193727 L172.461203,57.5191497 C172.461203,54.9859424 170.431605,52.9593765 167.894607,52.9593765 L167.894607,52.9593765 Z" sketch:type="MSShapeGroup"></path>
|
17
|
+
</g>
|
18
|
+
</g>
|
19
|
+
</g>
|
20
|
+
</svg>
|
Binary file
|
@@ -0,0 +1,513 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html class="html">
|
3
|
+
<head>
|
4
|
+
<title>Kitabu</title>
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
6
|
+
<link name="stylesheet" rel="stylesheet" type="text/css" href="styles/html.css" />
|
7
|
+
<meta name="author" content="Nando Vieira" />
|
8
|
+
<meta name="subject" content="This guide will help you understand how all of the pieces fit together on Kitabu." />
|
9
|
+
<meta name="keywords" content="[Your book keywords (comma-separated)]" />
|
10
|
+
<meta name="date" content="2015-03-13" />
|
11
|
+
<style type="text/css">.highlight table td { padding: 5px; }
|
12
|
+
.highlight table pre { margin: 0; }
|
13
|
+
.highlight .cm {
|
14
|
+
color: #999988;
|
15
|
+
font-style: italic;
|
16
|
+
}
|
17
|
+
.highlight .cp {
|
18
|
+
color: #999999;
|
19
|
+
font-weight: bold;
|
20
|
+
}
|
21
|
+
.highlight .c1 {
|
22
|
+
color: #999988;
|
23
|
+
font-style: italic;
|
24
|
+
}
|
25
|
+
.highlight .cs {
|
26
|
+
color: #999999;
|
27
|
+
font-weight: bold;
|
28
|
+
font-style: italic;
|
29
|
+
}
|
30
|
+
.highlight .c, .highlight .cd {
|
31
|
+
color: #999988;
|
32
|
+
font-style: italic;
|
33
|
+
}
|
34
|
+
.highlight .err {
|
35
|
+
color: #a61717;
|
36
|
+
background-color: #e3d2d2;
|
37
|
+
}
|
38
|
+
.highlight .gd {
|
39
|
+
color: #000000;
|
40
|
+
background-color: #ffdddd;
|
41
|
+
}
|
42
|
+
.highlight .ge {
|
43
|
+
color: #000000;
|
44
|
+
font-style: italic;
|
45
|
+
}
|
46
|
+
.highlight .gr {
|
47
|
+
color: #aa0000;
|
48
|
+
}
|
49
|
+
.highlight .gh {
|
50
|
+
color: #999999;
|
51
|
+
}
|
52
|
+
.highlight .gi {
|
53
|
+
color: #000000;
|
54
|
+
background-color: #ddffdd;
|
55
|
+
}
|
56
|
+
.highlight .go {
|
57
|
+
color: #888888;
|
58
|
+
}
|
59
|
+
.highlight .gp {
|
60
|
+
color: #555555;
|
61
|
+
}
|
62
|
+
.highlight .gs {
|
63
|
+
font-weight: bold;
|
64
|
+
}
|
65
|
+
.highlight .gu {
|
66
|
+
color: #aaaaaa;
|
67
|
+
}
|
68
|
+
.highlight .gt {
|
69
|
+
color: #aa0000;
|
70
|
+
}
|
71
|
+
.highlight .kc {
|
72
|
+
color: #000000;
|
73
|
+
font-weight: bold;
|
74
|
+
}
|
75
|
+
.highlight .kd {
|
76
|
+
color: #000000;
|
77
|
+
font-weight: bold;
|
78
|
+
}
|
79
|
+
.highlight .kn {
|
80
|
+
color: #000000;
|
81
|
+
font-weight: bold;
|
82
|
+
}
|
83
|
+
.highlight .kp {
|
84
|
+
color: #000000;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
.highlight .kr {
|
88
|
+
color: #000000;
|
89
|
+
font-weight: bold;
|
90
|
+
}
|
91
|
+
.highlight .kt {
|
92
|
+
color: #445588;
|
93
|
+
font-weight: bold;
|
94
|
+
}
|
95
|
+
.highlight .k, .highlight .kv {
|
96
|
+
color: #000000;
|
97
|
+
font-weight: bold;
|
98
|
+
}
|
99
|
+
.highlight .mf {
|
100
|
+
color: #009999;
|
101
|
+
}
|
102
|
+
.highlight .mh {
|
103
|
+
color: #009999;
|
104
|
+
}
|
105
|
+
.highlight .il {
|
106
|
+
color: #009999;
|
107
|
+
}
|
108
|
+
.highlight .mi {
|
109
|
+
color: #009999;
|
110
|
+
}
|
111
|
+
.highlight .mo {
|
112
|
+
color: #009999;
|
113
|
+
}
|
114
|
+
.highlight .m, .highlight .mb, .highlight .mx {
|
115
|
+
color: #009999;
|
116
|
+
}
|
117
|
+
.highlight .sb {
|
118
|
+
color: #d14;
|
119
|
+
}
|
120
|
+
.highlight .sc {
|
121
|
+
color: #d14;
|
122
|
+
}
|
123
|
+
.highlight .sd {
|
124
|
+
color: #d14;
|
125
|
+
}
|
126
|
+
.highlight .s2 {
|
127
|
+
color: #d14;
|
128
|
+
}
|
129
|
+
.highlight .se {
|
130
|
+
color: #d14;
|
131
|
+
}
|
132
|
+
.highlight .sh {
|
133
|
+
color: #d14;
|
134
|
+
}
|
135
|
+
.highlight .si {
|
136
|
+
color: #d14;
|
137
|
+
}
|
138
|
+
.highlight .sx {
|
139
|
+
color: #d14;
|
140
|
+
}
|
141
|
+
.highlight .sr {
|
142
|
+
color: #009926;
|
143
|
+
}
|
144
|
+
.highlight .s1 {
|
145
|
+
color: #d14;
|
146
|
+
}
|
147
|
+
.highlight .ss {
|
148
|
+
color: #990073;
|
149
|
+
}
|
150
|
+
.highlight .s {
|
151
|
+
color: #d14;
|
152
|
+
}
|
153
|
+
.highlight .na {
|
154
|
+
color: #008080;
|
155
|
+
}
|
156
|
+
.highlight .bp {
|
157
|
+
color: #999999;
|
158
|
+
}
|
159
|
+
.highlight .nb {
|
160
|
+
color: #0086B3;
|
161
|
+
}
|
162
|
+
.highlight .nc {
|
163
|
+
color: #445588;
|
164
|
+
font-weight: bold;
|
165
|
+
}
|
166
|
+
.highlight .no {
|
167
|
+
color: #008080;
|
168
|
+
}
|
169
|
+
.highlight .nd {
|
170
|
+
color: #3c5d5d;
|
171
|
+
font-weight: bold;
|
172
|
+
}
|
173
|
+
.highlight .ni {
|
174
|
+
color: #800080;
|
175
|
+
}
|
176
|
+
.highlight .ne {
|
177
|
+
color: #990000;
|
178
|
+
font-weight: bold;
|
179
|
+
}
|
180
|
+
.highlight .nf {
|
181
|
+
color: #990000;
|
182
|
+
font-weight: bold;
|
183
|
+
}
|
184
|
+
.highlight .nl {
|
185
|
+
color: #990000;
|
186
|
+
font-weight: bold;
|
187
|
+
}
|
188
|
+
.highlight .nn {
|
189
|
+
color: #555555;
|
190
|
+
}
|
191
|
+
.highlight .nt {
|
192
|
+
color: #000080;
|
193
|
+
}
|
194
|
+
.highlight .vc {
|
195
|
+
color: #008080;
|
196
|
+
}
|
197
|
+
.highlight .vg {
|
198
|
+
color: #008080;
|
199
|
+
}
|
200
|
+
.highlight .vi {
|
201
|
+
color: #008080;
|
202
|
+
}
|
203
|
+
.highlight .nv {
|
204
|
+
color: #008080;
|
205
|
+
}
|
206
|
+
.highlight .ow {
|
207
|
+
color: #000000;
|
208
|
+
font-weight: bold;
|
209
|
+
}
|
210
|
+
.highlight .o {
|
211
|
+
color: #000000;
|
212
|
+
font-weight: bold;
|
213
|
+
}
|
214
|
+
.highlight .w {
|
215
|
+
color: #bbbbbb;
|
216
|
+
}
|
217
|
+
.highlight {
|
218
|
+
background-color: #f8f8f8;
|
219
|
+
}</style>
|
220
|
+
</head>
|
221
|
+
|
222
|
+
<body>
|
223
|
+
<div class="frontcover container">
|
224
|
+
<div>
|
225
|
+
<div class="logo"><img src="images/kitabu.svg" /></div>
|
226
|
+
<p class="description">This guide will help you understand how all of the pieces fit together on Kitabu.</p>
|
227
|
+
<p class="authors">Nando Vieira</p>
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<div class="white-page"></div>
|
232
|
+
|
233
|
+
<div class="table-of-contents">
|
234
|
+
<h2 class="no-toc">Contents</h2>
|
235
|
+
<div id="toc">
|
236
|
+
<div class="level2 getting-started"><a href="#getting-started"><span>Getting Started</span></a></div><div class="level3 installing-ruby"><a href="#installing-ruby"><span>Installing Ruby</span></a></div><div class="level3 installing-princexml"><a href="#installing-princexml"><span>Installing PrinceXML</span></a></div><div class="level3 installing-kindlegen"><a href="#installing-kindlegen"><span>Installing KindleGen</span></a></div><div class="level2 creating-chapters"><a href="#creating-chapters"><span>Creating Chapters</span></a></div><div class="level2 syntax-highlighting"><a href="#syntax-highlighting"><span>Syntax Highlighting</span></a></div><div class="level3 what-about-the-syntax"><a href="#what-about-the-syntax"><span>What about the syntax</span></a></div><div class="level3 lexers"><a href="#lexers"><span>Lexers</span></a></div><div class="level2 dynamic-content"><a href="#dynamic-content"><span>Dynamic Content</span></a></div><div class="level3 escaping-erb-code"><a href="#escaping-erb-code"><span>Escaping ERb code</span></a></div><div class="level2 exporting-files"><a href="#exporting-files"><span>Exporting Files</span></a></div><div class="level3 exporting-pdf-with-docraptor"><a href="#exporting-pdf-with-docraptor"><span>Exporting PDF with DocRaptor</span></a></div>
|
237
|
+
</div>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
<div id="chapters">
|
241
|
+
|
242
|
+
<div class="chapter"><h2 id="getting-started">Getting Started</h2>
|
243
|
+
|
244
|
+
<p>This guide is designed for beginners who want to get started with Kitabu from scratch. However, to get the most out of it, you need to have some prerequisites installed:</p>
|
245
|
+
|
246
|
+
<ul>
|
247
|
+
<li>The <a href="http://ruby-lang.org">Ruby</a> interpreter version 2.0.0 or greater.</li>
|
248
|
+
<li>The <a href="http://princexml.com">PrinceXML</a> converter version 9.0 or greater.</li>
|
249
|
+
<li>The <a href="http://www.amazon.com/gp/feature.html?docId=1000765211">KindleGen</a> converter.</li>
|
250
|
+
</ul>
|
251
|
+
|
252
|
+
<h3 id="installing-ruby">Installing Ruby</h3>
|
253
|
+
|
254
|
+
<p>To install Ruby, consider using <a href="http://rvm.io">RVM</a> or <a href="http://rbenv.org">rbenv</a>, both available for Mac OSX and Linux distros. If you’re running a Windows, well, I can’t help you. I don’t even know if Kitabu runs over Windows boxes, so if you find any bugs, make sure you <a href="http://github.com/fnando/kitabu/issues">let me know</a>.</p>
|
255
|
+
|
256
|
+
<h3 id="installing-princexml">Installing PrinceXML</h3>
|
257
|
+
|
258
|
+
<p><a href="http://princexml.com">PrinceXML</a> is the best HTML to PDF converter available. You can use advanced CSS features to style your book in any way you want. But good things don’t come for free, and PrinceXML is no exception. The Professional License, which you grant you a installation on a single computer by a single user costs 495USD. If you don’t like the price tag, consider using <a href="http://docraptor.com">DocRaptor</a> when you’re ready to publish your book.</p>
|
259
|
+
|
260
|
+
<p>To install PrinceXML, go to the website and download the correct version for your platform; you can choose from Mac OSX, to Linux and Windows.</p>
|
261
|
+
|
262
|
+
<h3 id="installing-kindlegen">Installing KindleGen</h3>
|
263
|
+
|
264
|
+
<p>KindleGen is the command-line tool that allows you to convert e-pubs into <code>.mobi</code> files. You can’t sell these files, though.<sup id="fnref1"><a href="#fn1" rel="footnote">1</a></sup> So if that’s the case, consider using <a href="http://calibre-ebook.com/">Calibre</a> for this task.<sup id="fnref2"><a href="#fn2" rel="footnote">2</a></sup></p>
|
265
|
+
|
266
|
+
<p>If you’re running <a href="http://brew.sh">Homebrew</a> on the Mac OSX, you can install it with <code>brew install kindlegen</code>. Go to <a href="http://www.amazon.com/gp/feature.html?docId=1000765211">KindleGen’s website</a> and download the appropriate installer otherwise.</p>
|
267
|
+
|
268
|
+
<div class="footnotes">
|
269
|
+
<hr />
|
270
|
+
<ol>
|
271
|
+
|
272
|
+
<li id="fn1">
|
273
|
+
<p>You can, but that would be a violation of Amazon’s terms of use. <a href="#fnref1" rev="footnote">↩</a></p>
|
274
|
+
</li>
|
275
|
+
|
276
|
+
<li id="fn2">
|
277
|
+
<p>Calibre is not perfect, but does a good job. <a href="#fnref2" rev="footnote">↩</a></p>
|
278
|
+
</li>
|
279
|
+
|
280
|
+
</ol>
|
281
|
+
</div>
|
282
|
+
|
283
|
+
|
284
|
+
</div>
|
285
|
+
<div class="chapter"><h2 id="creating-chapters">Creating Chapters</h2>
|
286
|
+
|
287
|
+
<p>You can create chapters by having multiple files or directories. They’re alphabetically sorted, so make sure you use a prefixed file name like <code>01_Introduction.md</code> as the file name.</p>
|
288
|
+
|
289
|
+
<p>If you’re going to write a long book, make sure you use the directory organization. This way you can have smaller text files, which will be easier to read and change as you go. A file structure suggestion for a book about <a href="http://guides.rubyonrails.com">Ruby on Rails</a> would be:</p>
|
290
|
+
<pre class="highlight plaintext"><code>getting-started-with-rails
|
291
|
+
├── text
|
292
|
+
└── 01_Guide_Assumptions.md
|
293
|
+
└── 02_Whats_Rails.md
|
294
|
+
└── 03_Creating_A_New_Project
|
295
|
+
└── 01_Installing_Rails.md
|
296
|
+
└── 02_Creating_The_Blog_Application.md
|
297
|
+
└── 04_Hello_Rails
|
298
|
+
└── 01_Starting_Up_The_Web_Server.md
|
299
|
+
└── 02_Say_Hello_Rails.md
|
300
|
+
└── 03_Setting_The_Application_Home_Page.md
|
301
|
+
└── ...
|
302
|
+
</code></pre>
|
303
|
+
|
304
|
+
<p>Notice that the file name does not need to be readable, but it will make your life easier.</p>
|
305
|
+
|
306
|
+
|
307
|
+
</div>
|
308
|
+
<div class="chapter"><h2 id="syntax-highlighting">Syntax Highlighting</h2>
|
309
|
+
|
310
|
+
<h3 id="what-about-the-syntax">What about the syntax</h3>
|
311
|
+
|
312
|
+
<p>Kitabu uses <a href="http://rubygems.org/gems/rouge">Route</a> as the syntax highlight formatter. It emits an output compatible with stylesheets designed for <a href="https://pygments.org">pygments</a>, the Python library used by many.</p>
|
313
|
+
|
314
|
+
<p>To highlight a code block, use the fenced block syntax. The following example would be formatted as Ruby.</p>
|
315
|
+
<pre class="highlight plaintext"><code>```ruby
|
316
|
+
class User
|
317
|
+
attr_accessor :name, :email
|
318
|
+
|
319
|
+
def initialize(name, email)
|
320
|
+
@name = name
|
321
|
+
@email = email
|
322
|
+
end
|
323
|
+
end
|
324
|
+
```
|
325
|
+
</code></pre>
|
326
|
+
|
327
|
+
<p>The output would be something like this:</p>
|
328
|
+
<pre class="highlight ruby"><code><span class="k">class</span> <span class="nc">User</span>
|
329
|
+
<span class="kp">attr_accessor</span> <span class="ss">:name</span><span class="p">,</span> <span class="ss">:email</span>
|
330
|
+
|
331
|
+
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="n">email</span><span class="p">)</span>
|
332
|
+
<span class="vi">@name</span> <span class="o">=</span> <span class="nb">name</span>
|
333
|
+
<span class="vi">@email</span> <span class="o">=</span> <span class="n">email</span>
|
334
|
+
<span class="k">end</span>
|
335
|
+
<span class="k">end</span>
|
336
|
+
</code></pre>
|
337
|
+
|
338
|
+
<div class="note info"><p>If you’re using Sublime Text, make sure you install the <a href="https://packagecontrol.io/packages/Markdown%20Extended">Markdown Extended</a> plugin; it enables code syntax highlighting on your Markdown files.</p>
|
339
|
+
</div>
|
340
|
+
|
341
|
+
<p>You can also provide inline options such as line numbers and inline rendering.</p>
|
342
|
+
<pre class="highlight plaintext"><code>```ruby?line_numbers=1
|
343
|
+
class User
|
344
|
+
attr_accessor :name, :email
|
345
|
+
|
346
|
+
def initialize(name, email)
|
347
|
+
@name = name
|
348
|
+
@email = email
|
349
|
+
end
|
350
|
+
end
|
351
|
+
```
|
352
|
+
</code></pre>
|
353
|
+
|
354
|
+
<p>This would be rendered like this:</p>
|
355
|
+
<div class="highlight ruby"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1
|
356
|
+
2
|
357
|
+
3
|
358
|
+
4
|
359
|
+
5
|
360
|
+
6
|
361
|
+
7
|
362
|
+
8</pre></td><td class="code"><pre><span class="k">class</span> <span class="nc">User</span>
|
363
|
+
<span class="kp">attr_accessor</span> <span class="ss">:name</span><span class="p">,</span> <span class="ss">:email</span>
|
364
|
+
|
365
|
+
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="n">email</span><span class="p">)</span>
|
366
|
+
<span class="vi">@name</span> <span class="o">=</span> <span class="nb">name</span>
|
367
|
+
<span class="vi">@email</span> <span class="o">=</span> <span class="n">email</span>
|
368
|
+
<span class="k">end</span>
|
369
|
+
<span class="k">end</span>
|
370
|
+
</pre></td></tr></tbody></table>
|
371
|
+
</div>
|
372
|
+
|
373
|
+
<h3 id="lexers">Lexers</h3>
|
374
|
+
|
375
|
+
<p>Rouge comes with dozens of lexers. Check out this list, generated dynamically when you export your e-book.</p>
|
376
|
+
|
377
|
+
<ul class="lexers-list"><li><strong>Apache</strong> <code>apache</code><br /><span>configuration files for Apache web server</span></li><li><strong>AppleScript</strong> <code>applescript</code><br /><span>The AppleScript scripting language by Apple Inc. (http://developer.apple.com/applescript/)</span></li><li><strong>C</strong> <code>c</code><br /><span>The C programming language</span></li><li><strong>Clojure</strong> <code>clojure</code><br /><span>The Clojure programming language (clojure.org)</span></li><li><strong>CoffeeScript</strong> <code>coffeescript</code><br /><span>The Coffeescript programming language (coffeescript.org)</span></li><li><strong>Common Lisp</strong> <code>common_lisp</code><br /><span>The Common Lisp variant of Lisp (common-lisp.net)</span></li><li><strong>Config File</strong> <code>conf</code><br /><span>A generic lexer for configuration files</span></li><li><strong>C++</strong> <code>cpp</code><br /><span>The C++ programming language</span></li><li><strong>C#</strong> <code>csharp</code><br /><span>a multi-paradigm language targeting .NET</span></li><li><strong>CSS</strong> <code>css</code><br /><span>Cascading Style Sheets, used to style web pages</span></li><li><strong>Dart</strong> <code>dart</code><br /><span>The Dart programming language (dartlang.com)</span></li><li><strong>diff</strong> <code>diff</code><br /><span>Lexes unified diffs or patches</span></li><li><strong>Elixir</strong> <code>elixir</code><br /><span>Elixir language (elixir-lang.org)</span></li><li><strong>ERB</strong> <code>erb</code><br /><span>Embedded ruby template files</span></li><li><strong>Erlang</strong> <code>erlang</code><br /><span>The Erlang programming language (erlang.org)</span></li><li><strong>Factor</strong> <code>factor</code><br /><span>Factor, the practical stack language (factorcode.org)</span></li><li><strong>Gherkin</strong> <code>gherkin</code><br /><span>A business-readable spec DSL ( github.com/cucumber/cucumber/wiki/Gherkin )</span></li><li><strong>Go</strong> <code>go</code><br /><span>The Go programming language (http://golang.org)</span></li><li><strong>Groovy</strong> <code>groovy</code><br /><span>The Groovy programming language (groovy.codehaus.org)</span></li><li><strong>Haml</strong> <code>haml</code><br /><span>The Haml templating system for Ruby (haml.info)</span></li><li><strong>Handlebars</strong> <code>handlebars</code><br /><span>the Handlebars and Mustache templating languages</span></li><li><strong>Haskell</strong> <code>haskell</code><br /><span>The Haskell programming language (haskell.org)</span></li><li><strong>HTML</strong> <code>html</code><br /><span>HTML, the markup language of the web</span></li><li><strong>HTTP</strong> <code>http</code><br /><span>http requests and responses</span></li><li><strong>INI</strong> <code>ini</code><br /><span>the INI configuration format</span></li><li><strong>Io</strong> <code>io</code><br /><span>The IO programming language (http://iolanguage.com)</span></li><li><strong>Java</strong> <code>java</code><br /><span>The Java programming language (java.com)</span></li><li><strong>JavaScript</strong> <code>javascript</code><br /><span>JavaScript, the browser scripting language</span></li><li><strong>Json</strong> <code>json</code><br /><span>JavaScript Object Notation (json.org)</span></li><li><strong>Liquid</strong> <code>liquid</code><br /><span>Liquid is a templating engine for Ruby (liquidmarkup.org)</span></li><li><strong>Literate CoffeeScript</strong> <code>literate_coffeescript</code><br /><span>Literate coffeescript</span></li><li><strong>Literate Haskell</strong> <code>literate_haskell</code><br /><span>Literate haskell</span></li><li><strong>LLVM</strong> <code>llvm</code><br /><span>The LLVM Compiler Infrastructure (http://llvm.org/)</span></li><li><strong>Lua</strong> <code>lua</code><br /><span>Lua (http://www.lua.org)</span></li><li><strong>Make</strong> <code>make</code><br /><span>Makefile syntax</span></li><li><strong>Markdown</strong> <code>markdown</code><br /><span>Markdown, a light-weight markup language for authors</span></li><li><strong>MATLAB</strong> <code>matlab</code><br /><span>Matlab</span></li><li><strong>MoonScript</strong> <code>moonscript</code><br /><span>Moonscript (http://www.moonscript.org)</span></li><li><strong>nginx</strong> <code>nginx</code><br /><span>configuration files for the nginx web server (nginx.org)</span></li><li><strong>Nim</strong> <code>nim</code><br /><span>The Nim programming language (http://nim-lang.org/)</span></li><li><strong>Objective-C</strong> <code>objective_c</code><br /><span>an extension of C commonly used to write Apple software</span></li><li><strong>OCaml</strong> <code>ocaml</code><br /><span>Objective CAML (ocaml.org)</span></li><li><strong>Perl</strong> <code>perl</code><br /><span>The Perl scripting language (perl.org)</span></li><li><strong>PHP</strong> <code>php</code><br /><span>The PHP scripting language (php.net)</span></li><li><strong>Plain Text</strong> <code>plaintext</code><br /><span>A boring lexer that doesn’t highlight anything</span></li><li><strong>Prolog</strong> <code>prolog</code><br /><span>The Prolog programming language (http://en.wikipedia.org/wiki/Prolog)</span></li><li><strong>.properties</strong> <code>properties</code><br /><span>.properties config files for Java</span></li><li><strong>Puppet</strong> <code>puppet</code><br /><span>The Puppet configuration management language (puppetlabs.org)</span></li><li><strong>Python</strong> <code>python</code><br /><span>The Python programming language (python.org)</span></li><li><strong>QML</strong> <code>qml</code><br /><span>QML, a UI markup language</span></li><li><strong>R</strong> <code>r</code><br /><span>The R statistics language (r-project.org)</span></li><li><strong>Racket</strong> <code>racket</code><br /><span>Racket is a Lisp descended from Scheme (racket-lang.org)</span></li><li><strong>Ruby</strong> <code>ruby</code><br /><span>The Ruby programming language (ruby-lang.org)</span></li><li><strong>Rust</strong> <code>rust</code><br /><span>The Rust programming language (rust-lang.org)</span></li><li><strong>Sass</strong> <code>sass</code><br /><span>The Sass stylesheet language language (sass-lang.com)</span></li><li><strong>Scala</strong> <code>scala</code><br /><span>The Scala programming language (scala-lang.org)</span></li><li><strong>Scheme</strong> <code>scheme</code><br /><span>The Scheme variant of Lisp</span></li><li><strong>SCSS</strong> <code>scss</code><br /><span>SCSS stylesheets (sass-lang.com)</span></li><li><strong>sed</strong> <code>sed</code><br /><span>sed, the ultimate stream editor</span></li><li><strong>shell</strong> <code>shell</code><br /><span>Various shell languages, including sh and bash</span></li><li><strong>Slim</strong> <code>slim</code><br /><span>The Slim template language</span></li><li><strong>Smalltalk</strong> <code>smalltalk</code><br /><span>The Smalltalk programming language</span></li><li><strong>SML</strong> <code>sml</code><br /><span>Standard ML</span></li><li><strong>SQL</strong> <code>sql</code><br /><span>Structured Query Language, for relational databases</span></li><li><strong>Swift</strong> <code>swift</code><br /><span>Multi paradigm, compiled programming language developed by Apple for iOS and OS X development. (developer.apple.com/swift)</span></li><li><strong>Tcl</strong> <code>tcl</code><br /><span>The Tool Command Language (tcl.tk)</span></li><li><strong>TeX</strong> <code>tex</code><br /><span>The TeX typesetting system</span></li><li><strong>TOML</strong> <code>toml</code><br /><span>the TOML configuration format (https://github.com/mojombo/toml)</span></li><li><strong>Visual Basic</strong> <code>vb</code><br /><span>Visual Basic</span></li><li><strong>VimL</strong> <code>viml</code><br /><span>VimL, the scripting language for the Vim editor (vim.org)</span></li><li><strong>XML</strong> <code>xml</code><br /><span><desc for="this-lexer">XML</desc></span></li><li><strong>YAML</strong> <code>yaml</code><br /><span>Yaml Ain’t Markup Language (yaml.org)</span></li></ul>
|
378
|
+
|
379
|
+
<p>And if what you want is not on this list, make you <a href="https://github.com/jneen/rouge/issues">open a ticket</a> on the project.</p>
|
380
|
+
|
381
|
+
|
382
|
+
</div>
|
383
|
+
<div class="chapter"><h2 id="dynamic-content">Dynamic Content</h2>
|
384
|
+
|
385
|
+
<p>Sometimes you may find useful to generate content dynamically. Maybe you’re going to read some configuration file, or maybe you just want to define some helpers. Kitabu has support for ERb files; all you need to do is naming your text file as <code>.erb</code>.</p>
|
386
|
+
|
387
|
+
<p>On the previous chapter, we listed all supported Rouge lexers. To do that, I created a helper that looks like this:</p>
|
388
|
+
<pre class="highlight ruby"><code><span class="k">module</span> <span class="nn">Kitabu</span>
|
389
|
+
<span class="k">module</span> <span class="nn">Helpers</span>
|
390
|
+
<span class="k">def</span> <span class="nf">lexers_list</span>
|
391
|
+
<span class="n">buffer</span> <span class="o">=</span> <span class="s1">'<ul class="lexers">'</span>
|
392
|
+
|
393
|
+
<span class="no">Rouge</span><span class="o">::</span><span class="no">Lexers</span><span class="p">.</span><span class="nf">constants</span><span class="p">.</span><span class="nf">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">const</span><span class="o">|</span>
|
394
|
+
<span class="n">lexer</span> <span class="o">=</span> <span class="no">Rouge</span><span class="o">::</span><span class="no">Lexers</span><span class="p">.</span><span class="nf">const_get</span><span class="p">(</span><span class="n">const</span><span class="p">)</span>
|
395
|
+
|
396
|
+
<span class="k">begin</span>
|
397
|
+
<span class="n">title</span> <span class="o">=</span> <span class="n">lexer</span><span class="p">.</span><span class="nf">title</span>
|
398
|
+
<span class="n">tag</span> <span class="o">=</span> <span class="n">lexer</span><span class="p">.</span><span class="nf">tag</span>
|
399
|
+
<span class="n">description</span> <span class="o">=</span> <span class="n">lexer</span><span class="p">.</span><span class="nf">desc</span>
|
400
|
+
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
|
401
|
+
<span class="k">next</span>
|
402
|
+
<span class="k">end</span>
|
403
|
+
|
404
|
+
<span class="n">buffer</span> <span class="o"><<</span> <span class="s1">'<li>'</span>
|
405
|
+
<span class="n">buffer</span> <span class="o"><<</span> <span class="s2">"<strong></span><span class="si">#{</span><span class="n">title</span><span class="si">}</span><span class="s2"></strong> "</span>
|
406
|
+
<span class="n">buffer</span> <span class="o"><<</span> <span class="s2">"<code></span><span class="si">#{</span><span class="n">tag</span><span class="si">}</span><span class="s2"></code><br>"</span>
|
407
|
+
<span class="n">buffer</span> <span class="o"><<</span> <span class="s2">"<span></span><span class="si">#{</span><span class="n">description</span><span class="si">}</span><span class="s2"></span>"</span>
|
408
|
+
<span class="n">buffer</span> <span class="o"><<</span> <span class="s1">'</li>'</span>
|
409
|
+
<span class="k">end</span>
|
410
|
+
|
411
|
+
<span class="n">buffer</span> <span class="o"><<</span> <span class="s1">'</ul>'</span>
|
412
|
+
<span class="n">buffer</span>
|
413
|
+
<span class="k">end</span>
|
414
|
+
<span class="k">end</span>
|
415
|
+
<span class="k">end</span>
|
416
|
+
</code></pre>
|
417
|
+
|
418
|
+
<p>To use it, I just needed to add <code><%= lexers_list %></code> to my text file. This allows you to create anything you need!</p>
|
419
|
+
|
420
|
+
<p>Kitabu comes with some built-in helpers, such as <code>note</code>. With this helper, you can create a note that generates a HTML structure, so you can easily style it. The syntax for using the <code>note</code> helper is <code>note(type, &block)</code>.</p>
|
421
|
+
<pre class="highlight erb"><code><span class="cp"><%</span> <span class="n">note</span> <span class="k">do</span> <span class="cp">%></span>
|
422
|
+
Some text that will be parsed as Markdown.
|
423
|
+
<span class="cp"><%</span> <span class="k">end</span> <span class="cp">%></span>
|
424
|
+
</code></pre>
|
425
|
+
|
426
|
+
<p>By default, this will generate a <code><div class="note info"></code> tag, but you can use anything you want.</p>
|
427
|
+
<pre class="highlight erb"><code><span class="cp"><%</span> <span class="n">note</span> <span class="ss">:warning</span> <span class="k">do</span> <span class="cp">%></span>
|
428
|
+
Some text that will be parsed as Markdown.
|
429
|
+
<span class="cp"><%</span> <span class="k">end</span> <span class="cp">%></span>
|
430
|
+
</code></pre>
|
431
|
+
|
432
|
+
<p><a href="https://github.com/fnando/kitabu/blob/cleanup/lib/kitabu/helpers.rb">Check out the source</a> for a sample on how to create block helpers like <code>note</code>.</p>
|
433
|
+
|
434
|
+
<h3 id="escaping-erb-code">Escaping ERb code</h3>
|
435
|
+
|
436
|
+
<p>If you want to write a book about Rails, you’re likely to use lots of ERb tags. In this case, make sure you escape the <code>and</code> markers as <code><% %></code> and <code><%= %></code>; otherwise you’ll have a syntax error.</p>
|
437
|
+
<pre class="highlight plaintext"><code><%%= Date.today %>
|
438
|
+
</code></pre>
|
439
|
+
|
440
|
+
|
441
|
+
</div>
|
442
|
+
<div class="chapter"><h2 id="exporting-files">Exporting Files</h2>
|
443
|
+
|
444
|
+
<p>You can generate files as you go. Just execute <code>kitabu export</code> from your book’s root directory.</p>
|
445
|
+
<pre class="highlight plaintext"><code>$ kitabu export
|
446
|
+
** e-book has been exported
|
447
|
+
</code></pre>
|
448
|
+
|
449
|
+
<p>This command will generate all supported formats<sup id="fnref1"><a href="#fn1" rel="footnote">1</a></sup>. The generated files will be placed on your <code>output</code> directory; the following output list only the relevant files.</p>
|
450
|
+
<pre class="highlight plaintext"><code>$ tree output
|
451
|
+
output
|
452
|
+
├── images
|
453
|
+
│ ├── kitabu.png
|
454
|
+
│ └── kitabu.svg
|
455
|
+
├── kitabu.epub
|
456
|
+
├── kitabu.html
|
457
|
+
├── kitabu.mobi
|
458
|
+
├── kitabu.pdf
|
459
|
+
├── kitabu.print.pdf
|
460
|
+
├── kitabu.txt
|
461
|
+
└── styles
|
462
|
+
├── epub.css
|
463
|
+
├── html.css
|
464
|
+
├── pdf.css
|
465
|
+
└── print.css
|
466
|
+
</code></pre>
|
467
|
+
|
468
|
+
<p>This can take a while depending on your book size, but usually the process is pretty fast. If you want to generate a specific format faster, provide the <code>--only</code> flag.</p>
|
469
|
+
<pre class="highlight plaintext"><code>$ kitabu export --only pdf
|
470
|
+
</code></pre>
|
471
|
+
|
472
|
+
<p>You can also automatically generate files when something changes. You can use <a href="http://rubygems.org/gems/guard">Guard</a> for this, and Kitabu even generates a sample file for you. All you have to do is running <code>bundle exec guard</code>.</p>
|
473
|
+
<pre class="highlight plaintext"><code>$ bundle exec guard
|
474
|
+
20:38:10 - INFO - Guard is now watching at '/Users/fnando/Projects/kitabu/examples/kitabu'
|
475
|
+
** e-book has been exported
|
476
|
+
</code></pre>
|
477
|
+
|
478
|
+
<h3 id="exporting-pdf-with-docraptor">Exporting PDF with DocRaptor</h3>
|
479
|
+
|
480
|
+
<p>After exporting your files (you can use <code>--only pdf</code> for this), upload files to somewhere public, possibly your <a href="http://dropbox.com">Dropbox</a> account. You can even use curl; since the command is quite long, you can view it at <a href="https://gist.github.com/fnando/de555a08e7aab14a661a">https://gist.github.com/fnando/de555a08e7aab14a661a</a>.</p>
|
481
|
+
|
482
|
+
<div class="footnotes">
|
483
|
+
<hr />
|
484
|
+
<ol>
|
485
|
+
|
486
|
+
<li id="fn1">
|
487
|
+
<p>Depend on Prince, html2text and KindleGen being available on your <code>$PATH</code>. <a href="#fnref1" rev="footnote">↩</a></p>
|
488
|
+
</li>
|
489
|
+
|
490
|
+
</ol>
|
491
|
+
</div>
|
492
|
+
|
493
|
+
|
494
|
+
</div>
|
495
|
+
|
496
|
+
</div>
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
<div class="white-page"></div>
|
501
|
+
|
502
|
+
<div class="imprint container">
|
503
|
+
<div>
|
504
|
+
<h2>Kitabu</h2>
|
505
|
+
<p class="description">This guide will help you understand how all of the pieces fit together on Kitabu.</p>
|
506
|
+
<p class="authors">Nando Vieira</p>
|
507
|
+
<p class="copyright">Copyright (C) 2015 Nando Vieira.</p>
|
508
|
+
</div>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
<a href="#" class="go-top">⇧</a>
|
512
|
+
</body>
|
513
|
+
</html>
|