rapier-html 1.2.46 → 1.2.49
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/BUILD.json +4 -4
- package/README.md +12 -11
- package/dist/ledger/carried.mjs +17 -8
- package/dist/ledger/diff/concerns.mjs +2 -2
- package/dist/ledger/document-fonts.mjs +60 -6
- package/dist/ledger/source.mjs +31 -2
- package/dist/ledger/vendor/SOURCES.json +253 -0
- package/dist/ledger/vendor/entities/decode-codepoint.mjs +27 -0
- package/dist/ledger/vendor/entities.mjs +499 -0
- package/dist/ledger/vendor/linkify-it.mjs +427 -0
- package/dist/ledger/vendor/markdown-it.mjs +4027 -0
- package/dist/ledger/vendor/markdown-plugins.mjs +1328 -11
- package/dist/ledger/vendor/markdown-runtime.mjs +3 -11
- package/dist/ledger/vendor/mdurl/index.mjs +11 -0
- package/dist/ledger/vendor/mdurl/lib/decode.mjs +107 -0
- package/dist/ledger/vendor/mdurl/lib/encode.mjs +77 -0
- package/dist/ledger/vendor/mdurl/lib/format.mjs +20 -0
- package/dist/ledger/vendor/mdurl/lib/parse.mjs +231 -0
- package/dist/ledger/vendor/punycode.mjs +282 -0
- package/dist/ledger/vendor/uc.micro.mjs +49 -0
- package/dist/page.mjs +11 -3
- package/dist/rapier.html +97 -51
- package/dist/wrap.mjs +10 -5
- package/package.json +1 -1
- package/dist/ledger/vendor/BROWSER-ENTITIES.json +0 -36
- package/dist/ledger/vendor/MARKDOWN-RUNTIME.json +0 -136
- package/dist/ledger/vendor/MARKDOWNIT.json +0 -582
- package/dist/ledger/vendor/markdown-plugins.json +0 -46
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Copyright Joyent, Inc. and other Node contributors.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
copy of this software and associated documentation files (the
|
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
9
|
+
persons to whom the Software is furnished to do so, subject to the
|
|
10
|
+
following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included
|
|
13
|
+
in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
16
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
18
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
19
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
20
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
21
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function Url () {
|
|
26
|
+
this.protocol = null
|
|
27
|
+
this.slashes = null
|
|
28
|
+
this.auth = null
|
|
29
|
+
this.port = null
|
|
30
|
+
this.hostname = null
|
|
31
|
+
this.hash = null
|
|
32
|
+
this.search = null
|
|
33
|
+
this.pathname = null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
const protocolPattern = /^([a-z0-9.+-]+:)/i
|
|
38
|
+
const portPattern = /:[0-9]*$/
|
|
39
|
+
|
|
40
|
+
/* eslint-disable-next-line no-useless-escape */
|
|
41
|
+
const simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/
|
|
42
|
+
|
|
43
|
+
const delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t']
|
|
44
|
+
|
|
45
|
+
const unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims)
|
|
46
|
+
|
|
47
|
+
const autoEscape = ['\''].concat(unwise)
|
|
48
|
+
const nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape)
|
|
49
|
+
const hostEndingChars = ['/', '?', '#']
|
|
50
|
+
const hostnameMaxLen = 255
|
|
51
|
+
const hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/
|
|
52
|
+
const hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/
|
|
53
|
+
const hostlessProtocol = {
|
|
54
|
+
javascript: true,
|
|
55
|
+
'javascript:': true
|
|
56
|
+
}
|
|
57
|
+
const slashedProtocol = {
|
|
58
|
+
http: true,
|
|
59
|
+
https: true,
|
|
60
|
+
ftp: true,
|
|
61
|
+
gopher: true,
|
|
62
|
+
file: true,
|
|
63
|
+
'http:': true,
|
|
64
|
+
'https:': true,
|
|
65
|
+
'ftp:': true,
|
|
66
|
+
'gopher:': true,
|
|
67
|
+
'file:': true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function urlParse (url, slashesDenoteHost) {
|
|
71
|
+
if (url && url instanceof Url) return url
|
|
72
|
+
|
|
73
|
+
const u = new Url()
|
|
74
|
+
u.parse(url, slashesDenoteHost)
|
|
75
|
+
return u
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Url.prototype.parse = function (url, slashesDenoteHost) {
|
|
79
|
+
let lowerProto, hec, slashes
|
|
80
|
+
let rest = url
|
|
81
|
+
|
|
82
|
+
rest = rest.trim()
|
|
83
|
+
|
|
84
|
+
if (!slashesDenoteHost && url.split('#').length === 1) {
|
|
85
|
+
const simplePath = simplePathPattern.exec(rest)
|
|
86
|
+
if (simplePath) {
|
|
87
|
+
this.pathname = simplePath[1]
|
|
88
|
+
if (simplePath[2]) {
|
|
89
|
+
this.search = simplePath[2]
|
|
90
|
+
}
|
|
91
|
+
return this
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let proto = protocolPattern.exec(rest)
|
|
96
|
+
if (proto) {
|
|
97
|
+
proto = proto[0]
|
|
98
|
+
lowerProto = proto.toLowerCase()
|
|
99
|
+
this.protocol = proto
|
|
100
|
+
rest = rest.substr(proto.length)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* eslint-disable-next-line no-useless-escape */
|
|
104
|
+
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
|
105
|
+
slashes = rest.substr(0, 2) === '//'
|
|
106
|
+
if (slashes && !(proto && hostlessProtocol[proto])) {
|
|
107
|
+
rest = rest.substr(2)
|
|
108
|
+
this.slashes = true
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!hostlessProtocol[proto] &&
|
|
113
|
+
(slashes || (proto && !slashedProtocol[proto]))) {
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
let hostEnd = -1
|
|
117
|
+
for (let i = 0; i < hostEndingChars.length; i++) {
|
|
118
|
+
hec = rest.indexOf(hostEndingChars[i])
|
|
119
|
+
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
|
|
120
|
+
hostEnd = hec
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let auth, atSign
|
|
125
|
+
if (hostEnd === -1) {
|
|
126
|
+
atSign = rest.lastIndexOf('@')
|
|
127
|
+
} else {
|
|
128
|
+
atSign = rest.lastIndexOf('@', hostEnd)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (atSign !== -1) {
|
|
132
|
+
auth = rest.slice(0, atSign)
|
|
133
|
+
rest = rest.slice(atSign + 1)
|
|
134
|
+
this.auth = auth
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
hostEnd = -1
|
|
138
|
+
for (let i = 0; i < nonHostChars.length; i++) {
|
|
139
|
+
hec = rest.indexOf(nonHostChars[i])
|
|
140
|
+
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
|
|
141
|
+
hostEnd = hec
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (hostEnd === -1) {
|
|
145
|
+
hostEnd = rest.length
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (rest[hostEnd - 1] === ':') { hostEnd-- }
|
|
149
|
+
const host = rest.slice(0, hostEnd)
|
|
150
|
+
rest = rest.slice(hostEnd)
|
|
151
|
+
|
|
152
|
+
this.parseHost(host)
|
|
153
|
+
|
|
154
|
+
this.hostname = this.hostname || ''
|
|
155
|
+
|
|
156
|
+
const ipv6Hostname = this.hostname[0] === '[' &&
|
|
157
|
+
this.hostname[this.hostname.length - 1] === ']'
|
|
158
|
+
|
|
159
|
+
if (!ipv6Hostname) {
|
|
160
|
+
const hostparts = this.hostname.split(/\./)
|
|
161
|
+
for (let i = 0, l = hostparts.length; i < l; i++) {
|
|
162
|
+
const part = hostparts[i]
|
|
163
|
+
if (!part) { continue }
|
|
164
|
+
if (!part.match(hostnamePartPattern)) {
|
|
165
|
+
let newpart = ''
|
|
166
|
+
for (let j = 0, k = part.length; j < k; j++) {
|
|
167
|
+
if (part.charCodeAt(j) > 127) {
|
|
168
|
+
newpart += 'x'
|
|
169
|
+
} else {
|
|
170
|
+
newpart += part[j]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!newpart.match(hostnamePartPattern)) {
|
|
174
|
+
const validParts = hostparts.slice(0, i)
|
|
175
|
+
const notHost = hostparts.slice(i + 1)
|
|
176
|
+
const bit = part.match(hostnamePartStart)
|
|
177
|
+
if (bit) {
|
|
178
|
+
validParts.push(bit[1])
|
|
179
|
+
notHost.unshift(bit[2])
|
|
180
|
+
}
|
|
181
|
+
if (notHost.length) {
|
|
182
|
+
rest = notHost.join('.') + rest
|
|
183
|
+
}
|
|
184
|
+
this.hostname = validParts.join('.')
|
|
185
|
+
break
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (this.hostname.length > hostnameMaxLen) {
|
|
192
|
+
this.hostname = ''
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (ipv6Hostname) {
|
|
196
|
+
this.hostname = this.hostname.substr(1, this.hostname.length - 2)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const hash = rest.indexOf('#')
|
|
201
|
+
if (hash !== -1) {
|
|
202
|
+
this.hash = rest.substr(hash)
|
|
203
|
+
rest = rest.slice(0, hash)
|
|
204
|
+
}
|
|
205
|
+
const qm = rest.indexOf('?')
|
|
206
|
+
if (qm !== -1) {
|
|
207
|
+
this.search = rest.substr(qm)
|
|
208
|
+
rest = rest.slice(0, qm)
|
|
209
|
+
}
|
|
210
|
+
if (rest) { this.pathname = rest }
|
|
211
|
+
if (slashedProtocol[lowerProto] &&
|
|
212
|
+
this.hostname && !this.pathname) {
|
|
213
|
+
this.pathname = ''
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return this
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
Url.prototype.parseHost = function (host) {
|
|
220
|
+
let port = portPattern.exec(host)
|
|
221
|
+
if (port) {
|
|
222
|
+
port = port[0]
|
|
223
|
+
if (port !== ':') {
|
|
224
|
+
this.port = port.substr(1)
|
|
225
|
+
}
|
|
226
|
+
host = host.substr(0, host.length - port.length)
|
|
227
|
+
}
|
|
228
|
+
if (host) { this.hostname = host }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default urlParse
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const maxInt = 2147483647;
|
|
4
|
+
|
|
5
|
+
const base = 36;
|
|
6
|
+
const tMin = 1;
|
|
7
|
+
const tMax = 26;
|
|
8
|
+
const skew = 38;
|
|
9
|
+
const damp = 700;
|
|
10
|
+
const initialBias = 72;
|
|
11
|
+
const initialN = 128;
|
|
12
|
+
const delimiter = '-';
|
|
13
|
+
|
|
14
|
+
const regexPunycode = /^xn--/;
|
|
15
|
+
const regexNonASCII = /[^\0-\x7F]/;
|
|
16
|
+
const regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
|
|
17
|
+
|
|
18
|
+
const errors = {
|
|
19
|
+
'overflow': 'Overflow: input needs wider integers to process',
|
|
20
|
+
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
21
|
+
'invalid-input': 'Invalid input'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const baseMinusTMin = base - tMin;
|
|
25
|
+
const floor = Math.floor;
|
|
26
|
+
const stringFromCharCode = String.fromCharCode;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function error(type) {
|
|
30
|
+
throw new RangeError(errors[type]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function map(array, callback) {
|
|
34
|
+
const result = [];
|
|
35
|
+
let length = array.length;
|
|
36
|
+
while (length--) {
|
|
37
|
+
result[length] = callback(array[length]);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function mapDomain(domain, callback) {
|
|
43
|
+
const parts = domain.split('@');
|
|
44
|
+
let result = '';
|
|
45
|
+
if (parts.length > 1) {
|
|
46
|
+
result = parts[0] + '@';
|
|
47
|
+
domain = parts[1];
|
|
48
|
+
}
|
|
49
|
+
domain = domain.replace(regexSeparators, '\x2E');
|
|
50
|
+
const labels = domain.split('.');
|
|
51
|
+
const encoded = map(labels, callback).join('.');
|
|
52
|
+
return result + encoded;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function ucs2decode(string) {
|
|
56
|
+
const output = [];
|
|
57
|
+
let counter = 0;
|
|
58
|
+
const length = string.length;
|
|
59
|
+
while (counter < length) {
|
|
60
|
+
const value = string.charCodeAt(counter++);
|
|
61
|
+
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
62
|
+
const extra = string.charCodeAt(counter++);
|
|
63
|
+
if ((extra & 0xFC00) == 0xDC00) {
|
|
64
|
+
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
65
|
+
} else {
|
|
66
|
+
output.push(value);
|
|
67
|
+
counter--;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
output.push(value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return output;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const ucs2encode = codePoints => String.fromCodePoint(...codePoints);
|
|
77
|
+
|
|
78
|
+
const basicToDigit = function(codePoint) {
|
|
79
|
+
if (codePoint >= 0x30 && codePoint < 0x3A) {
|
|
80
|
+
return 26 + (codePoint - 0x30);
|
|
81
|
+
}
|
|
82
|
+
if (codePoint >= 0x41 && codePoint < 0x5B) {
|
|
83
|
+
return codePoint - 0x41;
|
|
84
|
+
}
|
|
85
|
+
if (codePoint >= 0x61 && codePoint < 0x7B) {
|
|
86
|
+
return codePoint - 0x61;
|
|
87
|
+
}
|
|
88
|
+
return base;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const digitToBasic = function(digit, flag) {
|
|
92
|
+
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const adapt = function(delta, numPoints, firstTime) {
|
|
96
|
+
let k = 0;
|
|
97
|
+
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
98
|
+
delta += floor(delta / numPoints);
|
|
99
|
+
for ( ; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
100
|
+
delta = floor(delta / baseMinusTMin);
|
|
101
|
+
}
|
|
102
|
+
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const decode = function(input) {
|
|
106
|
+
const output = [];
|
|
107
|
+
const inputLength = input.length;
|
|
108
|
+
let i = 0;
|
|
109
|
+
let n = initialN;
|
|
110
|
+
let bias = initialBias;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
let basic = input.lastIndexOf(delimiter);
|
|
114
|
+
if (basic < 0) {
|
|
115
|
+
basic = 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
for (let j = 0; j < basic; ++j) {
|
|
119
|
+
if (input.charCodeAt(j) >= 0x80) {
|
|
120
|
+
error('not-basic');
|
|
121
|
+
}
|
|
122
|
+
output.push(input.charCodeAt(j));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
|
127
|
+
|
|
128
|
+
const oldi = i;
|
|
129
|
+
for (let w = 1, k = base; ; k += base) {
|
|
130
|
+
|
|
131
|
+
if (index >= inputLength) {
|
|
132
|
+
error('invalid-input');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const digit = basicToDigit(input.charCodeAt(index++));
|
|
136
|
+
|
|
137
|
+
if (digit >= base) {
|
|
138
|
+
error('invalid-input');
|
|
139
|
+
}
|
|
140
|
+
if (digit > floor((maxInt - i) / w)) {
|
|
141
|
+
error('overflow');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
i += digit * w;
|
|
145
|
+
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
146
|
+
|
|
147
|
+
if (digit < t) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const baseMinusT = base - t;
|
|
152
|
+
if (w > floor(maxInt / baseMinusT)) {
|
|
153
|
+
error('overflow');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
w *= baseMinusT;
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const out = output.length + 1;
|
|
161
|
+
bias = adapt(i - oldi, out, oldi == 0);
|
|
162
|
+
|
|
163
|
+
if (floor(i / out) > maxInt - n) {
|
|
164
|
+
error('overflow');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
n += floor(i / out);
|
|
168
|
+
i %= out;
|
|
169
|
+
|
|
170
|
+
output.splice(i++, 0, n);
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return String.fromCodePoint(...output);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const encode = function(input) {
|
|
178
|
+
const output = [];
|
|
179
|
+
|
|
180
|
+
input = ucs2decode(input);
|
|
181
|
+
|
|
182
|
+
const inputLength = input.length;
|
|
183
|
+
|
|
184
|
+
let n = initialN;
|
|
185
|
+
let delta = 0;
|
|
186
|
+
let bias = initialBias;
|
|
187
|
+
|
|
188
|
+
for (const currentValue of input) {
|
|
189
|
+
if (currentValue < 0x80) {
|
|
190
|
+
output.push(stringFromCharCode(currentValue));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const basicLength = output.length;
|
|
195
|
+
let handledCPCount = basicLength;
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if (basicLength) {
|
|
199
|
+
output.push(delimiter);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
while (handledCPCount < inputLength) {
|
|
203
|
+
|
|
204
|
+
let m = maxInt;
|
|
205
|
+
for (const currentValue of input) {
|
|
206
|
+
if (currentValue >= n && currentValue < m) {
|
|
207
|
+
m = currentValue;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const handledCPCountPlusOne = handledCPCount + 1;
|
|
212
|
+
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
213
|
+
error('overflow');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
delta += (m - n) * handledCPCountPlusOne;
|
|
217
|
+
n = m;
|
|
218
|
+
|
|
219
|
+
for (const currentValue of input) {
|
|
220
|
+
if (currentValue < n && ++delta > maxInt) {
|
|
221
|
+
error('overflow');
|
|
222
|
+
}
|
|
223
|
+
if (currentValue === n) {
|
|
224
|
+
let q = delta;
|
|
225
|
+
for (let k = base; ; k += base) {
|
|
226
|
+
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
227
|
+
if (q < t) {
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
const qMinusT = q - t;
|
|
231
|
+
const baseMinusT = base - t;
|
|
232
|
+
output.push(
|
|
233
|
+
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
234
|
+
);
|
|
235
|
+
q = floor(qMinusT / baseMinusT);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
239
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
|
|
240
|
+
delta = 0;
|
|
241
|
+
++handledCPCount;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
++delta;
|
|
246
|
+
++n;
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
return output.join('');
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const toUnicode = function(input) {
|
|
253
|
+
return mapDomain(input, function(string) {
|
|
254
|
+
return regexPunycode.test(string)
|
|
255
|
+
? decode(string.slice(4).toLowerCase())
|
|
256
|
+
: string;
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const toASCII = function(input) {
|
|
261
|
+
return mapDomain(input, function(string) {
|
|
262
|
+
return regexNonASCII.test(string)
|
|
263
|
+
? 'xn--' + encode(string)
|
|
264
|
+
: string;
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
const punycode = {
|
|
270
|
+
'version': '2.3.1',
|
|
271
|
+
'ucs2': {
|
|
272
|
+
'decode': ucs2decode,
|
|
273
|
+
'encode': ucs2encode
|
|
274
|
+
},
|
|
275
|
+
'decode': decode,
|
|
276
|
+
'encode': encode,
|
|
277
|
+
'toASCII': toASCII,
|
|
278
|
+
'toUnicode': toUnicode
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export { ucs2decode, ucs2encode, decode, encode, toASCII, toUnicode };
|
|
282
|
+
export default punycode;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const Any = /[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
2
|
+
const Cc = /[\0-\x1F\x7F-\x9F]/;
|
|
3
|
+
const Cf = /[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;
|
|
4
|
+
const P = new RegExp(
|
|
5
|
+
"[!-#%-\\*,-\\/:;\\?@\\[-\\]_\\{\\}\\xA1\\xA7\\xAB\\xB6\\xB7\\xBB\\xBF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05" +
|
|
6
|
+
"F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061D-\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u096" +
|
|
7
|
+
"4\\u0965\\u0970\\u09FD\\u0A76\\u0AF0\\u0C77\\u0C84\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u" +
|
|
8
|
+
"0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1" +
|
|
9
|
+
"800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B4E\\u1B4F\\u1B5A-\\u1B60\\u1B7D-\\u1B7F\\u1BFC-\\u1BFF\\u1C3B-\\u" +
|
|
10
|
+
"1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2308-\\u" +
|
|
11
|
+
"230B\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2" +
|
|
12
|
+
"D70\\u2E00-\\u2E2E\\u2E30-\\u2E4F\\u2E52-\\u2E5D\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA" +
|
|
13
|
+
"60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA8FC\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9" +
|
|
14
|
+
"DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B" +
|
|
15
|
+
"\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]|\\uD800[\\uDD" +
|
|
16
|
+
"00-\\uDD02\\uDF9F\\uDFD0]|\\uD801\\uDD6F|\\uD802[\\uDC57\\uDD1F\\uDD3F\\uDE50-\\uDE58\\uDE7F\\uDEF0-\\uDEF6\\uDF39-\\uDF3F\\uDF99-\\uDF9C]" +
|
|
17
|
+
"|\\uD803[\\uDD6E\\uDEAD\\uDED0\\uDF55-\\uDF59\\uDF86-\\uDF89]|\\uD804[\\uDC47-\\uDC4D\\uDCBB\\uDCBC\\uDCBE-\\uDCC1\\uDD40-\\uDD43\\uDD74\\u" +
|
|
18
|
+
"DD75\\uDDC5-\\uDDC8\\uDDCD\\uDDDB\\uDDDD-\\uDDDF\\uDE38-\\uDE3D\\uDEA9\\uDFD4\\uDFD5\\uDFD7\\uDFD8]|\\uD805[\\uDC4B-\\uDC4F\\uDC5A\\uDC5B\\" +
|
|
19
|
+
"uDC5D\\uDCC6\\uDDC1-\\uDDD7\\uDE41-\\uDE43\\uDE60-\\uDE6C\\uDEB9\\uDF3C-\\uDF3E]|\\uD806[\\uDC3B\\uDD44-\\uDD46\\uDDE2\\uDE3F-\\uDE46\\uDE" +
|
|
20
|
+
"9A-\\uDE9C\\uDE9E-\\uDEA2\\uDF00-\\uDF09\\uDFE1]|\\uD807[\\uDC41-\\uDC45\\uDC70\\uDC71\\uDEF7\\uDEF8\\uDF43-\\uDF4F\\uDFFF]|\\uD809[\\uDC7" +
|
|
21
|
+
"0-\\uDC74]|\\uD80B[\\uDFF1\\uDFF2]|\\uD81A[\\uDE6E\\uDE6F\\uDEF5\\uDF37-\\uDF3B\\uDF44]|\\uD81B[\\uDD6D-\\uDD6F\\uDE97-\\uDE9A\\uDFE2]|\\u" +
|
|
22
|
+
"D82F\\uDC9F|\\uD836[\\uDE87-\\uDE8B]|\\uD839\\uDDFF|\\uD83A[\\uDD5E\\uDD5F]");
|
|
23
|
+
const S = new RegExp(
|
|
24
|
+
"[\\$\\+<->\\^`\\|~\\xA2-\\xA6\\xA8\\xA9\\xAC\\xAE-\\xB1\\xB4\\xB8\\xD7\\xF7\\u02C2-\\u02C5\\u02D2-\\u02DF\\u02E5-\\u02EB\\u02ED\\u02EF-\\u02FF\\u" +
|
|
25
|
+
"0375\\u0384\\u0385\\u03F6\\u0482\\u058D-\\u058F\\u0606-\\u0608\\u060B\\u060E\\u060F\\u06DE\\u06E9\\u06FD\\u06FE\\u07F6\\u07FE\\u07FF\\u0888" +
|
|
26
|
+
"\\u09F2\\u09F3\\u09FA\\u09FB\\u0AF1\\u0B70\\u0BF3-\\u0BFA\\u0C7F\\u0D4F\\u0D79\\u0E3F\\u0F01-\\u0F03\\u0F13\\u0F15-\\u0F17\\u0F1A-\\u0F1F\\u" +
|
|
27
|
+
"0F34\\u0F36\\u0F38\\u0FBE-\\u0FC5\\u0FC7-\\u0FCC\\u0FCE\\u0FCF\\u0FD5-\\u0FD8\\u109E\\u109F\\u1390-\\u1399\\u166D\\u17DB\\u1940\\u19DE-\\u1" +
|
|
28
|
+
"9FF\\u1B61-\\u1B6A\\u1B74-\\u1B7C\\u1FBD\\u1FBF-\\u1FC1\\u1FCD-\\u1FCF\\u1FDD-\\u1FDF\\u1FED-\\u1FEF\\u1FFD\\u1FFE\\u2044\\u2052\\u207A-\\u" +
|
|
29
|
+
"207C\\u208A-\\u208C\\u20A0-\\u20C1\\u2100\\u2101\\u2103-\\u2106\\u2108\\u2109\\u2114\\u2116-\\u2118\\u211E-\\u2123\\u2125\\u2127\\u2129\\u2" +
|
|
30
|
+
"12E\\u213A\\u213B\\u2140-\\u2144\\u214A-\\u214D\\u214F\\u218A\\u218B\\u2190-\\u2307\\u230C-\\u2328\\u232B-\\u2429\\u2440-\\u244A\\u249C-\\u" +
|
|
31
|
+
"24E9\\u2500-\\u2767\\u2794-\\u27C4\\u27C7-\\u27E5\\u27F0-\\u2982\\u2999-\\u29D7\\u29DC-\\u29FB\\u29FE-\\u2B73\\u2B76-\\u2BFF\\u2CE5-\\u2CE" +
|
|
32
|
+
"A\\u2E50\\u2E51\\u2E80-\\u2E99\\u2E9B-\\u2EF3\\u2F00-\\u2FD5\\u2FF0-\\u2FFF\\u3004\\u3012\\u3013\\u3020\\u3036\\u3037\\u303E\\u303F\\u309B\\" +
|
|
33
|
+
"u309C\\u3190\\u3191\\u3196-\\u319F\\u31C0-\\u31E5\\u31EF\\u3200-\\u321E\\u322A-\\u3247\\u3250\\u3260-\\u327F\\u328A-\\u32B0\\u32C0-\\u33FF" +
|
|
34
|
+
"\\u4DC0-\\u4DFF\\uA490-\\uA4C6\\uA700-\\uA716\\uA720\\uA721\\uA789\\uA78A\\uA828-\\uA82B\\uA836-\\uA839\\uAA77-\\uAA79\\uAB5B\\uAB6A\\uAB6B" +
|
|
35
|
+
"\\uFB29\\uFBB2-\\uFBD2\\uFD40-\\uFD4F\\uFD90\\uFD91\\uFDC8-\\uFDCF\\uFDFC-\\uFDFF\\uFE62\\uFE64-\\uFE66\\uFE69\\uFF04\\uFF0B\\uFF1C-\\uFF1E" +
|
|
36
|
+
"\\uFF3E\\uFF40\\uFF5C\\uFF5E\\uFFE0-\\uFFE6\\uFFE8-\\uFFEE\\uFFFC\\uFFFD]|\\uD800[\\uDD37-\\uDD3F\\uDD79-\\uDD89\\uDD8C-\\uDD8E\\uDD90-\\uD" +
|
|
37
|
+
"D9C\\uDDA0\\uDDD0-\\uDDFC]|\\uD802[\\uDC77\\uDC78\\uDEC8]|\\uD803[\\uDD8E\\uDD8F\\uDED1-\\uDED8]|\\uD805\\uDF3F|\\uD807[\\uDFD5-\\uDFF1]|" +
|
|
38
|
+
"\\uD81A[\\uDF3C-\\uDF3F\\uDF45]|\\uD82F\\uDC9C|\\uD833[\\uDC00-\\uDCEF\\uDCFA-\\uDCFC\\uDD00-\\uDEB3\\uDEBA-\\uDED0\\uDEE0-\\uDEF0\\uDF50-" +
|
|
39
|
+
"\\uDFC3]|\\uD834[\\uDC00-\\uDCF5\\uDD00-\\uDD26\\uDD29-\\uDD64\\uDD6A-\\uDD6C\\uDD83\\uDD84\\uDD8C-\\uDDA9\\uDDAE-\\uDDEA\\uDE00-\\uDE41\\u" +
|
|
40
|
+
"DE45\\uDF00-\\uDF56]|\\uD835[\\uDEC1\\uDEDB\\uDEFB\\uDF15\\uDF35\\uDF4F\\uDF6F\\uDF89\\uDFA9\\uDFC3]|\\uD836[\\uDC00-\\uDDFF\\uDE37-\\uDE3" +
|
|
41
|
+
"A\\uDE6D-\\uDE74\\uDE76-\\uDE83\\uDE85\\uDE86]|\\uD838[\\uDD4F\\uDEFF]|\\uD83B[\\uDCAC\\uDCB0\\uDD2E\\uDEF0\\uDEF1]|\\uD83C[\\uDC00-\\uDC2" +
|
|
42
|
+
"B\\uDC30-\\uDC93\\uDCA0-\\uDCAE\\uDCB1-\\uDCBF\\uDCC1-\\uDCCF\\uDCD1-\\uDCF5\\uDD0D-\\uDDAD\\uDDE6-\\uDE02\\uDE10-\\uDE3B\\uDE40-\\uDE48\\u" +
|
|
43
|
+
"DE50\\uDE51\\uDE60-\\uDE65\\uDF00-\\uDFFF]|\\uD83D[\\uDC00-\\uDED8\\uDEDC-\\uDEEC\\uDEF0-\\uDEFC\\uDF00-\\uDFD9\\uDFE0-\\uDFEB\\uDFF0]|\\u" +
|
|
44
|
+
"D83E[\\uDC00-\\uDC0B\\uDC10-\\uDC47\\uDC50-\\uDC59\\uDC60-\\uDC87\\uDC90-\\uDCAD\\uDCB0-\\uDCBB\\uDCC0\\uDCC1\\uDCD0-\\uDCD8\\uDD00-\\uDE5" +
|
|
45
|
+
"7\\uDE60-\\uDE6D\\uDE70-\\uDE7C\\uDE80-\\uDE8A\\uDE8E-\\uDEC6\\uDEC8\\uDECD-\\uDEDC\\uDEDF-\\uDEEA\\uDEEF-\\uDEF8\\uDF00-\\uDF92\\uDF94-\\u" +
|
|
46
|
+
"DFEF\\uDFFA]");
|
|
47
|
+
const Z = /[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
|
|
48
|
+
|
|
49
|
+
export { Any, Cc, Cf, P, S, Z };
|
package/dist/page.mjs
CHANGED
|
@@ -11,7 +11,7 @@ export async function writePage(text, name = 'document.md', {include, ...options
|
|
|
11
11
|
const carries = include ?? [...(options.view === 'draw' || options.drawing != null ? ['drawing'] : []), ...portableNeeds(String(text), {base: options.base})];
|
|
12
12
|
return wrap(carry(await carriedPage(), carries), text, name, options);
|
|
13
13
|
}
|
|
14
|
-
const USAGE = 'usage: rapier-html <document.md> [out.html] [--include draw,layout,math,mermaid] [--view draw] [--drawing sketch.svg] [--compare original.md [--by <your name>]] [--return <url> --return-expires-at <timestamp>]\n' +
|
|
14
|
+
const USAGE = 'usage: rapier-html <document.md> [out.html] [--include draw,layout,math,mermaid] [--view draw] [--drawing sketch.svg] [--compare original.md [--by <your name>]] [--return <url> --return-expires-at <timestamp>] [--editor <page.html>]\n' +
|
|
15
15
|
' writes <document>.rapier.html beside the file: Rapier with the document inside it, one file, offline.\n' +
|
|
16
16
|
' It never overwrites: an output that already exists, the document itself included, is refused.\n' +
|
|
17
17
|
' --include what the file carries beyond the base editor: draw (drawing and painting), layout (a template page), math,\n' +
|
|
@@ -23,13 +23,15 @@ const USAGE = 'usage: rapier-html <document.md> [out.html] [--include draw,layou
|
|
|
23
23
|
' --by with --compare: the name shown on the diff with the time the page was made\n' +
|
|
24
24
|
' --return carries a one-use return URL from show {target:"return"}; Share offers Send back\n' +
|
|
25
25
|
' --return-expires-at carries the same mint\'s expiry; Share offers Save once the return expires\n' +
|
|
26
|
+
' --editor the editor page to use: any Rapier .html page, such as one export {format:"html"} delivered; the\n' +
|
|
27
|
+
' page this package carries by default\n' +
|
|
26
28
|
' -- everything after it is a filename, even one that starts with a dash\n' +
|
|
27
29
|
' --help this text';
|
|
28
30
|
const text = async path => { try { return new TextDecoder('utf-8', {fatal: true, ignoreBOM: true}).decode(await readFile(path)); } catch (error) { throw error.code === 'ERR_ENCODING_INVALID_ENCODED_DATA' ? new Error(path + ' is not valid UTF-8') : error; } };
|
|
29
31
|
|
|
30
32
|
export async function main(argv, pagesDir, {log = console.log} = {}) {
|
|
31
33
|
const names = [];
|
|
32
|
-
let drawingPath = null, basePath = null, by = null, view = null, address = null, expiry = null, include = null, onlyNames = false;
|
|
34
|
+
let editorPath = null, drawingPath = null, basePath = null, by = null, view = null, address = null, expiry = null, include = null, onlyNames = false;
|
|
33
35
|
for (let i = 0; i < argv.length; i++) {
|
|
34
36
|
const arg = argv[i];
|
|
35
37
|
if (onlyNames || !arg.startsWith('-')) names.push(arg);
|
|
@@ -57,6 +59,10 @@ export async function main(argv, pagesDir, {log = console.log} = {}) {
|
|
|
57
59
|
if (address !== null || !argv[i + 1] || argv[i + 1].startsWith('-')) throw new Error('--return takes one HTTPS return URL');
|
|
58
60
|
address = returnAddress(argv[++i]);
|
|
59
61
|
}
|
|
62
|
+
else if (arg === '--editor') {
|
|
63
|
+
if (editorPath !== null || !argv[i + 1] || argv[i + 1].startsWith('-')) throw new Error('--editor takes one Rapier .html page');
|
|
64
|
+
editorPath = argv[++i];
|
|
65
|
+
}
|
|
60
66
|
else if (arg === '--return-expires-at') {
|
|
61
67
|
if (expiry !== null || !argv[i + 1] || argv[i + 1].startsWith('-')) throw new Error('--return-expires-at takes one ISO timestamp from show {target:"return"}');
|
|
62
68
|
expiry = returnExpiresAt(argv[++i]);
|
|
@@ -68,7 +74,9 @@ export async function main(argv, pagesDir, {log = console.log} = {}) {
|
|
|
68
74
|
if (names.length < 1 || names.length > 2) throw new Error(USAGE);
|
|
69
75
|
const [input, named] = names;
|
|
70
76
|
const source = await text(input);
|
|
71
|
-
const page = await readFile(join(pagesDir, 'rapier.html'), 'utf8')
|
|
77
|
+
const page = await readFile(editorPath ?? join(pagesDir, 'rapier.html'), 'utf8').catch(error => {
|
|
78
|
+
throw error.code === 'ENOENT' && editorPath === null ? new Error('no editor page beside this helper: pass --editor <a Rapier .html page>') : error;
|
|
79
|
+
});
|
|
72
80
|
const name = basename(input);
|
|
73
81
|
const out = named || join(dirname(input), name.replace(/\.(md|markdown|txt)$/i, '') + '.rapier.html');
|
|
74
82
|
const wrapOptions = {};
|