book-source 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,8 +28,8 @@
28
28
 
29
29
 
30
30
 
31
- const HtmlRenderer = require( './HtmlRenderer.js' ) ;
32
31
  const Style = require( './Style.js' ) ;
32
+ const Theme = require( './Theme.js' ) ;
33
33
 
34
34
  const emoji = require( 'string-kit/lib/emoji.js' ) ;
35
35
  const inPlaceFilter = require( 'array-kit/lib/inPlaceFilter.js' ) ;
@@ -47,12 +47,6 @@ module.exports = StructuredDocument ;
47
47
 
48
48
 
49
49
 
50
- StructuredDocument.prototype.toHtml = function( theme , params ) {
51
- return this.render( new HtmlRenderer( theme , params ) ) ;
52
- } ;
53
-
54
-
55
-
56
50
  StructuredDocument.prototype.render = function( renderer ) {
57
51
  var meta = {
58
52
  title: this.title
package/lib/Style.js CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
 
30
30
 
31
- const Color = require( './Color.js' ) ;
31
+ const Color = require( 'palette-shade' ).Color ;
32
32
 
33
33
 
34
34
 
@@ -44,6 +44,12 @@ module.exports = Style ;
44
44
 
45
45
 
46
46
 
47
+ Style.prototype.merge = function( ... styles ) {
48
+ return Style.merge( this , ... styles ) ;
49
+ } ;
50
+
51
+
52
+
47
53
  Style.merge = function( ... styles ) {
48
54
  var mergedStyle = new Style() ;
49
55
 
package/lib/Theme.js CHANGED
@@ -28,8 +28,9 @@
28
28
 
29
29
 
30
30
 
31
- const Palette = require( './Palette.js' ) ;
32
- const Color = require( './Color.js' ) ;
31
+ const paletteShade = require( 'palette-shade' ) ;
32
+ const Color = paletteShade.Color ;
33
+ const Palette = paletteShade.Palette ;
33
34
 
34
35
 
35
36
 
@@ -33,36 +33,12 @@ module.exports = bookSource ;
33
33
 
34
34
  bookSource.StructuredDocument = require( './StructuredDocument.js' ) ;
35
35
  bookSource.Style = require( './Style.js' ) ;
36
- bookSource.Color = require( './Color.js' ) ;
37
-
38
- bookSource.Palette = require( './Palette.js' ) ;
39
36
  bookSource.Theme = require( './Theme.js' ) ;
40
- bookSource.HtmlRenderer = require( './HtmlRenderer.js' ) ;
41
-
42
- bookSource.parse = bookSource.StructuredDocument.parse ;
43
-
44
-
45
37
 
46
- const path = require( 'path' ) ;
38
+ // Exposed external lib
39
+ const paletteShade = require( 'palette-shade' ) ;
40
+ bookSource.Color = paletteShade.Color ;
41
+ bookSource.Palette = paletteShade.Palette ;
47
42
 
48
- bookSource.getBuiltinCssPath = type => {
49
- switch ( type ) {
50
- case 'core' :
51
- case 'standalone' :
52
- case 'code' :
53
- return path.join( __dirname , '..' , 'css' , type + '.css' ) ;
54
- }
55
-
56
- throw new Error( "There is no built-in CSS of type '" + type + "'" ) ;
57
- } ;
58
-
59
- bookSource.getBuiltinCssSync = type => {
60
- const fs = require( 'fs' ) ;
61
- return fs.readFileSync( bookSource.getBuiltinCssPath( type ) , 'utf8' ) ;
62
- } ;
63
-
64
- bookSource.getBuiltinCss = type => {
65
- const fs = require( 'fs' ) ;
66
- return fs.promises.readFile( bookSource.getBuiltinCssPath( type ) , 'utf8' ) ;
67
- } ;
43
+ bookSource.parse = bookSource.StructuredDocument.parse ;
68
44
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "book-source",
3
- "version": "0.1.1",
4
- "description": "A lightweight markup language, inspired by Markdown",
3
+ "version": "0.2.0",
4
+ "description": "A lightweight markup language, inspired by Markdown.",
5
5
  "main": "lib/book-source.js",
6
6
  "directories": {
7
7
  "test": "test"
8
8
  },
9
9
  "dependencies": {
10
10
  "array-kit": "^0.2.6",
11
- "highlight.js": "^11.9.0",
11
+ "palette-shade": "^0.1.1",
12
12
  "string-kit": "^0.18.0"
13
13
  },
14
14
  "scripts": {
@@ -19,7 +19,9 @@
19
19
  "url": "https://github.com/cronvel/book-source.git"
20
20
  },
21
21
  "keywords": [
22
+ "lightweight",
22
23
  "markup",
24
+ "language",
23
25
  "book",
24
26
  "source"
25
27
  ],
@@ -34,5 +36,8 @@
34
36
  2023
35
37
  ],
36
38
  "owner": "Cédric Ronvel"
39
+ },
40
+ "engines": {
41
+ "node": ">=14.15.0"
37
42
  }
38
43
  }
