asciibook 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/README.adoc +122 -0
  3. data/book_template/asciibook.yml +5 -0
  4. data/book_template/book.adoc +3 -0
  5. data/exe/asciibook +7 -0
  6. data/lib/asciibook.rb +19 -1
  7. data/lib/asciibook/asciidoctor_ext/abstract_node.rb +5 -0
  8. data/lib/asciibook/book.rb +153 -0
  9. data/lib/asciibook/builders/base_builder.rb +24 -0
  10. data/lib/asciibook/builders/epub_builder.rb +84 -0
  11. data/lib/asciibook/builders/html_builder.rb +45 -0
  12. data/lib/asciibook/builders/mobi_builder.rb +21 -0
  13. data/lib/asciibook/builders/pdf_builder.rb +154 -0
  14. data/lib/asciibook/command.rb +85 -0
  15. data/lib/asciibook/converter.rb +303 -0
  16. data/lib/asciibook/page.rb +30 -0
  17. data/lib/asciibook/version.rb +1 -1
  18. data/templates/admonition.html +4 -0
  19. data/templates/audio.html +7 -0
  20. data/templates/colist.html +7 -0
  21. data/templates/dlist.html +12 -0
  22. data/templates/document.html +29 -0
  23. data/templates/embedded.html +20 -0
  24. data/templates/example.html +4 -0
  25. data/templates/footnotes.html +7 -0
  26. data/templates/image.html +11 -0
  27. data/templates/index.html +40 -0
  28. data/templates/inline_anchor.html +12 -0
  29. data/templates/inline_callout.html +1 -0
  30. data/templates/inline_footnote.html +1 -0
  31. data/templates/inline_image.html +3 -0
  32. data/templates/inline_indexterm.html +5 -0
  33. data/templates/inline_quoted.html +24 -0
  34. data/templates/listing.html +4 -0
  35. data/templates/literal.html +1 -0
  36. data/templates/olist.html +8 -0
  37. data/templates/page_break.html +1 -0
  38. data/templates/paragraph.html +1 -0
  39. data/templates/pass.html +1 -0
  40. data/templates/preamble.html +3 -0
  41. data/templates/quote.html +9 -0
  42. data/templates/section.html +4 -0
  43. data/templates/sidebar.html +6 -0
  44. data/templates/stem.html +9 -0
  45. data/templates/table.html +41 -0
  46. data/templates/thematic_break.html +1 -0
  47. data/templates/ulist.html +8 -0
  48. data/templates/verse.html +9 -0
  49. data/templates/video.html +10 -0
  50. data/theme/epub/epub.css +6 -0
  51. data/theme/epub/layout.html +14 -0
  52. data/theme/html/html.css +190 -0
  53. data/theme/html/html.js +29 -0
  54. data/theme/html/layout.html +91 -0
  55. data/theme/mobi/layout.html +13 -0
  56. data/theme/mobi/mobi.css +2 -0
  57. data/theme/pdf/config.yml +6 -0
  58. data/theme/pdf/footer.html +11 -0
  59. data/theme/pdf/header.html +3 -0
  60. data/theme/pdf/layout.html +14 -0
  61. data/theme/pdf/pdf.css +3 -0
  62. data/theme/pdf/toc.xsl +81 -0
  63. data/theme/share/default.css +174 -0
  64. data/theme/share/highlight.css +216 -0
  65. data/theme/share/normalize.css +349 -0
  66. metadata +119 -21
  67. data/.gitignore +0 -9
  68. data/.travis.yml +0 -4
  69. data/Gemfile +0 -4
  70. data/README.md +0 -41
  71. data/Rakefile +0 -10
  72. data/asciibook.gemspec +0 -25
