@mdsvex/parse 1.0.0-next.4 → 1.1.0
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/PLUGINS.md +24 -0
- package/WIRE_FORMAT.md +4 -2
- package/dist/buf-utils.js +139 -106
- package/dist/buf_utils.d.ts +13 -0
- package/dist/heading_ids.d.ts +2 -0
- package/dist/main.d.ts +13 -1
- package/dist/main.js +2201 -1730
- package/dist/{node_view-DEZDLDFD.js → node_view-DEaYKJq-.js} +22 -19
- package/dist/node_view.d.ts +3 -0
- package/dist/plugin_dispatch.d.ts +4 -2
- package/dist/plugin_types.d.ts +15 -0
- package/dist/reader_text.d.ts +17 -0
- package/dist/tree-builder.js +199 -110
- package/dist/tree_builder.d.ts +20 -1
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +263 -241
- package/dist/wire-tree-builder.js +8 -8
- package/package.json +1 -1
package/dist/tree-builder.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NodeBuffer as
|
|
2
|
-
const
|
|
1
|
+
import { NodeBuffer as c, merge_meta as u, make_meta as p } from "./utils.js";
|
|
2
|
+
const r = 4294967295, m = new Int32Array(64);
|
|
3
3
|
class v {
|
|
4
4
|
constructor(e, s) {
|
|
5
|
-
this.id_to_index = null, this.revoked = null, this.revoked_map = null, this.revoked_mapped = 0, this.plain_from = 0, this.ids = null, this.headings = null, this.nodes = new
|
|
5
|
+
this.id_to_index = null, this.revoked = null, this.revoked_map = null, this.revoked_mapped = 0, this.plain_from = 0, this.ids = null, this.headings = null, this.fed_to = 0, this.shown = null, this.nodes = new c(e), this.dispatcher = s ?? null, this.wants = s !== void 0 ? s.open_wants : m;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* reset the builder for another complete document
|
|
@@ -11,7 +11,7 @@ class v {
|
|
|
11
11
|
* document until a batch caller points it at the new one with set_source
|
|
12
12
|
*/
|
|
13
13
|
reset() {
|
|
14
|
-
this.nodes.reset(), this.nodes.push(0, 0), this.id_to_index = null;
|
|
14
|
+
this.fed_to = 0, this.shown !== null && (this.shown.length = 0), this.nodes.reset(), this.nodes.push(0, 0), this.id_to_index = null;
|
|
15
15
|
const e = this.dispatcher;
|
|
16
16
|
e !== null ? (e.reset(), this.refresh(e), this.revoked_map = null, this.revoked_mapped = 0) : this.revoked !== null && (this.revoked = null, this.revoked_map = null, this.revoked_mapped = 0);
|
|
17
17
|
}
|
|
@@ -47,227 +47,227 @@ class v {
|
|
|
47
47
|
}
|
|
48
48
|
start_id_map() {
|
|
49
49
|
const e = this.nodes._size, s = [];
|
|
50
|
-
for (let
|
|
51
|
-
s.push(
|
|
50
|
+
for (let t = 0; t < e; t++)
|
|
51
|
+
s.push(t);
|
|
52
52
|
return this.id_to_index = s, s;
|
|
53
53
|
}
|
|
54
54
|
/** for callers that do not pass the kind, a revoke may have rewritten it */
|
|
55
55
|
opened_kind(e) {
|
|
56
56
|
const s = this.dispatcher !== null ? this.dispatcher.kind_log() : this.revoked;
|
|
57
57
|
if (s !== null) {
|
|
58
|
-
let
|
|
59
|
-
|
|
58
|
+
let t = this.revoked_map;
|
|
59
|
+
t === null && (t = this.revoked_map = /* @__PURE__ */ new Map());
|
|
60
60
|
for (let n = this.revoked_mapped; n < s.length; n += 2)
|
|
61
|
-
|
|
61
|
+
t.has(s[n]) || t.set(s[n], s[n + 1]);
|
|
62
62
|
this.revoked_mapped = s.length;
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
return
|
|
63
|
+
const i = t.get(e);
|
|
64
|
+
if (i !== void 0)
|
|
65
|
+
return i;
|
|
66
66
|
}
|
|
67
67
|
return this.nodes._n[
|
|
68
68
|
e * 12
|
|
69
69
|
/* NodeField.stride */
|
|
70
70
|
] & 255;
|
|
71
71
|
}
|
|
72
|
-
open(e, s,
|
|
73
|
-
const
|
|
74
|
-
if (this.id_to_index === null && e ===
|
|
75
|
-
|
|
72
|
+
open(e, s, t, i, n, h) {
|
|
73
|
+
const o = this.nodes;
|
|
74
|
+
if (this.id_to_index === null && e === o._size && i >= this.wants[s]) {
|
|
75
|
+
o.push_node(s, t, i >>> 0, n, h);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
e !== 0 && this.open_slow(e, s,
|
|
78
|
+
e !== 0 && this.open_slow(e, s, t, i, n, h);
|
|
79
79
|
}
|
|
80
|
-
open_slow(e, s,
|
|
81
|
-
const
|
|
82
|
-
if (d !== null && this.id_to_index === null && e ===
|
|
83
|
-
let
|
|
80
|
+
open_slow(e, s, t, i, n, h) {
|
|
81
|
+
const o = this.nodes, d = this.dispatcher;
|
|
82
|
+
if (d !== null && this.id_to_index === null && e === o._size) {
|
|
83
|
+
let _ = i === -1 ? r : i;
|
|
84
84
|
if (d.has_handlers(s)) {
|
|
85
|
-
const l =
|
|
86
|
-
d.dispatch_open(l, s,
|
|
85
|
+
const l = o.push_node(s, t, _, n, h);
|
|
86
|
+
d.dispatch_open(l, s, o), this.refresh(d), o._size !== l + 1 && this.pushed();
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
_ !== r && (_ = d.resolve(_)), o.push_node(s, t, _, n, h);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
this.open_mapped(e, s,
|
|
92
|
+
this.open_mapped(e, s, t, i, n, h);
|
|
93
93
|
}
|
|
94
94
|
/** an open once a plugin pushed nodes without ids or ids skipped a slot */
|
|
95
|
-
open_mapped(e, s,
|
|
96
|
-
const
|
|
97
|
-
let l =
|
|
95
|
+
open_mapped(e, s, t, i, n, h) {
|
|
96
|
+
const o = this.nodes, d = this.dispatcher, _ = this.id_to_index ?? this.start_id_map();
|
|
97
|
+
let l = i === -1 ? r : _[i] ?? r;
|
|
98
98
|
if (d !== null) {
|
|
99
99
|
if (d.has_handlers(s)) {
|
|
100
|
-
const
|
|
101
|
-
|
|
100
|
+
const f = o.push_node(s, t, l, n, h);
|
|
101
|
+
_[e] = f, d.dispatch_open(f, s, o), this.refresh(d);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
l !==
|
|
104
|
+
l !== r && (l = d.resolve(l));
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
_[e] = o.push_node(s, t, l, n, h);
|
|
107
107
|
}
|
|
108
|
-
close(e, s,
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
108
|
+
close(e, s, t) {
|
|
109
|
+
const i = this.index_of(e);
|
|
110
|
+
if (i === void 0)
|
|
111
111
|
return;
|
|
112
|
-
const n =
|
|
113
|
-
if (
|
|
112
|
+
const n = i * 12, h = this.nodes._n;
|
|
113
|
+
if (h[
|
|
114
114
|
n + 2
|
|
115
115
|
/* NodeField.end */
|
|
116
|
-
] = s,
|
|
116
|
+
] = s, i >= this.plain_from && t !== void 0 && t !== 15 && t !== 3 && (t !== 7 || h[
|
|
117
117
|
n + 10
|
|
118
118
|
/* NodeField.pending */
|
|
119
119
|
] === 0)) {
|
|
120
|
-
|
|
120
|
+
h[
|
|
121
121
|
n + 10
|
|
122
122
|
/* NodeField.pending */
|
|
123
123
|
] = 0;
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
this.close_rest(
|
|
126
|
+
this.close_rest(i, n, t);
|
|
127
127
|
}
|
|
128
128
|
/** a delimiter the parser gave up on, closed but not final, its revoke follows */
|
|
129
|
-
close_pending(e, s,
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
129
|
+
close_pending(e, s, t) {
|
|
130
|
+
const i = this.index_of(e);
|
|
131
|
+
if (i === void 0)
|
|
132
132
|
return;
|
|
133
|
-
const n =
|
|
133
|
+
const n = i * 12;
|
|
134
134
|
this.nodes._n[
|
|
135
135
|
n + 2
|
|
136
136
|
/* NodeField.end */
|
|
137
|
-
] = s, this.close_rest(
|
|
137
|
+
] = s, this.close_rest(i, n, t, !0);
|
|
138
138
|
}
|
|
139
|
-
close_rest(e, s,
|
|
140
|
-
const n = this.nodes,
|
|
141
|
-
if (e < this.plain_from &&
|
|
142
|
-
|
|
139
|
+
close_rest(e, s, t, i = !1) {
|
|
140
|
+
const n = this.nodes, h = this.dispatcher;
|
|
141
|
+
if (e < this.plain_from && h !== null && !h.plain_close(e)) {
|
|
142
|
+
t === void 0 && (t = this.opened_kind(e));
|
|
143
143
|
const d = n._size;
|
|
144
|
-
|
|
144
|
+
h.dispatch_close(
|
|
145
145
|
e,
|
|
146
146
|
n,
|
|
147
|
-
|
|
147
|
+
i || t === 7
|
|
148
148
|
/* NodeKind.paragraph */
|
|
149
|
-
), this.refresh(
|
|
149
|
+
), this.refresh(h), n._size !== d && this.pushed();
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
|
|
151
|
+
t === void 0 && (t = this.opened_kind(e));
|
|
152
|
+
const o = n._n;
|
|
153
|
+
if (t === 3) {
|
|
154
|
+
o[
|
|
155
155
|
s + 10
|
|
156
156
|
/* NodeField.pending */
|
|
157
157
|
] = 0, this.headings !== null && this.headings.close(n, e);
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
t === 7 && o[
|
|
161
161
|
s + 10
|
|
162
162
|
/* NodeField.pending */
|
|
163
|
-
] === 1 && (
|
|
164
|
-
|
|
163
|
+
] === 1 && (o[
|
|
164
|
+
o[
|
|
165
165
|
s + 5
|
|
166
166
|
/* NodeField.parent */
|
|
167
167
|
] * 12
|
|
168
168
|
/* NodeField.stride */
|
|
169
|
-
] & 255) === 16 || (
|
|
169
|
+
] & 255) === 16 || (o[
|
|
170
170
|
s + 10
|
|
171
171
|
/* NodeField.pending */
|
|
172
|
-
] = 0,
|
|
172
|
+
] = 0, t === 15 && this.unwrap_tight_list(e));
|
|
173
173
|
}
|
|
174
174
|
/** a no op when finalize_list_pending_paras already revoked the paragraphs */
|
|
175
175
|
unwrap_tight_list(e) {
|
|
176
|
-
const s = this.nodes,
|
|
177
|
-
if (!
|
|
176
|
+
const s = this.nodes, t = s.metadata_at(e);
|
|
177
|
+
if (!t || !t.tight)
|
|
178
178
|
return;
|
|
179
|
-
let
|
|
179
|
+
let i = s.first_child_at(e), n = i !== r && s.parent_at(i) === e;
|
|
180
180
|
for (; n; ) {
|
|
181
|
-
const
|
|
182
|
-
n =
|
|
183
|
-
let
|
|
181
|
+
const h = s.next_at(i);
|
|
182
|
+
n = h !== r && s.parent_at(h) === e;
|
|
183
|
+
let o = s.first_child_at(i), d = o !== r && s.parent_at(o) === i;
|
|
184
184
|
for (; d; ) {
|
|
185
|
-
const
|
|
186
|
-
d =
|
|
185
|
+
const _ = s.next_at(o);
|
|
186
|
+
d = _ !== r && s.parent_at(_) === i, s.kind_at(o) === 7 && s.unwrap_node(o), o = _;
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
i = h;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
text(e, s,
|
|
191
|
+
text(e, s, t, i) {
|
|
192
192
|
let n = this.index_of(e);
|
|
193
|
-
n !== void 0 && (this.dispatcher !== null ? (
|
|
193
|
+
n !== void 0 && (this.dispatcher !== null ? (i === void 0 && (i = this.opened_kind(n)), n = this.dispatcher.resolve(n)) : i === void 0 && (i = this.opened_kind(n)), i === 3 || i === 5 || i === 8 || i === 26 ? this.nodes.set_value(n, s, t) : this.nodes.push_text(s, t, n));
|
|
194
194
|
}
|
|
195
|
-
leaf(e, s,
|
|
195
|
+
leaf(e, s, t, i, n, h, o) {
|
|
196
196
|
const d = this.nodes;
|
|
197
|
-
if (this.id_to_index === null && e === d._size && (this.dispatcher === null ||
|
|
198
|
-
d.push_leaf(s,
|
|
197
|
+
if (this.id_to_index === null && e === d._size && (this.dispatcher === null || i >= this.wants[s])) {
|
|
198
|
+
d.push_leaf(s, t, n, h, o, i);
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
|
-
this.leaf_rest(e, s,
|
|
201
|
+
this.leaf_rest(e, s, t, i, n, h, o);
|
|
202
202
|
}
|
|
203
|
-
leaf_rest(e, s,
|
|
204
|
-
const d = this.nodes,
|
|
205
|
-
if (
|
|
206
|
-
d.push_leaf(s,
|
|
203
|
+
leaf_rest(e, s, t, i, n, h, o) {
|
|
204
|
+
const d = this.nodes, _ = this.dispatcher;
|
|
205
|
+
if (_ !== null && this.id_to_index === null && e === d._size && !_.has_handlers(s)) {
|
|
206
|
+
d.push_leaf(s, t, n, h, o, _.resolve(i));
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
this.open(e, s,
|
|
209
|
+
this.open(e, s, t, i, 0, !1), this.set_value_start(e, n), this.set_value_end(e, h), this.close(e, o, s);
|
|
210
210
|
}
|
|
211
|
-
attr(e, s,
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
211
|
+
attr(e, s, t) {
|
|
212
|
+
const i = this.index_of(e);
|
|
213
|
+
if (i !== void 0)
|
|
214
214
|
switch (s) {
|
|
215
215
|
case "value":
|
|
216
|
-
this.nodes.set_value(
|
|
216
|
+
this.nodes.set_value(i, t[0], t[1]);
|
|
217
217
|
break;
|
|
218
218
|
case "text":
|
|
219
|
-
this.nodes.own_strings()[
|
|
219
|
+
this.nodes.own_strings()[i] = t;
|
|
220
220
|
break;
|
|
221
221
|
case "value_start":
|
|
222
|
-
this.nodes.set_value_start(
|
|
222
|
+
this.nodes.set_value_start(i, t);
|
|
223
223
|
break;
|
|
224
224
|
case "value_end":
|
|
225
|
-
this.nodes.set_value_end(
|
|
225
|
+
this.nodes.set_value_end(i, t);
|
|
226
226
|
break;
|
|
227
227
|
default: {
|
|
228
|
-
const n = this.nodes,
|
|
229
|
-
|
|
228
|
+
const n = this.nodes, h = n.metadata_at(i);
|
|
229
|
+
h ? u(h, s, t) : n.set_metadata(i, p(s, t)), this.dispatcher !== null && (s === "name" ? this.named(i, t) : s === "info_end" && this.dispatcher.holds(i) && this.unheld(this.dispatcher));
|
|
230
230
|
break;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
/** only a directive gets a name, its open handlers and the handlers bound to it start here */
|
|
235
235
|
named(e, s) {
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
236
|
+
const t = this.dispatcher;
|
|
237
|
+
if (!t.wants_name())
|
|
238
238
|
return;
|
|
239
|
-
const
|
|
240
|
-
|
|
239
|
+
const i = this.nodes, n = i._size;
|
|
240
|
+
t.dispatch_name(e, s, i), this.refresh(t), i._size !== n && this.pushed();
|
|
241
241
|
}
|
|
242
242
|
/** the open handlers of a held node ran, they may have pushed nodes and made links */
|
|
243
243
|
unheld(e) {
|
|
244
|
-
const s = this.nodes,
|
|
245
|
-
e.unhold(s), this.refresh(e), s._size !==
|
|
244
|
+
const s = this.nodes, t = s._size;
|
|
245
|
+
e.unhold(s), this.refresh(e), s._size !== t && this.pushed();
|
|
246
246
|
}
|
|
247
247
|
set_value_start(e, s) {
|
|
248
|
-
const
|
|
249
|
-
|
|
248
|
+
const t = this.index_of(e);
|
|
249
|
+
t !== void 0 && this.nodes.set_value_start(t, s);
|
|
250
250
|
}
|
|
251
251
|
set_value_end(e, s) {
|
|
252
|
-
const i = this.index_of(e);
|
|
253
|
-
i !== void 0 && this.nodes.set_value_end(i, s);
|
|
254
|
-
}
|
|
255
|
-
revoke(e, s, i) {
|
|
256
252
|
const t = this.index_of(e);
|
|
257
|
-
|
|
253
|
+
t !== void 0 && this.nodes.set_value_end(t, s);
|
|
254
|
+
}
|
|
255
|
+
revoke(e, s, t) {
|
|
256
|
+
const i = this.index_of(e);
|
|
257
|
+
if (i === void 0)
|
|
258
258
|
return;
|
|
259
|
-
const n = this.nodes,
|
|
259
|
+
const n = this.nodes, h = n._size;
|
|
260
260
|
if (this.dispatcher !== null) {
|
|
261
|
-
if (this.dispatcher.dispatch_revoke(
|
|
261
|
+
if (this.dispatcher.dispatch_revoke(i, n), this.refresh(this.dispatcher), n.parent_at(i) === r)
|
|
262
262
|
return;
|
|
263
|
-
const d = n.kind_at(
|
|
264
|
-
n.handle_repair(
|
|
263
|
+
const d = n.kind_at(i), _ = this.dispatcher.lifted(i, n);
|
|
264
|
+
n.handle_repair(i, s, t), n.kind_at(i) !== d && this.dispatcher.log_kind(i, d), n._size !== h && this.pushed(), _ !== null && (this.dispatcher.dispatch_lifted(_, n), this.refresh(this.dispatcher));
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
-
const
|
|
268
|
-
if (n.handle_repair(
|
|
267
|
+
const o = n.kind_at(i);
|
|
268
|
+
if (n.handle_repair(i, s, t), n._size !== h && this.pushed(), n.kind_at(i) !== o) {
|
|
269
269
|
const d = this.revoked;
|
|
270
|
-
d === null ? this.revoked = [
|
|
270
|
+
d === null ? this.revoked = [i, o] : d.push(i, o);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
commit(e) {
|
|
@@ -275,6 +275,95 @@ class v {
|
|
|
275
275
|
s !== void 0 && (this.nodes.commit_node(s), this.dispatcher && (this.dispatcher.dispatch_commit(s), this.plain_from = this.dispatcher.plain_from()));
|
|
276
276
|
}
|
|
277
277
|
cursor(e) {
|
|
278
|
+
this.fed_to = e;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* gives the text the input has not ended yet a value end, so a render
|
|
282
|
+
* between two feeds shows the line being written, call it after a feed
|
|
283
|
+
* with the source fed so far and hide_open_text before the next feed or
|
|
284
|
+
* the finish, the parser must not see these ends
|
|
285
|
+
*
|
|
286
|
+
* a text run ends where the parser stopped, less the spaces and tabs it
|
|
287
|
+
* would trim, a code span or an html comment where the parser stopped, and
|
|
288
|
+
* a code fence at the end of the source, less a last line that starts with
|
|
289
|
+
* a backtick and may be its closing fence
|
|
290
|
+
* @returns true when a node changed
|
|
291
|
+
*/
|
|
292
|
+
show_open_text(e) {
|
|
293
|
+
const s = this.nodes._n, t = this.shown ?? (this.shown = []), i = this.fed_to;
|
|
294
|
+
let n = s[
|
|
295
|
+
9
|
|
296
|
+
/* NodeField.last_child */
|
|
297
|
+
];
|
|
298
|
+
for (; n !== r; ) {
|
|
299
|
+
const h = n * 12;
|
|
300
|
+
if (s[
|
|
301
|
+
h + 2
|
|
302
|
+
/* NodeField.end */
|
|
303
|
+
] !== r)
|
|
304
|
+
break;
|
|
305
|
+
const o = s[
|
|
306
|
+
h + 3
|
|
307
|
+
/* NodeField.value_start */
|
|
308
|
+
], d = s[h] & 255;
|
|
309
|
+
if (s[
|
|
310
|
+
h + 4
|
|
311
|
+
/* NodeField.value_end */
|
|
312
|
+
] <= o && (d === 1 || o > s[
|
|
313
|
+
h + 1
|
|
314
|
+
/* NodeField.start */
|
|
315
|
+
])) {
|
|
316
|
+
let _ = o;
|
|
317
|
+
if (d === 1)
|
|
318
|
+
for (_ = i; _ > o; ) {
|
|
319
|
+
const l = e.charCodeAt(_ - 1);
|
|
320
|
+
if (l !== 32 && l !== 9)
|
|
321
|
+
break;
|
|
322
|
+
_--;
|
|
323
|
+
}
|
|
324
|
+
else if (d === 8 || d === 26)
|
|
325
|
+
_ = i;
|
|
326
|
+
else if (d === 5) {
|
|
327
|
+
_ = e.length;
|
|
328
|
+
let l = e.lastIndexOf(`
|
|
329
|
+
`, _ - 1) + 1;
|
|
330
|
+
l < o && (l = o);
|
|
331
|
+
const f = l;
|
|
332
|
+
for (; l < _; ) {
|
|
333
|
+
const a = e.charCodeAt(l);
|
|
334
|
+
if (a !== 32 && a !== 9)
|
|
335
|
+
break;
|
|
336
|
+
l++;
|
|
337
|
+
}
|
|
338
|
+
l < _ && e.charCodeAt(l) === 96 && (_ = f);
|
|
339
|
+
}
|
|
340
|
+
_ > o && (t.push(n, s[
|
|
341
|
+
h + 4
|
|
342
|
+
/* NodeField.value_end */
|
|
343
|
+
]), s[
|
|
344
|
+
h + 4
|
|
345
|
+
/* NodeField.value_end */
|
|
346
|
+
] = _);
|
|
347
|
+
}
|
|
348
|
+
n = s[
|
|
349
|
+
h + 9
|
|
350
|
+
/* NodeField.last_child */
|
|
351
|
+
];
|
|
352
|
+
}
|
|
353
|
+
return t.length !== 0;
|
|
354
|
+
}
|
|
355
|
+
/** takes back the value ends show_open_text gave */
|
|
356
|
+
hide_open_text() {
|
|
357
|
+
const e = this.shown;
|
|
358
|
+
if (e === null || e.length === 0)
|
|
359
|
+
return;
|
|
360
|
+
const s = this.nodes._n;
|
|
361
|
+
for (let t = 0; t < e.length; t += 2)
|
|
362
|
+
s[
|
|
363
|
+
e[t] * 12 + 4
|
|
364
|
+
/* NodeField.value_end */
|
|
365
|
+
] = e[t + 1];
|
|
366
|
+
e.length = 0;
|
|
278
367
|
}
|
|
279
368
|
/** an incremental document is complete, give its unused slab tail back */
|
|
280
369
|
end() {
|
package/dist/tree_builder.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export declare class TreeBuilder implements Emitter {
|
|
|
35
35
|
private ids;
|
|
36
36
|
/** makes the id of each heading as it closes, null for none */
|
|
37
37
|
private headings;
|
|
38
|
+
/** where the parser stopped at the end of the last feed */
|
|
39
|
+
private fed_to;
|
|
40
|
+
/** each node show_open_text gave a value end and the one it had, hide_open_text puts it back */
|
|
41
|
+
private shown;
|
|
38
42
|
constructor(capacity: number, dispatcher?: PluginDispatcher);
|
|
39
43
|
/**
|
|
40
44
|
* reset the builder for another complete document
|
|
@@ -84,7 +88,22 @@ export declare class TreeBuilder implements Emitter {
|
|
|
84
88
|
set_value_end(id: number, pos: number): void;
|
|
85
89
|
revoke(id: number, source_text?: string, text_start?: number): void;
|
|
86
90
|
commit(id: number): void;
|
|
87
|
-
cursor(
|
|
91
|
+
cursor(pos: number): void;
|
|
92
|
+
/**
|
|
93
|
+
* gives the text the input has not ended yet a value end, so a render
|
|
94
|
+
* between two feeds shows the line being written, call it after a feed
|
|
95
|
+
* with the source fed so far and hide_open_text before the next feed or
|
|
96
|
+
* the finish, the parser must not see these ends
|
|
97
|
+
*
|
|
98
|
+
* a text run ends where the parser stopped, less the spaces and tabs it
|
|
99
|
+
* would trim, a code span or an html comment where the parser stopped, and
|
|
100
|
+
* a code fence at the end of the source, less a last line that starts with
|
|
101
|
+
* a backtick and may be its closing fence
|
|
102
|
+
* @returns true when a node changed
|
|
103
|
+
*/
|
|
104
|
+
show_open_text(source: string): boolean;
|
|
105
|
+
/** takes back the value ends show_open_text gave */
|
|
106
|
+
hide_open_text(): void;
|
|
88
107
|
/** an incremental document is complete, give its unused slab tail back */
|
|
89
108
|
end(): void;
|
|
90
109
|
/** extract the built NodeBuffer. */
|
package/dist/utils.d.ts
CHANGED
|
@@ -78,6 +78,12 @@ export declare const string_to_kind: (name: string) => NodeKind | undefined;
|
|
|
78
78
|
* takes it from the outer document, which therefore looks either way
|
|
79
79
|
*/
|
|
80
80
|
export declare function take_src(): boolean;
|
|
81
|
+
/** @internal bumped when an html heading tag or a footnote node enters a buffer */
|
|
82
|
+
export declare function bump_id_scan(): void;
|
|
83
|
+
/** @internal current generation of html heading and footnote additions */
|
|
84
|
+
export declare function get_id_scan(): number;
|
|
85
|
+
/** @internal true when tag is h1 through h6 */
|
|
86
|
+
export declare function is_html_heading(tag: unknown): boolean;
|
|
81
87
|
/** @internal the parser made a footnote reference or definition */
|
|
82
88
|
export declare function note_footnote(): void;
|
|
83
89
|
/**
|
|
@@ -86,6 +92,14 @@ export declare function note_footnote(): void;
|
|
|
86
92
|
* them, the note is shared between documents as the note of take_src is
|
|
87
93
|
*/
|
|
88
94
|
export declare function take_footnote(): boolean;
|
|
95
|
+
/** @internal a parse ended with a link reference whose label has no definition */
|
|
96
|
+
export declare function note_reference(): void;
|
|
97
|
+
/**
|
|
98
|
+
* @internal true once when a parse ended with a link reference that has no
|
|
99
|
+
* definition since the last call, so only such a document is looked through
|
|
100
|
+
* for them, the note is shared between documents as the note of take_src is
|
|
101
|
+
*/
|
|
102
|
+
export declare function take_reference(): boolean;
|
|
89
103
|
/** @internal the parser made an inline math span */
|
|
90
104
|
export declare function note_math(): void;
|
|
91
105
|
/**
|