@canopycanopycanopy/b-ber-parser-dialogue 3.0.0 → 3.0.3
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/dist/index.js +13 -27
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = void 0;
|
|
12
|
-
|
|
13
9
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
14
|
-
|
|
15
10
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
16
|
-
|
|
17
11
|
/* eslint-disable no-param-reassign,no-continue */
|
|
18
12
|
|
|
19
13
|
/*!
|
|
@@ -21,6 +15,7 @@ An adapted version of markdown-it-container 2.0.0
|
|
|
21
15
|
https://github.com//markdown-it/markdown-it-container
|
|
22
16
|
MIT license
|
|
23
17
|
*/
|
|
18
|
+
|
|
24
19
|
const containerPlugin = (md, name, options = {}) => {
|
|
25
20
|
const minMarkers = options.minMarkers || 3;
|
|
26
21
|
const markerStr = options.marker || ':';
|
|
@@ -29,11 +24,11 @@ const containerPlugin = (md, name, options = {}) => {
|
|
|
29
24
|
const {
|
|
30
25
|
validateOpen,
|
|
31
26
|
render
|
|
32
|
-
} = options;
|
|
27
|
+
} = options;
|
|
28
|
+
// const validateClose = options.validateClose
|
|
33
29
|
|
|
34
30
|
function container(state, startLine, endLine, silent) {
|
|
35
31
|
var _context, _context2, _context3, _context4;
|
|
36
|
-
|
|
37
32
|
const lineNumber = startLine + 1;
|
|
38
33
|
let pos;
|
|
39
34
|
let nextLine;
|
|
@@ -41,30 +36,27 @@ const containerPlugin = (md, name, options = {}) => {
|
|
|
41
36
|
let autoClosed = false;
|
|
42
37
|
let start = state.bMarks[startLine] + state.tShift[startLine];
|
|
43
38
|
let max = state.eMarks[startLine];
|
|
44
|
-
if (markerChar !== state.src.charCodeAt(start)) return false;
|
|
39
|
+
if (markerChar !== state.src.charCodeAt(start)) return false;
|
|
45
40
|
|
|
41
|
+
// Check out the rest of the marker string, i.e., count the number of markers
|
|
46
42
|
for (pos = start + 1; pos <= max; pos++) {
|
|
47
43
|
if (markerStr[(pos - start) % markerLen] !== state.src[pos]) {
|
|
48
44
|
break;
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
|
-
|
|
52
47
|
const markerCount = Math.floor((pos - start) / markerLen);
|
|
53
48
|
if (markerCount < minMarkers) return false;
|
|
54
49
|
pos -= (pos - start) % markerLen;
|
|
55
50
|
const markup = (0, _slice.default)(_context = state.src).call(_context, start, pos);
|
|
56
51
|
const params = (0, _slice.default)(_context2 = state.src).call(_context2, pos, max);
|
|
57
|
-
|
|
58
|
-
if (!validateOpen(params, lineNumber)
|
|
59
|
-
/* && !validateClose(params, lineNumber)*/
|
|
60
|
-
) {
|
|
52
|
+
if (!validateOpen(params, lineNumber) /* && !validateClose(params, lineNumber)*/) {
|
|
61
53
|
return false;
|
|
62
54
|
}
|
|
63
|
-
|
|
64
55
|
if (silent) return true; // for testing validation
|
|
65
56
|
|
|
66
|
-
nextLine = startLine;
|
|
57
|
+
nextLine = startLine;
|
|
67
58
|
|
|
59
|
+
// look for closing block
|
|
68
60
|
for (;;) {
|
|
69
61
|
nextLine += 1;
|
|
70
62
|
if (nextLine >= endLine) break; // unclosed block is autoclosed by end of document
|
|
@@ -72,17 +64,16 @@ const containerPlugin = (md, name, options = {}) => {
|
|
|
72
64
|
start = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
73
65
|
max = state.eMarks[nextLine];
|
|
74
66
|
if (state.sCount[nextLine] - state.blkIndent >= 4) continue; // closing fence must be indented less than 4 spaces
|
|
75
|
-
|
|
76
67
|
if (Math.floor((pos - start) / markerLen) < markerCount) continue;
|
|
77
68
|
if (pos < max) continue;
|
|
78
69
|
autoClosed = true;
|
|
79
70
|
break;
|
|
80
71
|
}
|
|
81
|
-
|
|
82
72
|
const oldParent = state.parentType;
|
|
83
73
|
const oldLineMax = state.lineMax;
|
|
84
|
-
state.parentType = 'container';
|
|
74
|
+
state.parentType = 'container';
|
|
85
75
|
|
|
76
|
+
// this will prevent lazy continuations from ever going past our end marker
|
|
86
77
|
state.lineMax = nextLine;
|
|
87
78
|
token = state.push(`container_${name}_open`, 'div', 1);
|
|
88
79
|
token.markup = markup;
|
|
@@ -95,24 +86,21 @@ const containerPlugin = (md, name, options = {}) => {
|
|
|
95
86
|
token.block = true;
|
|
96
87
|
state.parentType = oldParent;
|
|
97
88
|
state.lineMax = oldLineMax;
|
|
98
|
-
state.line = nextLine + (autoClosed ? 1 : 0);
|
|
99
|
-
// set a flag so that we don't render other directives' children which may use the same syntax
|
|
89
|
+
state.line = nextLine + (autoClosed ? 1 : 0);
|
|
100
90
|
|
|
91
|
+
// parse child tokens
|
|
92
|
+
// set a flag so that we don't render other directives' children which may use the same syntax
|
|
101
93
|
let childOfDialogue = false;
|
|
102
94
|
(0, _forEach.default)(_context4 = state.tokens).call(_context4, (t, i) => {
|
|
103
95
|
if (t.type === 'container_dialogue_open') childOfDialogue = true;
|
|
104
96
|
if (t.type === 'container_dialogue_close') childOfDialogue = false;
|
|
105
|
-
|
|
106
97
|
if (t.type === 'inline' && childOfDialogue) {
|
|
107
98
|
const matchedContent = t.content.match(/^(::\s?([^:]+?)\s?::)/);
|
|
108
|
-
|
|
109
99
|
if (matchedContent) {
|
|
110
100
|
const parent = state.tokens[i - 1];
|
|
111
|
-
|
|
112
101
|
if (parent.type === 'paragraph_open') {
|
|
113
102
|
parent.attrPush(['class', 'interlocutor-parent']);
|
|
114
103
|
}
|
|
115
|
-
|
|
116
104
|
t.content = t.content.replace(new RegExp(matchedContent[1]), '');
|
|
117
105
|
t.children.push({
|
|
118
106
|
type: 'inline',
|
|
@@ -134,13 +122,11 @@ const containerPlugin = (md, name, options = {}) => {
|
|
|
134
122
|
});
|
|
135
123
|
return true;
|
|
136
124
|
}
|
|
137
|
-
|
|
138
125
|
md.block.ruler.before('fence', `container_${name}`, container, {
|
|
139
126
|
alt: ['paragraph', 'reference', 'blockquote']
|
|
140
127
|
});
|
|
141
128
|
md.renderer.rules[`container_${name}_open`] = render;
|
|
142
129
|
md.renderer.rules[`container_${name}_close`] = render;
|
|
143
130
|
};
|
|
144
|
-
|
|
145
131
|
var _default = containerPlugin;
|
|
146
132
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-parser-dialogue",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"rimraf": "^2.7.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@canopycanopycanopy/b-ber-lib": "3.0.
|
|
29
|
-
"@canopycanopycanopy/b-ber-logger": "3.0.
|
|
30
|
-
"@canopycanopycanopy/b-ber-shapes-directives": "3.0.
|
|
31
|
-
"@canopycanopycanopy/b-ber-templates": "3.0.
|
|
28
|
+
"@canopycanopycanopy/b-ber-lib": "3.0.3",
|
|
29
|
+
"@canopycanopycanopy/b-ber-logger": "3.0.3",
|
|
30
|
+
"@canopycanopycanopy/b-ber-shapes-directives": "3.0.3",
|
|
31
|
+
"@canopycanopycanopy/b-ber-templates": "3.0.3",
|
|
32
32
|
"lodash": "^4.17.21",
|
|
33
33
|
"tar": "^6.1.11"
|
|
34
34
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"url": "https://maxwellsimmer.com"
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "40898312585810317993e60852ec1d62477085ef"
|
|
53
53
|
}
|