@@ -0,0 +1,29 @@
1
+ (function() {
2
+ document.querySelectorAll('.dropdown-toggle').forEach(function(element){
3
+ var dropdown = element.closest('.dropdown')
4
+
5
+ function openMenu() {
6
+ dropdown.classList.add('open')
7
+ document.addEventListener('click', closeMenuOutside);
8
+ }
9
+
10
+ function closeMenu() {
11
+ dropdown.classList.remove('open');
12
+ document.removeEventListener('click', closeMenuOutside);
13
+ }
14
+
15
+ function closeMenuOutside(event) {
16
+ if (!dropdown.contains(event.target)) {
17
+ closeMenu();
18
+ }
19
+ }
20
+
21
+ element.addEventListener('click', function() {
22
+ if (dropdown.classList.contains('open')) {
23
+ closeMenu();
24
+ } else {
25
+ openMenu();
26
+ }
27
+ });
28
+ })
29
+ })();
@@ -0,0 +1,91 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{ page.title }} - {{ book.title }}</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
+ <link rel="stylesheet" href="normalize.css" />
8
+ <link rel="stylesheet" href="default.css" />
9
+ <link rel="stylesheet" href="highlight.css" />
10
+ <link rel="stylesheet" href="html.css" />
11
+ <script src="html.js" defer></script>
12
+ </head>
13
+ <body>
14
+ <div id="drawer" class="drawer" style="display: none;">
15
+ <div class="drawer-content">
16
+ <div class="heading">
17
+ Table of Contents
18
+ </div>
19
+ <div class="nav">
20
+ {% if book.toc[0] %}
21
+ <ol>
22
+ {% for item in book.toc %}
23
+ <li class="nav-item">
24
+ <a href="{{ item.path }}">{{ item.title }}</a>
25
+ {% if item.items %}
26
+ <ol>
27
+ {% for subitem in item.items %}
28
+ <li class="nav-item">
29
+ <a href="{{ subitem.path }}">{{ subitem.title }}</a>
30
+ </li>
31
+ {% endfor %}
32
+ </ol>
33
+ {% endif %}
34
+ </li>
35
+ {% endfor %}
36
+ </ol>
37
+ {% endif %}
38
+ </div>
39
+ </div>
40
+ <div id="drawer-backdrop" class="drawer-backdrop">
41
+ </div>
42
+ </div>
43
+ <div class="toolbar">
44
+ <div class="toolbar-title">
45
+ <a href="index.html">
46
+ {{ book.title }}
47
+ </a>
48
+ </div>
49
+ <div class="toolbar-action">
50
+ <div class="dropdown">
51
+ <button id="drawer-button" type="button" class="dropdown-toggle button button-icon">
52
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 9h14V7H3v2zm0 4h14v-2H3v2zm0 4h14v-2H3v2zm16 0h2v-2h-2v2zm0-10v2h2V7h-2zm0 6h2v-2h-2v2z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
53
+ </button>
54
+ <div id="toolbar-toc" class="dropdown-menu">
55
+ {% if book.toc[0] %}
56
+ <ol>
57
+ {% for item in book.toc %}
58
+ <li>
59
+ <a class="dropdown-menu-item" href="{{ item.path }}">{{ item.title }}</a>
60
+ {% if item.items %}
61
+ <ol>
62
+ {% for subitem in item.items %}
63
+ <li>
64
+ <a class="dropdown-menu-item" href="{{ subitem.path }}">{{ subitem.title }}</a>
65
+ </li>
66
+ {% endfor %}
67
+ </ol>
68
+ {% endif %}
69
+ </li>
70
+ {% endfor %}
71
+ </ol>
72
+ {% endif %}
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ <div class="main">
78
+ <div class="content">
79
+ {{ page.content }}
80
+ </div>
81
+ <div class="paginator">
82
+ <a href="{{ page.prev_page.path }}" class="paginator-prev {% if page.prev_page == nil %} disabled {% endif %}">
83
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
84
+ </a>
85
+ <a href="{{ page.next_page.path }}" class="paginator-next {% if page.next_page == nil %} disabled {% endif %}">
86
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
87
+ </a>
88
+ </div>
89
+ </div>
90
+ </body>
91
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8"/>
5
+ <title>{{ page.title }} - {{ book.title }}</title>
6
+ <link rel="stylesheet" type="text/css" href="default.css" />
7
+ <link rel="stylesheet" type="text/css" href="highlight.css" />
8
+ <link rel="stylesheet" type="text/css" href="mobi.css" />
9
+ </head>
10
+ <body>
11
+ {{ page.content }}
12
+ </body>
13
+ </html>
@@ -0,0 +1,2 @@
1
+ body {
2
+ }
@@ -0,0 +1,6 @@
1
+ margin_top: 20
2
+ margin_left: 20
3
+ margin_right: 20
4
+ margin_bottom: 20
5
+ header_spacing: 0
6
+ footer_spacing: 8
@@ -0,0 +1,11 @@
1
+ <!--
2
+ Avaliable data class: 'page', 'frompage', 'topage', 'webpage', 'section', 'subsection', 'date', 'isodate', 'time', 'title', 'doctitle', 'sitepage', 'sitepages'
3
+ -->
4
+ <style>
5
+ .footer {
6
+ text-align: right;
7
+ }
8
+ </style>
9
+ <div class="footer">
10
+ <span class="section"></span> &middot; <span class="page"></span>
11
+ </div>
@@ -0,0 +1,3 @@
1
+ <!--
2
+ Avaliable data class: 'page', 'frompage', 'topage', 'webpage', 'section', 'subsection', 'date', 'isodate', 'time', 'title', 'doctitle', 'sitepage', 'sitepages'
3
+ -->
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{ book.title }}</title>
6
+ <link rel="stylesheet" href="normalize.css" />
7
+ <link rel="stylesheet" href="default.css" />
8
+ <link rel="stylesheet" href="highlight.css" />
9
+ <link rel="stylesheet" href="pdf.css">
10
+ </head>
11
+ <body>
12
+ {{ page.content }}
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ body {
2
+ font-size: 1.2em;
3
+ }
@@ -0,0 +1,81 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet version="2.0"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
+ xmlns:outline="http://wkhtmltopdf.org/outline"
5
+ xmlns="http://www.w3.org/1999/xhtml">
6
+ <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
7
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
8
+ indent="yes" />
9
+ <xsl:template match="outline:outline">
10
+ <html>
11
+ <head>
12
+ <title>{{ book.title }}</title>
13
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
14
+ <style>
15
+ ol {
16
+ padding: 0;
17
+ font-size: 120%;
18
+ }
19
+
20
+ ol ol {
21
+ padding-left: 1em;
22
+ font-size: 100%;
23
+ }
24
+
25
+ ol ol ol {
26
+ display: none;
27
+ }
28
+
29
+ li {
30
+ list-style: none;
31
+ }
32
+
33
+ a {
34
+ display: -webkit-box;
35
+ display: flex;
36
+ color: #333;
37
+ text-decoration: none;
38
+ margin: 0.5em 0;
39
+ page-break-inside: avoid;
40
+ }
41
+
42
+ a .dotted {
43
+ -webkit-box-flex: 1;
44
+ flex-grow: 1;
45
+ border-bottom: 2px dotted #333;
46
+ margin: 0.5em;
47
+ }
48
+
49
+ .title, .page {
50
+ white-space: nowrap;
51
+ }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <h1>{{ page.title }}</h1>
56
+ <ol><xsl:apply-templates select="outline:item/outline:item"/></ol>
57
+ </body>
58
+ </html>
59
+ </xsl:template>
60
+ <xsl:template match="outline:item">
61
+ <li>
62
+ <xsl:if test="@title!=''">
63
+ <a>
64
+ <xsl:if test="@link">
65
+ <xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
66
+ </xsl:if>
67
+ <xsl:if test="@backLink">
68
+ <xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
69
+ </xsl:if>
70
+ <div class="title"><xsl:value-of select="@title" /></div>
71
+ <div class="dotted"><xsl:comment>added to prevent self-closing tags in QtXmlPatterns</xsl:comment></div>
72
+ <div class="page"><xsl:value-of select="@page" /></div>
73
+ </a>
74
+ </xsl:if>
75
+ <ol>
76
+ <xsl:comment>added to prevent self-closing tags in QtXmlPatterns</xsl:comment>
77
+ <xsl:apply-templates select="outline:item"/>
78
+ </ol>
79
+ </li>
80
+ </xsl:template>
81
+ </xsl:stylesheet>
@@ -0,0 +1,174 @@
1
+ html {
2
+ }
3
+
4
+ body {
5
+ line-height: 1.5;
6
+ font-size: 1em;
7
+ color: #333;
8
+ }
9
+
10
+ h1, h2, h3, h4, h5, h6 {
11
+ margin: 1.5em 0 1em;
12
+ color: #c62828;
13
+ }
14
+
15
+ h1 {
16
+ font-size: 2em;
17
+ }
18
+
19
+ h2 {
20
+ font-size: 1.75em;
21
+ }
22
+
23
+ h3 {
24
+ font-size: 1.5em;
25
+ }
26
+
27
+ h4 {
28
+ font-size: 1.25em;
29
+ }
30
+
31
+ h5, h6 {
32
+ font-size: 1em;
33
+ }
34
+
35
+ a {
36
+ color: #3f51b5;
37
+ }
38
+
39
+ a:hover {
40
+ color: #303f9f;
41
+ }
42
+
43
+ img {
44
+ max-width: 100%;
45
+ line-height: 1;
46
+ }
47
+
48
+ pre {
49
+ line-height: 1.2;
50
+ margin: 1em 0;
51
+ background-color: #f8f8f8;
52
+ padding: 1em;
53
+ white-space: pre-wrap;
54
+ }
55
+
56
+ .toc ol {
57
+ list-style: none;
58
+ padding: 0;
59
+ margin: 0;
60
+ }
61
+
62
+ .toc ol ol {
63
+ padding-left: 1em;
64
+ }
65
+
66
+ .toc a {
67
+ display: block;
68
+ padding: 0.5em 0;
69
+ text-decoration: none;
70
+ }
71
+
72
+ ul, ol {
73
+ }
74
+
75
+ a.callout {
76
+ display: inline-block;
77
+ background: #333;
78
+ color: white;
79
+ border-radius: 50%;
80
+ font-size: 0.75em;
81
+ line-height: 1.5em;
82
+ width: 1.5em;
83
+ text-decoration: none;
84
+ text-align: center;
85
+ }
86
+
87
+ ul.colist {
88
+ list-style: none;
89
+ padding: 0;
90
+ margin: 1em 0;
91
+ }
92
+
93
+ figure {
94
+ margin: 1em 0;
95
+ }
96
+
97
+ figure.image {
98
+ text-align: center;
99
+ }
100
+
101
+ figcaption {
102
+ font-style: italic;
103
+ }
104
+
105
+ .example {
106
+ margin: 1em 0;
107
+ padding: 1em;
108
+ background: #eee;
109
+ }
110
+
111
+ .example > *:first-child {
112
+ margin-top: 0;
113
+ }
114
+
115
+ .example > *:last-child {
116
+ margin-bottom: 0;
117
+ }
118
+
119
+ .sidebar {
120
+ margin: 1em 0;
121
+ padding: 1em;
122
+ background: #eee;
123
+ }
124
+
125
+ .sidebar > *:first-child {
126
+ margin-top: 0;
127
+ }
128
+
129
+ .sidebar > *:last-child {
130
+ margin-bottom: 0;
131
+ }
132
+
133
+ table {
134
+ width: 100%;
135
+ margin: 1em 0;
136
+ text-align: left;
137
+ border-collapse: collapse;
138
+ }
139
+
140
+ table caption {
141
+ text-align: left;
142
+ font-style: italic;
143
+ }
144
+
145
+ table thead th {
146
+ border-bottom: 2px solid #ccc;
147
+ padding: 0.75em;
148
+ }
149
+
150
+ table tbody td {
151
+ border-bottom: 1px solid #ccc;
152
+ padding: 0.75em;
153
+ }
154
+
155
+ blockquote {
156
+ padding: 1em;
157
+ margin: 1em 0;
158
+ border-left: 2px solid #ccc;
159
+ background: #eee;
160
+ }
161
+
162
+ blockquote > *:first-child {
163
+ margin-top: 0;
164
+ }
165
+
166
+ blockquote > *:last-child {
167
+ margin-bottom: 0;
168
+ }
169
+
170
+ footer {
171
+ border-top: 1px solid #ccc;
172
+ margin-top: 1.5em;
173
+ padding-top: 1em;
174
+ }
@@ -0,0 +1,216 @@
1
+ .highlight {
2
+ padding: 1em;
3
+ }
4
+ .highlight table td {
5
+ padding: 5px;
6
+ }
7
+ .highlight table pre {
8
+ margin: 0;
9
+ }
10
+ .highlight .cm {
11
+ color: #999988;
12
+ font-style: italic;
13
+ }
14
+ .highlight .cp {
15
+ color: #999999;
16
+ font-weight: bold;
17
+ }
18
+ .highlight .c1 {
19
+ color: #999988;
20
+ font-style: italic;
21
+ }
22
+ .highlight .cs {
23
+ color: #999999;
24
+ font-weight: bold;
25
+ font-style: italic;
26
+ }
27
+ .highlight .c, .highlight .ch, .highlight .cd, .highlight .cpf {
28
+ color: #999988;
29
+ font-style: italic;
30
+ }
31
+ .highlight .err {
32
+ color: #a61717;
33
+ background-color: #e3d2d2;
34
+ }
35
+ .highlight .gd {
36
+ color: #000000;
37
+ background-color: #ffdddd;
38
+ }
39
+ .highlight .ge {
40
+ color: #000000;
41
+ font-style: italic;
42
+ }
43
+ .highlight .gr {
44
+ color: #aa0000;
45
+ }
46
+ .highlight .gh {
47
+ color: #999999;
48
+ }
49
+ .highlight .gi {
50
+ color: #000000;
51
+ background-color: #ddffdd;
52
+ }
53
+ .highlight .go {
54
+ color: #888888;
55
+ }
56
+ .highlight .gp {
57
+ color: #555555;
58
+ }
59
+ .highlight .gs {
60
+ font-weight: bold;
61
+ }
62
+ .highlight .gu {
63
+ color: #aaaaaa;
64
+ }
65
+ .highlight .gt {
66
+ color: #aa0000;
67
+ }
68
+ .highlight .kc {
69
+ color: #000000;
70
+ font-weight: bold;
71
+ }
72
+ .highlight .kd {
73
+ color: #000000;
74
+ font-weight: bold;
75
+ }
76
+ .highlight .kn {
77
+ color: #000000;
78
+ font-weight: bold;
79
+ }
80
+ .highlight .kp {
81
+ color: #000000;
82
+ font-weight: bold;
83
+ }
84
+ .highlight .kr {
85
+ color: #000000;
86
+ font-weight: bold;
87
+ }
88
+ .highlight .kt {
89
+ color: #445588;
90
+ font-weight: bold;
91
+ }
92
+ .highlight .k, .highlight .kv {
93
+ color: #000000;
94
+ font-weight: bold;
95
+ }
96
+ .highlight .mf {
97
+ color: #009999;
98
+ }
99
+ .highlight .mh {
100
+ color: #009999;
101
+ }
102
+ .highlight .il {
103
+ color: #009999;
104
+ }
105
+ .highlight .mi {
106
+ color: #009999;
107
+ }
108
+ .highlight .mo {
109
+ color: #009999;
110
+ }
111
+ .highlight .m, .highlight .mb, .highlight .mx {
112
+ color: #009999;
113
+ }
114
+ .highlight .sb {
115
+ color: #d14;
116
+ }
117
+ .highlight .sc {
118
+ color: #d14;
119
+ }
120
+ .highlight .sd {
121
+ color: #d14;
122
+ }
123
+ .highlight .s2 {
124
+ color: #d14;
125
+ }
126
+ .highlight .se {
127
+ color: #d14;
128
+ }
129
+ .highlight .sh {
130
+ color: #d14;
131
+ }
132
+ .highlight .si {
133
+ color: #d14;
134
+ }
135
+ .highlight .sx {
136
+ color: #d14;
137
+ }
138
+ .highlight .sr {
139
+ color: #009926;
140
+ }
141
+ .highlight .s1 {
142
+ color: #d14;
143
+ }
144
+ .highlight .ss {
145
+ color: #990073;
146
+ }
147
+ .highlight .s, .highlight .sa, .highlight .dl {
148
+ color: #d14;
149
+ }
150
+ .highlight .na {
151
+ color: #008080;
152
+ }
153
+ .highlight .bp {
154
+ color: #999999;
155
+ }
156
+ .highlight .nb {
157
+ color: #0086B3;
158
+ }
159
+ .highlight .nc {
160
+ color: #445588;
161
+ font-weight: bold;
162
+ }
163
+ .highlight .no {
164
+ color: #008080;
165
+ }
166
+ .highlight .nd {
167
+ color: #3c5d5d;
168
+ font-weight: bold;
169
+ }
170
+ .highlight .ni {
171
+ color: #800080;
172
+ }
173
+ .highlight .ne {
174
+ color: #990000;
175
+ font-weight: bold;
176
+ }
177
+ .highlight .nf, .highlight .fm {
178
+ color: #990000;
179
+ font-weight: bold;
180
+ }
181
+ .highlight .nl {
182
+ color: #990000;
183
+ font-weight: bold;
184
+ }
185
+ .highlight .nn {
186
+ color: #555555;
187
+ }
188
+ .highlight .nt {
189
+ color: #000080;
190
+ }
191
+ .highlight .vc {
192
+ color: #008080;
193
+ }
194
+ .highlight .vg {
195
+ color: #008080;
196
+ }
197
+ .highlight .vi {
198
+ color: #008080;
199
+ }
200
+ .highlight .nv, .highlight .vm {
201
+ color: #008080;
202
+ }
203
+ .highlight .ow {
204
+ color: #000000;
205
+ font-weight: bold;
206
+ }
207
+ .highlight .o {
208
+ color: #000000;
209
+ font-weight: bold;
210
+ }
211
+ .highlight .w {
212
+ color: #bbbbbb;
213
+ }
214
+ .highlight {
215
+ background-color: #f8f8f8;
216
+ }