book-source 0.1.1

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.
package/.eslintrc.js ADDED
@@ -0,0 +1,168 @@
1
+ module.exports = {
2
+ 'root': true ,
3
+ 'env': {
4
+ 'browser': true ,
5
+ 'node': true ,
6
+ 'es6': true ,
7
+ 'es2022': true
8
+ } ,
9
+ 'parserOptions': {
10
+ 'ecmaVersion': 2022
11
+ } ,
12
+ 'extends': [ 'eslint:recommended' ] ,
13
+ 'ignorePatterns': [ "*.min.js" ] ,
14
+ 'rules': {
15
+
16
+ /*
17
+ Bad code -- detect anything that can be broken or lead to bugs
18
+ */
19
+
20
+
21
+
22
+ 'strict': [ 'error' , 'global' ] ,
23
+ 'unicode-bom': [ 'error' , 'never' ] ,
24
+ 'radix': 'error' ,
25
+ 'eqeqeq': 'error' ,
26
+ 'consistent-return': 'off' ,
27
+ 'valid-typeof': 'error' ,
28
+ 'no-unneeded-ternary': 'error' ,
29
+ 'no-unused-vars': 'warn' , // During development phase, it's boring to clean unused var since they can be used later
30
+ 'no-lonely-if': 'off' , // Can hurt semantic programming
31
+ 'no-nested-ternary': 'off' , // Now I use the streamlined ternary operator a lot
32
+ 'no-shadow': 'error' ,
33
+ 'no-shadow-restricted-names': 'error' ,
34
+ 'require-atomic-updates': 'off' , // check for possible race condition on assignment, interesting but too nitpicky
35
+
36
+
37
+
38
+ /*
39
+ Code preferences
40
+ */
41
+
42
+
43
+
44
+ 'prefer-arrow-callback': 'error' ,
45
+ 'prefer-spread': 'warn' ,
46
+ 'prefer-rest-params': 'warn' ,
47
+ 'no-control-regex': 'off' , // because thing like \x00 are considered like a control even if escaped...
48
+ 'no-fallthrough': 'off' ,
49
+ 'no-empty': [ 'error' , {
50
+ 'allowEmptyCatch': true
51
+ } ] ,
52
+
53
+
54
+
55
+ /*
56
+ Coding styles -- cosmetic rules and opinionated preferences
57
+ */
58
+
59
+
60
+
61
+ // Indent & spaces (general)
62
+ 'indent': [ 'error' , 'tab' , {
63
+ 'SwitchCase': 1 ,
64
+ 'MemberExpression': 1 ,
65
+ 'flatTernaryExpressions': true
66
+ } ] ,
67
+ 'newline-per-chained-call': 'off',
68
+ 'no-multi-spaces': 'off' ,
69
+ 'block-spacing': 'error' ,
70
+ 'comma-spacing': [ 'error' , {
71
+ 'before': true ,
72
+ 'after': true
73
+ } ] ,
74
+ 'no-whitespace-before-property': 'error' ,
75
+ 'space-before-blocks': 'error' ,
76
+ 'space-before-function-paren': [ 'error' , {
77
+ 'anonymous': 'never',
78
+ 'named': 'never',
79
+ 'asyncArrow': 'always'
80
+ } ] ,
81
+ 'space-infix-ops': 'error' ,
82
+ 'space-unary-ops': [ 'error' , {
83
+ 'words': true ,
84
+ 'nonwords': true ,
85
+ 'overrides': {
86
+ //'-': false ,
87
+ }
88
+ } ] ,
89
+ 'space-in-parens': [ 'error' , 'always' , {
90
+ 'exceptions': [ 'empty' ]
91
+ } ] ,
92
+ 'no-trailing-spaces': 'error' ,
93
+ 'switch-colon-spacing': [ 'error' , {
94
+ 'after': true ,
95
+ 'before': true
96
+ } ] ,
97
+ 'arrow-spacing': 'error' ,
98
+ 'rest-spread-spacing': [ 'error' , 'always' ] ,
99
+ /* Troublesome with commented line of code
100
+ 'spaced-comment': [ 'error' , 'always' , {
101
+ 'line': {
102
+ 'markers': [ '/' ],
103
+ 'exceptions': [ '-', '*', '/' ]
104
+ } ,
105
+ 'block': {
106
+ 'exceptions': [ '*' ] ,
107
+ 'balanced': true
108
+ }
109
+ } ] ,
110
+ */
111
+
112
+
113
+ // Semi-colon
114
+ 'semi': [ 'error' , 'always' ] ,
115
+ 'semi-style': [ 'error' , 'last' ] ,
116
+ 'semi-spacing': [ 'error' , {
117
+ 'before': true ,
118
+ 'after': true
119
+ } ] ,
120
+
121
+ // Objects
122
+ 'key-spacing': [ 'error' , {
123
+ 'beforeColon': false ,
124
+ 'afterColon': true ,
125
+ 'mode': 'strict'
126
+ } ] ,
127
+ 'object-curly-newline': [ 'error' , {
128
+ 'ObjectExpression' : {
129
+ 'consistent': true ,
130
+ 'minProperties': 4
131
+ } ,
132
+ 'ObjectPattern' : {
133
+ // object destructuring assigment
134
+ 'consistent': true ,
135
+ 'minProperties': 8
136
+ }
137
+ } ] ,
138
+ 'object-curly-spacing': [ 'error' , 'always' ] ,
139
+ 'object-property-newline': [ 'error' , { 'allowMultiplePropertiesPerLine': true } ] ,
140
+
141
+
142
+ // Arrays
143
+ 'array-bracket-newline': [ 'error' , 'consistent' ] ,
144
+ //'array-element-newline': [ 'error' , { 'multiline': true , 'minItems': 5 } ] ,
145
+ 'array-bracket-spacing': [ 'error' , 'always' ],
146
+
147
+ 'brace-style': [ 'error' , 'stroustrup' , {
148
+ 'allowSingleLine': true
149
+ } ] ,
150
+
151
+
152
+ // Misc style
153
+ 'no-else-return': 'warn' ,
154
+ 'comma-dangle': [ 'error' , 'never' ] ,
155
+ 'quotes': 'off' ,
156
+ 'camelcase': 'warn' ,
157
+
158
+
159
+
160
+ /*
161
+ Method limitation
162
+ */
163
+
164
+
165
+
166
+ 'no-console': 'off'
167
+ }
168
+ } ;
package/Makefile ADDED
@@ -0,0 +1,112 @@
1
+
2
+
3
+
4
+ # User rules
5
+
6
+ # The first rule is the default rule, when invoking "make" without argument...
7
+ # Build every buildable things
8
+ #all: install doc browser
9
+ all: install doc
10
+
11
+ # Just install things so it works, basicaly: it just performs a "npm install --production" ATM
12
+ install: log/npm-install.log
13
+
14
+ # Just install things so it works, basicaly: it just performs a "npm install" ATM
15
+ dev-install: log/npm-dev-install.log
16
+
17
+ # Build
18
+ #build: browser
19
+
20
+ # Build the browser lib
21
+ #browser: browser/svg-kit.js browser/svg-kit.min.js
22
+
23
+ # This run the JsHint & Mocha BDD test, display it to STDOUT & save it to log/mocha.log and log/jshint.log
24
+ test: log/jshint.log log/mocha.log
25
+
26
+ # This run the JsHint, display it to STDOUT & save it to log/jshint.log
27
+ lint: log/jshint.log
28
+
29
+ # This run the Mocha BDD test, display it to STDOUT & save it to log/mocha.log
30
+ unit: log/mocha.log
31
+
32
+ # This build the doc and README.md
33
+ doc: README.md
34
+
35
+ # This publish to NPM and push to Github, if we are on master branch only
36
+ publish: log/npm-publish.log log/github-push.log
37
+
38
+ # Clean temporary things, or things that can be automatically regenerated
39
+ clean: clean-all
40
+
41
+
42
+
43
+ # Variables
44
+
45
+ BROWSERIFY=browserify
46
+ UGLIFY=uglifyjs
47
+
48
+
49
+
50
+ # Files rules
51
+
52
+ # Build the browser lib
53
+ #browser/svg-kit.js: lib/*.js lib/*/*.js
54
+ # ${BROWSERIFY} lib/svg-kit.js -i fs -i image-size -s svgKit -o browser/svg-kit.js
55
+
56
+ # Build the browser minified lib
57
+ #browser/svg-kit.min.js: browser/svg-kit.js
58
+ # ${UGLIFY} browser/svg-kit.js -o browser/svg-kit.min.js -m
59
+
60
+ # JsHint STDOUT test
61
+ log/jshint.log: log/npm-dev-install.log lib/*.js test/*.js
62
+ ${JSHINT} lib/*.js test/*.js | tee log/jshint.log ; exit $${PIPESTATUS[0]}
63
+
64
+ # Mocha BDD STDOUT test
65
+ log/mocha.log: log/npm-dev-install.log lib/*.js test/*.js
66
+ cd test ; ${MOCHA} *.js -R spec | tee ../log/mocha.log ; exit $${PIPESTATUS[0]}
67
+
68
+ # README
69
+ README.md: documentation.md
70
+ cat documentation.md > README.md
71
+
72
+ # Mocha Markdown BDD spec
73
+ bdd-spec.md: log/npm-dev-install.log lib/*.js test/*.js
74
+ cd test ; ${MOCHA} *.js -R markdown > ../bdd-spec.md
75
+
76
+ # Upgrade version in package.json
77
+ log/upgrade-package.log: lib/*.js test/*.js documentation.md
78
+ npm version patch -m "Upgrade package.json version to %s" | tee log/upgrade-package.log ; exit $${PIPESTATUS[0]}
79
+
80
+ # Publish to NPM
81
+ log/npm-publish.log: check-if-master-branch log/upgrade-package.log
82
+ npm publish | tee log/npm-publish.log ; exit $${PIPESTATUS[0]}
83
+
84
+ # Push to Github/master
85
+ log/github-push.log: lib/*.js test/*.js package.json
86
+ #'npm version patch' create the git tag by itself...
87
+ #git tag v`cat package.json | grep version | sed -r 's/.*"([0-9.]*)".*/\1/'`
88
+ git push origin master --tags | tee log/github-push.log ; exit $${PIPESTATUS[0]}
89
+
90
+ # NPM install
91
+ log/npm-install.log: package.json
92
+ npm install --production | tee log/npm-install.log ; exit $${PIPESTATUS[0]}
93
+
94
+ # NPM install for developpement usage
95
+ log/npm-dev-install.log: package.json
96
+ npm install | tee log/npm-dev-install.log ; exit $${PIPESTATUS[0]}
97
+
98
+
99
+
100
+ # PHONY rules
101
+
102
+ .PHONY: clean-all check-if-master-branch
103
+
104
+ # Delete files, mostly log and non-versioned files
105
+ clean-all:
106
+ rm -rf log/*.log README.md bdd-spec.md node_modules
107
+
108
+ # This will fail if we are not on master branch (grep exit 1 if nothing found)
109
+ check-if-master-branch:
110
+ git branch | grep "^* master$$"
111
+
112
+
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+
2
+ # Book Source
3
+
4
+ A Lightweight Markup Language similar to Markdown.
5
+
6
+ This lib parses Book Source and is shipped with a HTML renderer.
7
+
8
+ New renderers can easily be created.
9
+
10
+ The parser has zero regex.
11
+
12
+
13
+
14
+ ## Book Source syntax
15
+
16
+ TODO
17
+
package/brainstorming ADDED
@@ -0,0 +1,213 @@
1
+
2
+
3
+ ✅ Heading: # Title
4
+ ✅ Anchor (generating <a name="anchor-name"></a>: #(anchor-name)
5
+
6
+ ✅ Paragraph are separated by empty lines
7
+ ✅ Forced line-break (at the end of line, with or without space after): \
8
+ ✅ or (at the begining of the line, with at least on space after): \
9
+
10
+ ✅ Multiline block are two-spaces indent (multiline header, list-item, etc)
11
+
12
+ ✅ Italic: *
13
+ ✅ Bold: **
14
+ ✅ Bold+italic: ***
15
+
16
+ ✅ Underline: _
17
+ ✅ or: __
18
+
19
+ ✅ Blockquote: (8-spaces-indent)
20
+ ✅ Nested blockquote: (multiple-of-8-spaces-indent)
21
+
22
+ ✅ Give proper credit to the quote: -- Name the quoted person, or the book, film, lyrics
23
+ ✅ Signature at the end of an article: -- Name of the signing person
24
+
25
+ ✅ Unordered list: *
26
+ ✅ or: -
27
+ ✅ Ordered list: 1.
28
+ ✅ Nested list, having more indentation
29
+
30
+ ✅ Inline code: `some code`
31
+ ✅ Inline code with double bacquote escape: ``some `code` with backquote``
32
+ ✅ or (extra forced space is trimmed): `` `code` ``
33
+ ✅ Code block: ```language
34
+
35
+ ✅ Clear float (3 or more -): <--->
36
+ ✅ Horizontal rule (3 or more -): ---
37
+ ✅ Horizontal rule + Clear float (3 or more - at both side): ---<>---
38
+
39
+ ✅ Custom style: [text]<style>
40
+ (where style can be a color like red, green, black, or other style like bold, italic, oblique, separated by comma ",")
41
+ (generate a <span>)
42
+
43
+ ✅ Title tooltip: [text][title text]
44
+
45
+ ✅ Link: [link text](href)
46
+ ✅ Link+Title: [link text][title text](href)
47
+
48
+ ✅ Inline image with alt text: ![alt text](href)
49
+ ✅ Inline image + alt text + title: ![alt text][title text](href)
50
+ ✅ Emoji and special characters: ![emoji-name]
51
+ pre-defined image: ![pre-defined-image-name]
52
+ ? material icon: ![material-icon-name]
53
+ ✅ Block image: !=[alt text](href)
54
+ ✅ Block image with caption: !=[alt text][caption](href)
55
+ ✅ Block image + caption + title: !=[alt text][caption][title text](href)
56
+ ✅ Floating left block image: !<[alt text](href)
57
+ ✅ Floating right block image: !>[alt text](href)
58
+
59
+ Block multimedia: !=[alt text](href)(media-type)
60
+ media type can be: image, video, audio
61
+
62
+
63
+
64
+
65
+
66
+ ## Metadata
67
+
68
+ ✅ Start metadata part: ---[[
69
+ ✅ End of metadata part: ]]---
70
+ ✅ Start special metadata part (spaces around the name are possible): ---[special-name[
71
+ Special metadata have a meaning for the renderer, for example most implementation should support 'theme' as a special metadata.
72
+ E.g.: ---[ theme [
73
+
74
+
75
+
76
+
77
+
78
+ ## Tables
79
+
80
+ ✅ Very simple table:
81
+
82
+ | cell 1A | cell 1B | cell 1C |
83
+ | cell 2A | cell 2B | cell 2C |
84
+ | cell 3A | cell 3B | cell 3C |
85
+
86
+
87
+
88
+ ✅ Table caption (no space between the pipe and the bracket chars): |[ Table caption text ]|
89
+ ✅ Multiline table caption (follow-up caption line): |[ ... follow-up text ]|
90
+ ✅ Template row/header-body separator (optional): |----------|--------|---------|
91
+ ✅ Multiline table head row (multiple lines before the row/body separator)
92
+ ✅ Optional row separator: |----------|--------|---------|
93
+ ✅ Multiline rows (all rows should be separated by a row separator)
94
+ ✅ Multiline single row is done by enforcing a trailing row separator
95
+ ✅ Table header should be before the row template
96
+ ✅ Template row (cell) defining a left-alignment column: |<------|
97
+ ✅ Template row (cell) defining a right-alignment column: |------>|
98
+ ✅ Template row (cell) defining a center-alignment column: |>------<|
99
+ ✅ Template row (cell) defining a justified content column: |<------>|
100
+ ✅ Template row (cell) defining a head column: |-------:|
101
+ ✅ Template row (cell) column background-color: |---<red>---|
102
+ ✅ Cell color background-color: |<red> some content |
103
+ ✅ Table caption background-color: |[ Table caption text ]|<red>
104
+ ✅ Row background-color (at the end of the row): |<red>
105
+ ✅ Thick column separator (the right-bar is doubled, inside template row, or any cell): ||
106
+ ✅ Thick row separator: |==========|========|=========|
107
+ ✅ Colspan (less cell in a row, use bar matching the template row to know which cell have colspan)
108
+ ✅ Rowspan (only one hyphen after and before the bar, with space in between: |- -|
109
+ ✅ Rowspan + Colspan combo
110
+
111
+
112
+
113
+ ✅ Regular table:
114
+
115
+ |[ Table caption text ]|
116
+ | header 1 | header 2 | header 3 |
117
+ |----------|----------|----------|
118
+ | cell 1A | cell 1B | cell 1C |
119
+ | cell 2A | cell 2B | cell 2C |
120
+ | cell 3A | cell 3B | cell 3C |
121
+
122
+
123
+
124
+ ✅ Two-entries table:
125
+
126
+ |[ Table caption text ]|
127
+ | | header 1 | header 2 |
128
+ |---------:|----------|----------|
129
+ | entry 1 | cell 1A | cell 1B |
130
+ | entry 2 | cell 2A | cell 2B |
131
+ | entry 3 | cell 3A | cell 3B |
132
+
133
+
134
+
135
+ ✅ Multi-line table:
136
+
137
+ |[ Multiline table caption text ]|
138
+ |[ ... with extra line ]|
139
+ | header 1 | header 2 | header 3 |
140
+ | ... | ... | ... |
141
+ |----------|----------|----------|
142
+ | cell 1A | cell 1B | cell 1C |
143
+ | ... | ... | ... |
144
+ |----------|----------|----------|
145
+ | cell 2A | cell 2B | cell 2C |
146
+ | ... | ... | ... |
147
+ |----------|----------|----------|
148
+ | cell 3A | cell 3B | cell 3C |
149
+ | ... | ... | ... |
150
+
151
+
152
+
153
+ ## Spreadsheet-like feature inside tables
154
+
155
+ ? Computed spreadsheet-like cell: |=(formula) |
156
+ ? Template row (cell) computed spreadsheet-like column: |---=(formula)---|
157
+ ? Computed spreadsheet-like row (starts with): |=(formula)|
158
+
159
+
160
+
161
+ ## Section and Column flow:
162
+
163
+ Section break (3 or more): +++
164
+ (Clearing all columns and start over on a fresh one-column section, close/open "section" tags)
165
+
166
+ Column break (close/open "column" custom tags): |||
167
+
168
+
169
+
170
+ ## Misc:
171
+
172
+ ? Hover tooltip text block (support new lines inside the []): ?[text][[some block of text]]
173
+ ? Hover tooltip sub-document (href can point to markup, or html): ?[text](href)
174
+
175
+ ? Introduce a todo list item: -[ ]
176
+ ? Introduce a todo list item done: -[x]
177
+
178
+
179
+
180
+
181
+
182
+ ## Name Brainstorming for a Lightweight Markup Language
183
+
184
+ Obvious names:
185
+
186
+ Book Source (.bks) (to the point, but lacks of fun)
187
+ XTX / eXtrem TeXt (.xtx) (txt -> xtx, quite memorable, neutral+ name)
188
+ Mµ (.mu) (MarkUp)
189
+ LMK (.lmk) (Lightweight MarKup)
190
+ MKX (.mkx) (Markup X)
191
+ MKTX (.mktx) (MarKup TeXt)
192
+ Hyper Markdown (.hmd)
193
+ Orthodoc (.otd) (not really cool, confusion with LibreOffice .odt)
194
+ ArkTex / ArkTX (.arktx) (mARKup TEXt)
195
+ CupTx (.cuptx) (marKUP TeXt)
196
+
197
+
198
+ Abstract names:
199
+
200
+ Feather / Plume (.fetr? .plume?)
201
+ Hype (.hype) (but it's unlikely to have widespread adoption)
202
+ Blast (.blast) (ok name, but not explicit)
203
+ Popcorn (.pop .pcorn) (ok name, but not explicit)
204
+ YO (.yo) (no pun, no reason, just sounds fun)
205
+
206
+
207
+ Not available:
208
+
209
+ Texy (.texy) (sounds sexy) (it's a PHP lib having the same scope than this one...)
210
+ Litex (.litx) (Lite + Tex, because of Lightweight Markup Language, but too close to latex)
211
+ Easy Doc / EZ Doc (.ezd) (cool, but not really available)
212
+ xdoc (.xdoc) (similar to docx)
213
+
package/css/code.css ADDED
@@ -0,0 +1,120 @@
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
+ }