securemark 0.225.1 → 0.225.2
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/CHANGELOG.md +4 -0
- package/design.md +0 -6
- package/dist/securemark.js +24 -14
- package/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/parser/inline/emphasis.test.ts +4 -1
- package/src/parser/inline/mark.test.ts +2 -0
- package/src/parser/inline/ruby.ts +5 -5
- package/src/parser/inline/strong.test.ts +5 -3
- package/src/parser/source/escapable.ts +7 -1
- package/src/parser/util.ts +10 -7
package/CHANGELOG.md
CHANGED
package/design.md
CHANGED
|
@@ -148,12 +148,6 @@
|
|
|
148
148
|
ゆえに参照箇所に実体を記述する注釈構文および識別に文字列を使用する図表構文を採用し、その表示方法は任意とする。
|
|
149
149
|
脚注構文は附番が手作業となり参照と実体の対応の管理が困難であるため不採用とし注釈構文により生成可能とする。
|
|
150
150
|
|
|
151
|
-
### 羅列的知識への非依存
|
|
152
|
-
|
|
153
|
-
構文はその使用のために羅列的知識を求めてはならない。
|
|
154
|
-
|
|
155
|
-
ゆえに構文はHTMLエンティティの参照の有効性を検査しない。
|
|
156
|
-
|
|
157
151
|
### テンプレート対応
|
|
158
152
|
|
|
159
153
|
ソーステキストは自身をテンプレートとして別のソーステキストを生成するための構文を使用できなければならない。
|
package/dist/securemark.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.225.
|
|
1
|
+
/*! securemark v0.225.2 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
|
|
2
2
|
require = function () {
|
|
3
3
|
function r(e, n, t) {
|
|
4
4
|
function o(i, f) {
|
|
@@ -8051,11 +8051,6 @@ require = function () {
|
|
|
8051
8051
|
const acc = [''];
|
|
8052
8052
|
while (source !== '') {
|
|
8053
8053
|
switch (source[0]) {
|
|
8054
|
-
case ' ':
|
|
8055
|
-
case '\u3000':
|
|
8056
|
-
acc.push('');
|
|
8057
|
-
source = source.slice(1);
|
|
8058
|
-
continue;
|
|
8059
8054
|
case '&': {
|
|
8060
8055
|
const result = (0, htmlentity_1.htmlentity)(source, context);
|
|
8061
8056
|
acc[acc.length - 1] += (0, parser_1.eval)(result, [source[0]])[0];
|
|
@@ -8063,6 +8058,11 @@ require = function () {
|
|
|
8063
8058
|
continue;
|
|
8064
8059
|
}
|
|
8065
8060
|
default: {
|
|
8061
|
+
if (source[0].trimStart() === '') {
|
|
8062
|
+
acc.push('');
|
|
8063
|
+
source = source.slice(1);
|
|
8064
|
+
continue;
|
|
8065
|
+
}
|
|
8066
8066
|
const result = (0, source_1.text)(source, context);
|
|
8067
8067
|
acc[acc.length - 1] += (_a = (0, parser_1.eval)(result)[0]) !== null && _a !== void 0 ? _a : source.slice(0, source.length - (0, parser_1.exec)(result).length);
|
|
8068
8068
|
source = (0, parser_1.exec)(result);
|
|
@@ -8642,6 +8642,7 @@ require = function () {
|
|
|
8642
8642
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8643
8643
|
exports.escsource = void 0;
|
|
8644
8644
|
const combinator_1 = _dereq_('../../combinator');
|
|
8645
|
+
const text_1 = _dereq_('./text');
|
|
8645
8646
|
const separator = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
8646
8647
|
exports.escsource = (0, combinator_1.creator)(source => {
|
|
8647
8648
|
if (source === '')
|
|
@@ -8661,9 +8662,11 @@ require = function () {
|
|
|
8661
8662
|
source.slice(2)
|
|
8662
8663
|
];
|
|
8663
8664
|
default:
|
|
8665
|
+
const b = source[0] !== '\n' && source[0].trimStart() === '';
|
|
8666
|
+
const i = b || (0, text_1.isAlphanumeric)(source[0]) ? source.search(b ? text_1.nonWhitespace : text_1.nonAlphanumeric) : 1;
|
|
8664
8667
|
return [
|
|
8665
|
-
[source.slice(0,
|
|
8666
|
-
source.slice(
|
|
8668
|
+
[source.slice(0, i)],
|
|
8669
|
+
source.slice(i)
|
|
8667
8670
|
];
|
|
8668
8671
|
}
|
|
8669
8672
|
default:
|
|
@@ -8674,7 +8677,10 @@ require = function () {
|
|
|
8674
8677
|
}
|
|
8675
8678
|
});
|
|
8676
8679
|
},
|
|
8677
|
-
{
|
|
8680
|
+
{
|
|
8681
|
+
'../../combinator': 30,
|
|
8682
|
+
'./text': 135
|
|
8683
|
+
}
|
|
8678
8684
|
],
|
|
8679
8685
|
133: [
|
|
8680
8686
|
function (_dereq_, module, exports) {
|
|
@@ -9020,16 +9026,20 @@ require = function () {
|
|
|
9020
9026
|
function isEndTightNodes(nodes) {
|
|
9021
9027
|
if (nodes.length === 0)
|
|
9022
9028
|
return true;
|
|
9023
|
-
|
|
9029
|
+
for (let i = nodes.length; i--;) {
|
|
9030
|
+
if (typeof nodes[i] === 'object' && nodes[i]['className'] === 'comment')
|
|
9031
|
+
continue;
|
|
9032
|
+
return isVisible(nodes[i], -1);
|
|
9033
|
+
}
|
|
9034
|
+
return false;
|
|
9024
9035
|
}
|
|
9025
9036
|
exports.isEndTightNodes = isEndTightNodes;
|
|
9026
|
-
function isVisible(node,
|
|
9027
|
-
if (!node)
|
|
9028
|
-
return false;
|
|
9037
|
+
function isVisible(node, strpos) {
|
|
9029
9038
|
switch (typeof node) {
|
|
9030
9039
|
case 'string':
|
|
9031
|
-
const char =
|
|
9040
|
+
const char = node && strpos !== global_1.undefined ? node[strpos >= 0 ? strpos : node.length + strpos] : node;
|
|
9032
9041
|
switch (char) {
|
|
9042
|
+
case '':
|
|
9033
9043
|
case ' ':
|
|
9034
9044
|
case '\t':
|
|
9035
9045
|
case '\n':
|
package/package-lock.json
CHANGED
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ describe('Unit: parser/inline/emphasis', () => {
|
|
|
15
15
|
assert.deepStrictEqual(inspect(parser('*a\\\n*')), [['*', 'a', '<span class="linebreak"> </span>'], '*']);
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('*a**b')), [['*', 'a', '**', 'b'], '']);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('*a**b*')), [['*', 'a', '**', 'b', '*'], '']);
|
|
18
|
+
assert.deepStrictEqual(inspect(parser('*a [# b #]*')), [['*', 'a', ' ', '<sup class="comment" title="b"></sup>'], '*']);
|
|
18
19
|
assert.deepStrictEqual(inspect(parser('* *')), undefined);
|
|
19
20
|
assert.deepStrictEqual(inspect(parser('* a*')), undefined);
|
|
20
21
|
assert.deepStrictEqual(inspect(parser('* a *')), undefined);
|
|
@@ -35,10 +36,12 @@ describe('Unit: parser/inline/emphasis', () => {
|
|
|
35
36
|
assert.deepStrictEqual(inspect(parser('*a\nb*')), [['<em>a<br>b</em>'], '']);
|
|
36
37
|
assert.deepStrictEqual(inspect(parser('*a\\\nb*')), [['<em>a<span class="linebreak"> </span>b</em>'], '']);
|
|
37
38
|
assert.deepStrictEqual(inspect(parser('*a**')), [['<em>a</em>'], '*']);
|
|
38
|
-
assert.deepStrictEqual(inspect(parser('*a**b**c*')), [['<em>a<strong>b</strong>c</em>'], '']);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('nest', () => {
|
|
42
|
+
assert.deepStrictEqual(inspect(parser('*a**b**c*')), [['<em>a<strong>b</strong>c</em>'], '']);
|
|
43
|
+
assert.deepStrictEqual(inspect(parser('*a**b**c*d')), [['<em>a<strong>b</strong>c</em>'], 'd']);
|
|
44
|
+
assert.deepStrictEqual(inspect(parser('*a[# b #]*')), [['<em>a<sup class="comment" title="b"></sup></em>'], '']);
|
|
42
45
|
assert.deepStrictEqual(inspect(parser('*`a`*')), [['<em><code data-src="`a`">a</code></em>'], '']);
|
|
43
46
|
assert.deepStrictEqual(inspect(parser('*<small>*')), [['<em><small></em>'], '']);
|
|
44
47
|
assert.deepStrictEqual(inspect(parser('*(*a*)*')), [['<em><span class="paren">(<em>a</em>)</span></em>'], '']);
|
|
@@ -16,6 +16,7 @@ describe('Unit: parser/inline/mark', () => {
|
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('==a\n==')), [['==', 'a', '<br>'], '==']);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('==a\\ ==')), [['==', 'a', ' '], '==']);
|
|
18
18
|
assert.deepStrictEqual(inspect(parser('==a\\\n==')), [['==', 'a', '<span class="linebreak"> </span>'], '==']);
|
|
19
|
+
assert.deepStrictEqual(inspect(parser('==a [# b #]==')), [['==', 'a', ' ', '<sup class="comment" title="b"></sup>'], '==']);
|
|
19
20
|
assert.deepStrictEqual(inspect(parser('== ==')), undefined);
|
|
20
21
|
assert.deepStrictEqual(inspect(parser('== a==')), undefined);
|
|
21
22
|
assert.deepStrictEqual(inspect(parser('== a ==')), undefined);
|
|
@@ -36,6 +37,7 @@ describe('Unit: parser/inline/mark', () => {
|
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
it('nest', () => {
|
|
40
|
+
assert.deepStrictEqual(inspect(parser('==a[# b #]==')), [['<mark>a<sup class="comment" title="b"></sup></mark>'], '']);
|
|
39
41
|
assert.deepStrictEqual(inspect(parser('==*==a==*==')), [['<mark><em><mark>a</mark></em></mark>'], '']);
|
|
40
42
|
});
|
|
41
43
|
|
|
@@ -51,11 +51,6 @@ const text: RubyParser.TextParser = creator((source, context) => {
|
|
|
51
51
|
while (source !== '') {
|
|
52
52
|
assert(source[0] !== '\n');
|
|
53
53
|
switch (source[0]) {
|
|
54
|
-
case ' ':
|
|
55
|
-
case ' ':
|
|
56
|
-
acc.push('');
|
|
57
|
-
source = source.slice(1);
|
|
58
|
-
continue;
|
|
59
54
|
case '&': {
|
|
60
55
|
const result = htmlentity(source, context);
|
|
61
56
|
acc[acc.length - 1] += eval(result, [source[0]])[0];
|
|
@@ -63,6 +58,11 @@ const text: RubyParser.TextParser = creator((source, context) => {
|
|
|
63
58
|
continue;
|
|
64
59
|
}
|
|
65
60
|
default: {
|
|
61
|
+
if (source[0].trimStart() === '') {
|
|
62
|
+
acc.push('');
|
|
63
|
+
source = source.slice(1);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
66
|
const result = txt(source, context)!;
|
|
67
67
|
assert(result);
|
|
68
68
|
acc[acc.length - 1] += eval(result)[0] ?? source.slice(0, source.length - exec(result).length);
|
|
@@ -15,6 +15,7 @@ describe('Unit: parser/inline/strong', () => {
|
|
|
15
15
|
assert.deepStrictEqual(inspect(parser('**a\\ **')), [['**', 'a', ' '], '**']);
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('**a\\\n**')), [['**', 'a', '<span class="linebreak"> </span>'], '**']);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('**a*b**')), [['**', 'a', '<em>b</em>', '*'], '']);
|
|
18
|
+
assert.deepStrictEqual(inspect(parser('**a [# b #]**')), [['**', 'a', ' ', '<sup class="comment" title="b"></sup>'], '**']);
|
|
18
19
|
assert.deepStrictEqual(inspect(parser('** **')), undefined);
|
|
19
20
|
assert.deepStrictEqual(inspect(parser('** a**')), undefined);
|
|
20
21
|
assert.deepStrictEqual(inspect(parser('** a **')), undefined);
|
|
@@ -33,12 +34,13 @@ describe('Unit: parser/inline/strong', () => {
|
|
|
33
34
|
assert.deepStrictEqual(inspect(parser('**ab**')), [['<strong>ab</strong>'], '']);
|
|
34
35
|
assert.deepStrictEqual(inspect(parser('**a\nb**')), [['<strong>a<br>b</strong>'], '']);
|
|
35
36
|
assert.deepStrictEqual(inspect(parser('**a\\\nb**')), [['<strong>a<span class="linebreak"> </span>b</strong>'], '']);
|
|
36
|
-
assert.deepStrictEqual(inspect(parser('**a*b*c**')), [['<strong>a<em>b</em>c</strong>'], '']);
|
|
37
|
-
assert.deepStrictEqual(inspect(parser('**a*b*c**d')), [['<strong>a<em>b</em>c</strong>'], 'd']);
|
|
38
|
-
assert.deepStrictEqual(inspect(parser('**a *b***')), [['<strong>a <em>b</em></strong>'], '']);
|
|
39
37
|
});
|
|
40
38
|
|
|
41
39
|
it('nest', () => {
|
|
40
|
+
assert.deepStrictEqual(inspect(parser('**a*b*c**')), [['<strong>a<em>b</em>c</strong>'], '']);
|
|
41
|
+
assert.deepStrictEqual(inspect(parser('**a*b*c**d')), [['<strong>a<em>b</em>c</strong>'], 'd']);
|
|
42
|
+
assert.deepStrictEqual(inspect(parser('**a *b***')), [['<strong>a <em>b</em></strong>'], '']);
|
|
43
|
+
assert.deepStrictEqual(inspect(parser('**a[# b #]**')), [['<strong>a<sup class="comment" title="b"></sup></strong>'], '']);
|
|
42
44
|
assert.deepStrictEqual(inspect(parser('**`a`**')), [['<strong><code data-src="`a`">a</code></strong>'], '']);
|
|
43
45
|
assert.deepStrictEqual(inspect(parser('**<small>**')), [['<strong><small></strong>'], '']);
|
|
44
46
|
assert.deepStrictEqual(inspect(parser('**(*a*)**')), [['<strong><span class="paren">(<em>a</em>)</span></strong>'], '']);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EscapableSourceParser } from '../source';
|
|
2
2
|
import { creator } from '../../combinator';
|
|
3
|
+
import { nonWhitespace, nonAlphanumeric, isAlphanumeric } from './text';
|
|
3
4
|
|
|
4
5
|
const separator = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
|
|
5
6
|
|
|
@@ -15,7 +16,12 @@ export const escsource: EscapableSourceParser = creator(source => {
|
|
|
15
16
|
case '\\':
|
|
16
17
|
return [[source.slice(0, 2)], source.slice(2)];
|
|
17
18
|
default:
|
|
18
|
-
|
|
19
|
+
const b = source[0] !== '\n' && source[0].trimStart() === '';
|
|
20
|
+
const i = b || isAlphanumeric(source[0])
|
|
21
|
+
? source.search(b ? nonWhitespace : nonAlphanumeric)
|
|
22
|
+
: 1;
|
|
23
|
+
assert(i > 0);
|
|
24
|
+
return [[source.slice(0, i)], source.slice(i)];
|
|
19
25
|
}
|
|
20
26
|
default:
|
|
21
27
|
return [[source.slice(0, i)], source.slice(i)];
|
package/src/parser/util.ts
CHANGED
|
@@ -135,17 +135,20 @@ export function isStartTightNodes(nodes: readonly (HTMLElement | string)[]): boo
|
|
|
135
135
|
}
|
|
136
136
|
export function isEndTightNodes(nodes: readonly (HTMLElement | string)[]): boolean {
|
|
137
137
|
if (nodes.length === 0) return true;
|
|
138
|
-
|
|
138
|
+
for (let i = nodes.length; i--;) {
|
|
139
|
+
if (typeof nodes[i] === 'object' && nodes[i]['className'] === 'comment') continue;
|
|
140
|
+
return isVisible(nodes[i], -1);
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
139
143
|
}
|
|
140
|
-
function isVisible(node: HTMLElement | string,
|
|
141
|
-
if (!node) return false;
|
|
144
|
+
function isVisible(node: HTMLElement | string, strpos?: number): boolean {
|
|
142
145
|
switch (typeof node) {
|
|
143
146
|
case 'string':
|
|
144
|
-
const char =
|
|
145
|
-
? node
|
|
146
|
-
: node
|
|
147
|
-
assert(char);
|
|
147
|
+
const char = node && strpos !== undefined
|
|
148
|
+
? node[strpos >= 0 ? strpos : node.length + strpos]
|
|
149
|
+
: node;
|
|
148
150
|
switch (char) {
|
|
151
|
+
case '':
|
|
149
152
|
case ' ':
|
|
150
153
|
case '\t':
|
|
151
154
|
case '\n':
|