package/css/code.css DELETED
@@ -1,120 +0,0 @@
1
- .book-source .hljs {
2
- display: block;
3
- padding: 0.5em;
4
- color: #333;
5
- background: #f8f8f8;
6
- }
7
-
8
- .book-source .hljs-comment ,
9
- .book-source .hljs-template_comment ,
10
- .book-source .diff .hljs-header ,
11
- .book-source .hljs-javadoc {
12
- color: #998;
13
- font-style: italic;
14
- }
15
-
16
- .book-source .hljs-keyword ,
17
- .book-source .css .rule .hljs-keyword ,
18
- .book-source .hljs-winutils ,
19
- .book-source .javascript .hljs-title ,
20
- .book-source .nginx .hljs-title ,
21
- .book-source .hljs-subst ,
22
- .book-source .hljs-request ,
23
- .book-source .hljs-status {
24
- color: #333;
25
- font-weight: bold;
26
- }
27
-
28
- .book-source .hljs-number ,
29
- .book-source .hljs-hexcolor ,
30
- .book-source .ruby .hljs-constant {
31
- color: #099;
32
- }
33
-
34
- .book-source .hljs-string ,
35
- .book-source .hljs-tag .hljs-value ,
36
- .book-source .hljs-phpdoc ,
37
- .book-source .tex .hljs-formula {
38
- color: #d14;
39
- }
40
-
41
- .book-source .hljs-title ,
42
- .book-source .hljs-id ,
43
- .book-source .coffeescript .hljs-params ,
44
- .book-source .scss .hljs-preprocessor {
45
- color: #900;
46
- font-weight: bold;
47
- }
48
-
49
- .book-source .javascript .hljs-title ,
50
- .book-source .lisp .hljs-title ,
51
- .book-source .clojure .hljs-title ,
52
- .book-source .hljs-subst {
53
- font-weight: normal;
54
- }
55
-
56
- .book-source .hljs-class .hljs-title ,
57
- .book-source .haskell .hljs-type ,
58
- .book-source .vhdl .hljs-literal ,
59
- .book-source .tex .hljs-command {
60
- color: #458;
61
- font-weight: bold;
62
- }
63
-
64
- .book-source .hljs-tag ,
65
- .book-source .hljs-tag .hljs-title ,
66
- .book-source .hljs-rules .hljs-property ,
67
- .book-source .django .hljs-tag .hljs-keyword {
68
- color: #000080;
69
- font-weight: normal;
70
- }
71
-
72
- .book-source .hljs-attribute ,
73
- .book-source .hljs-variable ,
74
- .book-source .lisp .hljs-body {
75
- color: #008080;
76
- }
77
-
78
- .book-source .hljs-regexp {
79
- color: #009926;
80
- }
81
-
82
- .book-source .hljs-symbol ,
83
- .book-source .ruby .hljs-symbol .hljs-string ,
84
- .book-source .lisp .hljs-keyword ,
85
- .book-source .tex .hljs-special ,
86
- .book-source .hljs-prompt {
87
- color: #990073;
88
- }
89
-
90
- .book-source .hljs-built_in ,
91
- .book-source .lisp .hljs-title ,
92
- .book-source .clojure .hljs-built_in {
93
- color: #0086b3;
94
- }
95
-
96
- .book-source .hljs-preprocessor ,
97
- .book-source .hljs-pragma ,
98
- .book-source .hljs-pi ,
99
- .book-source .hljs-doctype ,
100
- .book-source .hljs-shebang ,
101
- .book-source .hljs-cdata {
102
- color: #999;
103
- font-weight: bold;
104
- }
105
-
106
- .book-source .hljs-deletion {
107
- background: #fdd;
108
- }
109
-
110
- .book-source .hljs-addition {
111
- background: #dfd;
112
- }
113
-
114
- .book-source .diff .hljs-change {
115
- background: #0086b3;
116
- }
117
-
118
- .book-source .hljs-chunk {
119
- color: #aaa;
120
- }
package/css/core.css DELETED
@@ -1,317 +0,0 @@
1
-
2
- /* General */
3
-
4
- .book-source {
5
- font-family: var(--main-font);
6
- font-size: var(--text-size);
7
- color: var(--text-color);
8
- background-color: var(--background-color);
9
- word-wrap: break-word;
10
- }
11
-
12
-
13
-
14
- /* Text */
15
-
16
- .book-source em { font-style: italic; }
17
- .book-source strong { font-weight: bold; }
18
- .book-source .bold { font-weight: bold; }
19
- .book-source .italic { font-style: italic; }
20
- .book-source .underline { text-decoration: underline; }
21
- .book-source .title-tooltip { cursor: help; }
22
-
23
- .book-source .align-left { text-align: left; }
24
- .book-source .align-right { text-align: right; }
25
- .book-source .align-center { text-align: center; }
26
- .book-source .align-justify { text-align: justify; }
27
-
28
-
29
- .book-source p {
30
- line-height: var(--line-height-size);
31
- margin: 1em 0;
32
- text-align: justify;
33
- }
34
-
35
- .book-source a {
36
- color: var(--link-text-color);
37
- text-decoration: none;
38
- }
39
-
40
- .book-source a:visited {
41
- color: var(--visited-link-text-color);
42
- }
43
-
44
- .book-source a:hover {
45
- color: var(--hover-link-text-color);
46
- text-decoration: underline;
47
- }
48
-
49
- .book-source a:active ,
50
- .book-source a:hover {
51
- outline: 0 none;
52
- }
53
-
54
- .book-source h1 { font-size: 2.6em ; }
55
- .book-source h2 { font-size: 2em ; }
56
- .book-source h3 { font-size: 1.6em ; }
57
- .book-source h4 { font-size: 1.25em ; }
58
- .book-source h5 { font-size: 1em ; }
59
- .book-source h6 { font-size: 0.8em ; }
60
-
61
- .book-source h1 {
62
- margin: 2em 0 3em 0;
63
- text-align: center;
64
- }
65
-
66
- .book-source h2 ,
67
- .book-source h3 {
68
- margin: 2em 0 1em 0;
69
- border-bottom: 1px solid var(--header-rule-color);
70
- }
71
-
72
- .book-source h4 ,
73
- .book-source h5 ,
74
- .book-source h6 {
75
- margin: 0.5em 0 0 0;
76
- text-decoration: underline;
77
- }
78
-
79
-
80
-
81
- /* Lists */
82
-
83
- .book-source ul ,
84
- .book-source ol ,
85
- .book-source dl {
86
- margin: 1em 0;
87
- padding: 0 40px;
88
- }
89
-
90
- .book-source li ul ,
91
- .book-source li ol ,
92
- .book-source li dl {
93
- margin: 0.5em 0;
94
- }
95
-
96
- .book-source ul li ,
97
- .book-source ol li ,
98
- .book-source dl li {
99
- line-height: var(--line-height-size);
100
- text-align: justify;
101
- }
102
-
103
-
104
-
105
- /* Quote */
106
-
107
- .book-source blockquote {
108
- font-size: 1.1em;
109
- margin: 1em 0;
110
- padding: 0.25em 2em;
111
- border-radius: 0.5em;
112
- background-color: var(--quote-background-color);
113
- }
114
-
115
- .book-source blockquote blockquote {
116
- background-color: var(--quote2-background-color);
117
- }
118
-
119
- .book-source blockquote blockquote blockquote {
120
- background-color: var(--quote3-background-color);
121
- }
122
-
123
- .book-source blockquote cite {
124
- display: block;
125
- text-align: right;
126
- margin-right: 10%;
127
- }
128
-
129
- .book-source blockquote cite::before {
130
- content: "-- ";
131
- }
132
-
133
-
134
-
135
- /* Code */
136
-
137
- .book-source code {
138
- background-color: var(--code-background-color);
139
- border: 1px solid var(--code-border-color);
140
- border-radius: 3px;
141
- margin: 0 2px;
142
- padding: 2px 4px;
143
- line-height: var(--line-height-size);
144
- }
145
-
146
- .book-source pre {
147
- background-color: var(--code-background-color);
148
- border: 1px solid var(--code-border-color);
149
- border-radius: 3px;
150
- margin: 15px 0;
151
- padding: 6px 10px;
152
- line-height: var(--code-line-height-size);
153
- }
154
-
155
- .book-source pre code {
156
- border: none;
157
- margin: 0;
158
- padding: 0;
159
- }
160
-
161
-
162
-
163
- /* Block media */
164
-
165
- .book-source figure {
166
- display: table;
167
- margin: 10px auto;
168
- width: 1px;
169
- border-collapse: collapse;
170
- }
171
-
172
- .book-source figure.float {
173
- margin: 2px 2px 10px 2px;
174
- clear: both;
175
- }
176
-
177
- .book-source figure.float-left { margin-right: 20px; }
178
- .book-source figure.float-right { margin-left: 20px; }
179
-
180
- .book-source figure img {
181
- display: table-row;
182
- vertical-align: bottom;
183
- }
184
-
185
- .book-source figure figcaption {
186
- display: table-row;
187
- text-align: center;
188
- font-style: italic;
189
- background-color: var(--figure-caption-background-color);
190
- }
191
-
192
- .book-source .float-left { float: left; }
193
- .book-source .float-right { float: right; }
194
- .book-source .clear-float { clear: both; }
195
-
196
-
197
-
198
- /* Tables */
199
-
200
- .book-source table {
201
- display: table;
202
- margin: 1.5em auto;
203
- max-width: 90%;
204
- width: auto;
205
- overflow: auto;
206
- border-spacing: 0;
207
- border-collapse: collapse;
208
- }
209
-
210
- .book-source table caption {
211
- caption-side: top;
212
- text-align: center;
213
- background-color: var(--table-caption-background-color);
214
- color: var(--table-caption-text-color);
215
- font-size: 1.1em;
216
- font-weight: bold;
217
- border: 1px solid var(--table-border-color);
218
- padding: 6px 13px;
219
- }
220
-
221
- .book-source table th:not([scope]) {
222
- background-color: var(--table-both-head-color);
223
- border-top: 1px solid var(--table-border-color);
224
- border-bottom: 2px solid var(--table-border-color);
225
- border-right: 2px solid var(--table-border-color);
226
- }
227
-
228
- .book-source table th[scope="column"] {
229
- background-color: var(--table-column-head-color);
230
- border-top: 1px solid var(--table-border-color);
231
- border-bottom: 2px solid var(--table-border-color);
232
- }
233
-
234
- .book-source table th[scope="row"] {
235
- background-color: var(--table-row-head-color);
236
- border-right: 2px solid var(--table-border-color);
237
- }
238
-
239
- .book-source table tbody tr {
240
- background-color: var(--table-row-background-color);
241
- border-top: 1px solid var(--table-border-color);
242
- }
243
-
244
- .book-source table th.row-separator, .book-source table tr.row-separator {
245
- border-bottom: 6px solid var(--table-border-color);
246
- }
247
-
248
- .book-source table tbody tr:nth-child(2n):not(.bg-styled) {
249
- background-color: var(--table-even-row-background-color);
250
- }
251
-
252
- .book-source table th, .book-source table td {
253
- padding: 6px 13px;
254
- border: 1px solid var(--table-border-color);
255
- }
256
-
257
- .book-source table th.column-separator, .book-source table td.column-separator {
258
- border-right: 6px solid var(--table-border-color);
259
- }
260
-
261
- .book-source table td img {
262
- max-width: 100%;
263
- }
264
-
265
-
266
-
267
- /* Print / PDF */
268
-
269
- @media print {
270
- .book-source {
271
- font-size: var(--text-size);
272
- }
273
-
274
- .book-source h1 {
275
- break-before: page;
276
- break-after: avoid-page;
277
- break-inside: avoid-page;
278
- }
279
-
280
- .book-source h2, .book-source h3, .book-source h4, .book-source h5, .book-source h6 {
281
- break-after: avoid-page;
282
- break-inside: avoid-page;
283
- }
284
-
285
- .book-source p {
286
- line-height: var(--line-height-printsize);
287
- break-inside: auto;
288
- widows: 3;
289
- orphans: 3;
290
- }
291
-
292
- .book-source blockquote { break-inside: avoid-page; }
293
- .book-source cite { break-inside: avoid-page; }
294
- .book-source blockquote cite { break-inside: avoid-page; }
295
- .book-source table { break-inside: avoid-page; }
296
-
297
- .book-source ul ,
298
- .book-source ol ,
299
- .book-source dl {
300
- break-before: avoid-page;
301
- break-inside: avoid-page;
302
- }
303
-
304
- .book-source ul li {
305
- line-height: var(--line-height-printsize);
306
- break-inside: avoid-page;
307
- }
308
-
309
- .book-source code {
310
- line-height: var(--line-height-printsize);
311
- }
312
-
313
- .book-source pre {
314
- line-height: var(--code-line-height-printsize);
315
- }
316
- }
317
-
@@ -1,30 +0,0 @@
1
- body {
2
- background-color: var(--background-color);
3
- padding: 30px 0 80px 0;
4
- }
5
-
6
- .book-source {
7
- max-width: 800px;
8
- margin-left:auto;
9
- margin-right:auto;
10
- padding: 15px;
11
- }
12
-
13
- @media print {
14
- body {
15
- padding: 0;
16
- margin: 0;
17
- background-color: #fff;
18
- }
19
-
20
- .book-source {
21
- max-width: 100%;
22
- padding: 0;
23
- }
24
-
25
- html, body, div {
26
- page-break-inside: auto;
27
- break-inside: auto;
28
- }
29
- }
30
-
@@ -1,65 +0,0 @@
1
-
2
- /* Checkboxes */
3
-
4
- .book-source ul.todo-list {
5
- display: table;
6
- max-width: 50%;
7
- min-width: 10%;
8
- background-color: #f6f3c0;
9
- border-radius: 0.5em;
10
- padding-top: 0.6em;
11
- padding-bottom: 0.6em;
12
- padding-right: 2em;
13
- padding-left: 4em; /* =~ 2 + 1 + ( 1.75 + 0.3 ) / 2 */
14
- }
15
-
16
- .book-source ul.todo-list li {
17
- text-indent: -1.6em; /* = 1.75 - 0.3 / 2 */
18
- line-height: 1.2;
19
- }
20
-
21
- .book-source ul li.unchecked {
22
- list-style: none;
23
- }
24
-
25
- .book-source ul li.unchecked::before {
26
- content: '☐';
27
- font-size: 1.75em;
28
- position: relative;
29
- top: 0.15em;
30
- right: 0.3em;
31
- }
32
-
33
- .book-source ul li.checked {
34
- list-style: none;
35
- }
36
-
37
- .book-source ul li.checked::before {
38
- content: '☑';
39
- color: green;
40
- font-size: 1.75em;
41
- position: relative;
42
- top: 0.15em;
43
- right: 0.3em;
44
- }
45
-
46
-
47
-
48
- /* Sections and columns */
49
-
50
- .book-source section {
51
- display: flex;
52
- clear: both;
53
- }
54
-
55
- .book-source div.column , .book-source column {
56
- flex: 1;
57
- padding: 0 10px;
58
- max-width: 100%;
59
- box-sizing: border-box;
60
- }
61
-
62
- .book-source div.column:nth-last-child(n+2) , .book-source column:nth-last-child(n+2) {
63
- border-right: 1px solid #c6cbd1;
64
- }
65
-