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
@@ -1,352 +0,0 @@
1
- /* ============ */
2
- /* = DEFAULTS = */
3
- /* ============ */
4
- html * {
5
- font: normal normal normal 12pt/normal Constantia, Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, serif;
6
- }
7
-
8
- /* ========= */
9
- /* = PAGES = */
10
- /* ========= */
11
- @page {
12
- margin: 12mm 16mm 10mm 16mm;
13
- size: 7in 9.25in landscape;
14
-
15
- @footnotes {
16
- border-top: thin solid black;
17
- margin-left: 30%;
18
- margin-top: 0.6em;
19
- padding-top: 0.3em;
20
- }
21
-
22
- @bottom-right {
23
- color: #000;
24
- content: counter(page);
25
- font-family: helvetica, arial, sans-serif;
26
- font-size: 12px;
27
- margin-top: -10px;
28
- margin-right: -40px;
29
- }
30
- }
31
-
32
- @page toc {
33
- margin-right: 6mm;
34
-
35
- @bottom-right {
36
- content: "";
37
- }
38
- }
39
-
40
- @page cover {
41
- margin: 0;
42
-
43
- @bottom-right {
44
- content: "";
45
- }
46
- }
47
-
48
- /* ============= */
49
- /* = BOOKMARKS = */
50
- /* ============= */
51
- h1, h2, h3, h4, h5, h6 {
52
- prince-bookmark-level: none;
53
- }
54
-
55
- .frontcover h1 { prince-bookmark-level: 1; }
56
- .chapter h2 { prince-bookmark-level: 2; }
57
- .chapter h3 { prince-bookmark-level: 3; }
58
- .chapter h4 { prince-bookmark-level: 4; }
59
- .chapter h5 { prince-bookmark-level: 5; }
60
- .chapter h6 { prince-bookmark-level: 6; }
61
-
62
- /* ============= */
63
- /* = CONTAINER = */
64
- /* ============= */
65
- div.container {
66
- height: 7in;
67
- left: 0;
68
- page: cover;
69
- position: absolute;
70
- top: 0;
71
- width: 9.25in;
72
- z-index: -1;
73
- }
74
-
75
- /* ============== */
76
- /* = FRONTCOVER = */
77
- /* ============== */
78
- div.frontcover {
79
- background: #fff;
80
- }
81
-
82
- div.frontcover div {
83
- left: 1in;
84
- padding-top: 0.25in;
85
- position: absolute;
86
- top: 2.5in;
87
- width: 7.25in;
88
- }
89
-
90
- div.frontcover h1 {
91
- color: #f00;
92
- font-size: 46pt;
93
- }
94
-
95
- div.frontcover p {
96
- font-size: 18pt;
97
- }
98
-
99
- div.frontcover p.description {
100
- color: #666;
101
- font: italic normal normal 14pt/normal Baskerville, "Hoefler Text", Garamond, "Times New Roman", serif;
102
- margin-top: -.1in;
103
- }
104
-
105
- div.frontcover p.authors {
106
- color: #000;
107
- font-style: italic;
108
- position: absolute;
109
- top: 0;
110
- }
111
-
112
- div.frontcover * {
113
- margin: 0;
114
- }
115
-
116
- /* =========== */
117
- /* = CHAPTER = */
118
- /* =========== */
119
- #chapters {
120
- counter-reset: page 1;
121
- page-break-before: always;
122
- }
123
-
124
- .chapter {
125
- color: #444;
126
- counter-reset: footnote 0;
127
- page-break-after: always;
128
- }
129
-
130
- .chapter a {
131
- color: #0AE;
132
- text-decoration: none;
133
- }
134
-
135
- .chapter h2,
136
- .chapter h3,
137
- .chapter h4,
138
- .chapter h5 {
139
- margin: 25pt 0 15pt 0;
140
- }
141
-
142
- .chapter h2 {
143
- color: #222;
144
- counter-increment: chapter;
145
- font-size: 36pt;
146
- line-height: 1;
147
- string-set: header "Chapter " counter(chapter) ": " content();
148
- }
149
-
150
- .chapter h2::before {
151
- content: "Chapter " counter(chapter);
152
- color: #999;
153
- display: block;
154
- font-size: 18pt;
155
- letter-spacing: 0;
156
- margin-bottom: .2em;
157
- white-space: pre;
158
- }
159
-
160
- .chapter h3,
161
- .chapter h5 {
162
- font-family: "helvetica", arial, sans-serif;
163
- }
164
-
165
- .chapter h3 {
166
- color: #b62f32;
167
- font-size: 28px;
168
- }
169
-
170
- .chapter h4 {
171
- font-size: 18px;
172
- font-family: "helvetica neue", "arial narrow", sans-serif;
173
- }
174
-
175
- .chapter h5 {
176
- font-size: 15px;
177
- }
178
-
179
- .chapter h6 {
180
- font-size: 15px;
181
- font-weight: normal;
182
- text-transform: uppercase;
183
- }
184
-
185
- /* =========== */
186
- /* = IMPRINT = */
187
- /* =========== */
188
- .imprint {
189
- background: #E2E7E2;
190
- page: cover;
191
- string-set: header "";
192
- }
193
-
194
- .imprint, .imprint * {
195
- color: #5b5b5b;
196
- }
197
-
198
- .imprint * {
199
- font-family: "Lucida Grande", arial, sans-serif;
200
- font-size: 10pt;
201
- margin: 0 0 2pt 0;
202
- }
203
-
204
- .imprint div {
205
- left: 0.5in;
206
- position: absolute;
207
- bottom: 0.3in;
208
- }
209
-
210
- /* ========== */
211
- /* = CODING = */
212
- /* ========== */
213
- pre, code {
214
- color: #090;
215
- font-family: monaco, monospace;
216
- font-size: 9pt;
217
- }
218
-
219
- pre, pre code {
220
- font-size: 8pt;
221
- line-height: 1.4;
222
- padding-left: 25pt;
223
- }
224
-
225
- /* ========= */
226
- /* = TABLE = */
227
- /* ========= */
228
- table {
229
- border-collapse: collapse;
230
- }
231
-
232
- thead th {
233
- background: #e9e9e9;
234
- }
235
-
236
- th, td {
237
- border: 1px solid #ccc;
238
- font-size: 11pt;
239
- padding: 5pt;
240
- }
241
-
242
- /* ========= */
243
- /* = LISTS = */
244
- /* ========= */
245
- li {
246
- margin-bottom: 8pt;
247
- }
248
-
249
- li ul,
250
- li ol {
251
- margin-left: 15pt;
252
- }
253
-
254
- /* ========== */
255
- /* = FIGURE = */
256
- /* ========== */
257
- .figure img:after {
258
- content: attr("alt");
259
- display: block;
260
- font-size: 10pt;
261
- }
262
-
263
- img {
264
- max-width: none;
265
- prince-image-resolution: 96dpi;
266
- }
267
-
268
- .figure {
269
- float: right;
270
- margin: 0 0 20pt 20pt;
271
- overflow: auto;
272
- text-align: center;
273
- }
274
-
275
- /* ===================== */
276
- /* = TABLE OF CONTENTS = */
277
- /* ===================== */
278
- div.table-of-contents {
279
- page: toc;
280
- }
281
-
282
- div.table-of-contents h2 {
283
- font-size: 36pt;
284
- }
285
-
286
- div.table-of-contents a {
287
- font-size: 11pt;
288
- text-decoration: none;
289
- }
290
-
291
- div.table-of-contents div.level2 a {
292
- color: #000;
293
- font-weight: bold;
294
- }
295
-
296
- div.table-of-contents #toc {
297
- column-count: 2;
298
- column-fill: auto;
299
- column-gap: 5%;
300
- column-rule: none;
301
- column-width: 45%;
302
- }
303
-
304
- div.table-of-contents #toc div {
305
- padding-bottom: 10px;
306
- }
307
-
308
- div.table-of-contents div.level3 {
309
- margin-left: 20px;
310
- }
311
-
312
- div.table-of-contents #toc div.level3 a {
313
- color: #555;
314
- }
315
-
316
- div.table-of-contents div a::before {
317
- color: #888;
318
- content: target-counter(attr(href), page) " ";
319
- float: left;
320
- font-weight: normal;
321
- font-size: 11pt !important;
322
- margin-right: 4px;
323
- width: 40px;
324
- }
325
-
326
- div.table-of-contents div.level3 a::before {
327
- width: 20px;
328
- }
329
-
330
- div.table-of-contents div.level4,
331
- div.table-of-contents div.level5,
332
- div.table-of-contents div.level6 {
333
- display: none;
334
- }
335
-
336
- /* ===================== */
337
- /* = OTHER TEXT TWEAKS = */
338
- /* ===================== */
339
- acronym:after {
340
- content: " (" attr(title) ")";
341
- }
342
-
343
- /* ============= */
344
- /* = HIGHLIGHT = */
345
- /* ============= */
346
- .highlight {
347
- font-size: 20pt;
348
- }
349
-
350
- .highlight strong {
351
- color: #b62f32;
352
- }
@@ -1,43 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
- <head>
4
- <title><%= title %></title>
5
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
- <link rel="stylesheet" type="text/css" href="../templates/layout.css"/>
7
- <link rel="stylesheet" type="text/css" href="../templates/syntax.css"/>
8
- <link rel="stylesheet" type="text/css" href="../templates/user.css"/>
9
-
10
- <meta name="author" content="<%= authors.join(', ') %>" />
11
- <meta name="subject" content="<%= subject %>" />
12
- <meta name="keywords" content="<%= keywords %>" />
13
- <meta name="date" content="<%= published_at %>" />
14
- </head>
15
- <body>
16
- <div class="frontcover container">
17
- <div>
18
- <h1><%= title %></h1>
19
- <p class="description"><%= subject %></p>
20
- <p class="authors"><%= authors.to_sentence %></p>
21
- </div>
22
- </div>
23
-
24
- <div class="table-of-contents">
25
- <h2 class="no-toc">Content</h2>
26
- <div id="toc">
27
- <%= toc %>
28
- </div>
29
- </div>
30
-
31
- <div id="chapters">
32
- <%= content %>
33
- </div>
34
-
35
- <div class="imprint container">
36
- <div>
37
- <h2><%= title %></h2>
38
- <p><%= authors.to_sentence %></p>
39
- <p><%= copyright %></p>
40
- </div>
41
- </div>
42
- </body>
43
- </html>
@@ -1,62 +0,0 @@
1
- pre.idle .InheritedClass {
2
- }
3
- pre.idle .TypeName {
4
- color: #21439C;
5
- }
6
- pre.idle .Number {
7
- }
8
- pre.idle .LibraryVariable {
9
- color: #A535AE;
10
- }
11
- pre.idle .Storage {
12
- color: #FF5600;
13
- }
14
- pre.idle .line-numbers {
15
- background-color: #BAD6FD;
16
- color: #000000;
17
- }
18
- pre.idle {
19
- background-color: #FFFFFF;
20
- color: #000000;
21
- }
22
- pre.idle .StringInterpolation {
23
- color: #990000;
24
- }
25
- pre.idle .TagName {
26
- }
27
- pre.idle .LibraryConstant {
28
- color: #A535AE;
29
- }
30
- pre.idle .FunctionArgument {
31
- }
32
- pre.idle .BuiltInConstant {
33
- color: #A535AE;
34
- }
35
- pre.idle .Invalid {
36
- background-color: #990000;
37
- color: #FFFFFF;
38
- }
39
- pre.idle .LibraryClassType {
40
- color: #A535AE;
41
- }
42
- pre.idle .LibraryFunction {
43
- color: #A535AE;
44
- }
45
- pre.idle .TagAttribute {
46
- }
47
- pre.idle .Keyword {
48
- color: #FF5600;
49
- }
50
- pre.idle .UserDefinedConstant {
51
- }
52
- pre.idle .String {
53
- color: #00A33F;
54
- }
55
- pre.idle .FunctionName {
56
- color: #21439C;
57
- }
58
- pre.idle .Variable {
59
- }
60
- pre.idle .Comment {
61
- color: #919191;
62
- }