book-source 0.3.10 → 0.3.11
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/LICENSE +21 -0
- package/lib/StructuredDocument.js +21 -11
- package/package.json +1 -1
- package/.eslintrc.js +0 -168
- package/Makefile +0 -112
- package/documentation.md +0 -17
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Cédric Ronvel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -299,10 +299,6 @@ StructuredDocument.parse = function( str , options ) {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
// Call depthManagement() one last time, because some instanceOf may still be hanging...
|
|
303
|
-
//ctx.depth = -1 ;
|
|
304
|
-
//depthManagement( ctx ) ;
|
|
305
|
-
|
|
306
302
|
return ctx.structuredDocument ;
|
|
307
303
|
} ;
|
|
308
304
|
|
|
@@ -901,7 +897,7 @@ function parseTableCaption( str , ctx ) {
|
|
|
901
897
|
if ( data?.style?.[ 0 ] ) { tableCaption.style = data.style[ 0 ] ; }
|
|
902
898
|
}
|
|
903
899
|
|
|
904
|
-
ctx.i = lastCharOfLine + 1 ;
|
|
900
|
+
ctx.i = searchEndOfLine( str , lastCharOfLine !== - 1 ? lastCharOfLine : ctx.i ) + 1 ;
|
|
905
901
|
}
|
|
906
902
|
|
|
907
903
|
|
|
@@ -991,7 +987,7 @@ function parseTableRow( str , ctx ) {
|
|
|
991
987
|
currentBar = columnSeparator ? nextBar + 1 : nextBar ;
|
|
992
988
|
}
|
|
993
989
|
|
|
994
|
-
// Compute cells indexes, columnSpan,
|
|
990
|
+
// Compute cells indexes, columnSpan, column template, and add missing cells
|
|
995
991
|
computeIndexColumnSpan( ctx , table , tableRow ) ;
|
|
996
992
|
|
|
997
993
|
if ( str[ currentBar + 1 ] === '<' ) {
|
|
@@ -1000,7 +996,7 @@ function parseTableRow( str , ctx ) {
|
|
|
1000
996
|
if ( data?.style?.[ 0 ] ) { tableRow.style = data.style[ 0 ] ; }
|
|
1001
997
|
}
|
|
1002
998
|
|
|
1003
|
-
ctx.i = lastCharOfLine + 1 ;
|
|
999
|
+
ctx.i = searchEndOfLine( str , lastCharOfLine !== - 1 ? lastCharOfLine : ctx.i ) + 1 ;
|
|
1004
1000
|
}
|
|
1005
1001
|
|
|
1006
1002
|
|
|
@@ -1033,7 +1029,7 @@ function parseTableMultilineRow( str , ctx , lastCharOfLine , table , tableRow )
|
|
|
1033
1029
|
columnIndex ++ ;
|
|
1034
1030
|
}
|
|
1035
1031
|
|
|
1036
|
-
ctx.i = lastCharOfLine + 1 ;
|
|
1032
|
+
ctx.i = searchEndOfLine( str , lastCharOfLine !== - 1 ? lastCharOfLine : ctx.i ) + 1 ;
|
|
1037
1033
|
}
|
|
1038
1034
|
|
|
1039
1035
|
|
|
@@ -1143,7 +1139,7 @@ function parseTableRowSeparator( str , ctx , thick = false ) {
|
|
|
1143
1139
|
separatorCellIndex ++ ;
|
|
1144
1140
|
}
|
|
1145
1141
|
|
|
1146
|
-
ctx.i = lastCharOfLine + 1 ;
|
|
1142
|
+
ctx.i = searchEndOfLine( str , lastCharOfLine !== - 1 ? lastCharOfLine : ctx.i ) + 1 ;
|
|
1147
1143
|
}
|
|
1148
1144
|
|
|
1149
1145
|
|
|
@@ -1291,15 +1287,16 @@ function parseTableHeadRowSeparator( str , ctx , thick , lastCharOfLine ) {
|
|
|
1291
1287
|
}
|
|
1292
1288
|
|
|
1293
1289
|
if ( tableHeadRow ) {
|
|
1294
|
-
// Compute cells indexes, columnSpan,
|
|
1290
|
+
// Compute cells indexes, columnSpan, column template, and add missing cells
|
|
1295
1291
|
computeIndexColumnSpan( ctx , table , tableHeadRow ) ;
|
|
1296
1292
|
}
|
|
1297
1293
|
|
|
1298
|
-
ctx.i = lastCharOfLine + 1 ;
|
|
1294
|
+
ctx.i = searchEndOfLine( str , lastCharOfLine !== - 1 ? lastCharOfLine : ctx.i ) + 1 ;
|
|
1299
1295
|
}
|
|
1300
1296
|
|
|
1301
1297
|
|
|
1302
1298
|
|
|
1299
|
+
// Compute cells indexes, columnSpan, column template, and add missing cells
|
|
1303
1300
|
function computeIndexColumnSpan( ctx , table , tableRow ) {
|
|
1304
1301
|
var tableCell , cellIndex , column , columnIndex , columnSpan ,
|
|
1305
1302
|
columns = table.columns ,
|
|
@@ -1336,6 +1333,19 @@ function computeIndexColumnSpan( ctx , table , tableRow ) {
|
|
|
1336
1333
|
}
|
|
1337
1334
|
}
|
|
1338
1335
|
}
|
|
1336
|
+
|
|
1337
|
+
// Add missing cells
|
|
1338
|
+
if ( columns ) {
|
|
1339
|
+
for ( ; extraSpan > 0 ; extraSpan -- ) {
|
|
1340
|
+
columnIndex = table.columns.length - extraSpan ;
|
|
1341
|
+
column = table.columns[ columnIndex ] ;
|
|
1342
|
+
tableCell = new documentParts.TableCell() ;
|
|
1343
|
+
tableCell.column = columnIndex ;
|
|
1344
|
+
tableCell.sx = column?.sx || - 1 ;
|
|
1345
|
+
tableCell.ex = column?.ex || - 1 ;
|
|
1346
|
+
tableRow.parts.push( tableCell ) ;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1339
1349
|
}
|
|
1340
1350
|
|
|
1341
1351
|
|
package/package.json
CHANGED
package/.eslintrc.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
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/documentation.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Book Source
|
|
3
|
-
|
|
4
|
-
Book Source is a Lightweight Markup Language similar to Markdown.
|
|
5
|
-
|
|
6
|
-
This is the parser, you may want to add a renderer, like the [Book Source HTML renderer](https://github.com/cronvel/book-source-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
|
-
|