sensemaking 0.22.2 → 0.23.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/README.md +5 -7
- package/dist/cjs/chunk/extract.d.cts +3 -3
- package/dist/cjs/chunk/extract.d.ts +3 -3
- package/dist/cjs/chunk/extract.js +369 -72
- package/dist/cjs/chunk/extract.js.map +1 -1
- package/dist/cjs/chunk/group.js +2 -2
- package/dist/cjs/chunk/group.js.map +1 -1
- package/dist/cjs/chunk/parse.js +63 -67
- package/dist/cjs/chunk/parse.js.map +1 -1
- package/dist/cjs/chunk/parser.d.cts +2 -0
- package/dist/cjs/chunk/parser.d.ts +2 -0
- package/dist/cjs/chunk/parser.js +40 -0
- package/dist/cjs/chunk/parser.js.map +1 -0
- package/dist/cjs/chunk/types.d.cts +2 -2
- package/dist/cjs/chunk/types.d.ts +2 -2
- package/dist/cjs/chunk/version.d.cts +1 -1
- package/dist/cjs/chunk/version.d.ts +1 -1
- package/dist/cjs/chunk/version.js +1 -1
- package/dist/cjs/chunk/version.js.map +1 -1
- package/dist/cjs/features/sections.js +1 -1
- package/dist/cjs/features/sections.js.map +1 -1
- package/dist/cjs/scan/pool.js +1 -1
- package/dist/cjs/scan/pool.js.map +1 -1
- package/dist/cjs/store/duckdb/open.d.cts +1 -1
- package/dist/cjs/store/duckdb/open.d.ts +1 -1
- package/dist/cjs/store/duckdb/open.js +1 -1
- package/dist/cjs/store/duckdb/open.js.map +1 -1
- package/dist/cjs/store/sqlite/open.d.cts +1 -1
- package/dist/cjs/store/sqlite/open.d.ts +1 -1
- package/dist/cjs/store/sqlite/open.js +1 -1
- package/dist/cjs/store/sqlite/open.js.map +1 -1
- package/dist/cjs/store/turso/open.d.cts +1 -1
- package/dist/cjs/store/turso/open.d.ts +1 -1
- package/dist/cjs/store/turso/open.js +1 -1
- package/dist/cjs/store/turso/open.js.map +1 -1
- package/dist/cjs/text/strip.js +1 -3
- package/dist/cjs/text/strip.js.map +1 -1
- package/dist/cjs/workers/parse.js.map +1 -1
- package/dist/esm/chunk/extract.d.ts +3 -3
- package/dist/esm/chunk/extract.js +276 -63
- package/dist/esm/chunk/extract.js.map +1 -1
- package/dist/esm/chunk/group.js +2 -2
- package/dist/esm/chunk/group.js.map +1 -1
- package/dist/esm/chunk/parse.js +65 -64
- package/dist/esm/chunk/parse.js.map +1 -1
- package/dist/esm/chunk/parser.d.ts +2 -0
- package/dist/esm/chunk/parser.js +26 -0
- package/dist/esm/chunk/parser.js.map +1 -0
- package/dist/esm/chunk/types.d.ts +2 -2
- package/dist/esm/chunk/types.js.map +1 -1
- package/dist/esm/chunk/version.d.ts +1 -1
- package/dist/esm/chunk/version.js +1 -1
- package/dist/esm/chunk/version.js.map +1 -1
- package/dist/esm/features/sections.js +1 -1
- package/dist/esm/features/sections.js.map +1 -1
- package/dist/esm/scan/pool.js +1 -1
- package/dist/esm/scan/pool.js.map +1 -1
- package/dist/esm/store/duckdb/open.d.ts +1 -1
- package/dist/esm/store/duckdb/open.js +1 -1
- package/dist/esm/store/duckdb/open.js.map +1 -1
- package/dist/esm/store/sqlite/open.d.ts +1 -1
- package/dist/esm/store/sqlite/open.js +1 -1
- package/dist/esm/store/sqlite/open.js.map +1 -1
- package/dist/esm/store/turso/open.d.ts +1 -1
- package/dist/esm/store/turso/open.js +1 -1
- package/dist/esm/store/turso/open.js.map +1 -1
- package/dist/esm/text/strip.js +1 -1
- package/dist/esm/text/strip.js.map +1 -1
- package/dist/esm/workers/parse.js.map +1 -1
- package/package.json +5 -13
package/README.md
CHANGED
|
@@ -170,20 +170,18 @@ Dependencies, all pure JS. No native builds by default.
|
|
|
170
170
|
| | |
|
|
171
171
|
|---|---|
|
|
172
172
|
| [yaml](https://github.com/eemeli/yaml) | frontmatter |
|
|
173
|
-
| [
|
|
173
|
+
| [markdown-it](https://github.com/markdown-it/markdown-it) | markdown parsing |
|
|
174
174
|
| [@huggingface/tokenizers](https://github.com/huggingface/tokenizers.js) | chunking |
|
|
175
175
|
| [franc-min](https://github.com/wooorm/franc) | language detection |
|
|
176
176
|
| [tinypool](https://github.com/tinylibs/tinypool) | worker pool for parallel parsing on large trees |
|
|
177
177
|
| [install-module-linked](https://github.com/kmalakoff/install-module-linked) | installs the optional `duckdb` and `turso` bindings on first use, instead of shipping them to every install |
|
|
178
178
|
| Node's built-in SQLite | the default store |
|
|
179
179
|
|
|
180
|
-
Plus the
|
|
180
|
+
Plus two plugins for the GFM constructs the default preset lacks; tables, strikethrough, and
|
|
181
|
+
autolinks are built in:
|
|
181
182
|
|
|
182
|
-
- [
|
|
183
|
-
- [
|
|
184
|
-
- [micromark-extension-gfm-strikethrough](https://github.com/micromark/micromark-extension-gfm-strikethrough) / [mdast-util-gfm-strikethrough](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)
|
|
185
|
-
- [micromark-extension-gfm-table](https://github.com/micromark/micromark-extension-gfm-table) / [mdast-util-gfm-table](https://github.com/syntax-tree/mdast-util-gfm-table)
|
|
186
|
-
- [micromark-extension-gfm-task-list-item](https://github.com/micromark/micromark-extension-gfm-task-list-item) / [mdast-util-gfm-task-list-item](https://github.com/syntax-tree/mdast-util-gfm-task-list-item)
|
|
183
|
+
- [markdown-it-footnote](https://github.com/markdown-it/markdown-it-footnote)
|
|
184
|
+
- [markdown-it-task-lists](https://github.com/revin/markdown-it-task-lists)
|
|
187
185
|
|
|
188
186
|
## License
|
|
189
187
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function extractText(
|
|
3
|
-
export declare function extractTexts(
|
|
1
|
+
import type { Block } from './types.js';
|
|
2
|
+
export declare function extractText(block: Block): string;
|
|
3
|
+
export declare function extractTexts(blocks: Block[]): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function extractText(
|
|
3
|
-
export declare function extractTexts(
|
|
1
|
+
import type { Block } from './types.js';
|
|
2
|
+
export declare function extractText(block: Block): string;
|
|
3
|
+
export declare function extractTexts(blocks: Block[]): string;
|
|
@@ -16,8 +16,58 @@ _export(exports, {
|
|
|
16
16
|
return extractTexts;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
var _parserts = require("./parser.js");
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else obj[key] = value;
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
function _object_spread(target) {
|
|
32
|
+
for(var i = 1; i < arguments.length; i++){
|
|
33
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
34
|
+
var ownKeys = Object.keys(source);
|
|
35
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
36
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
37
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
ownKeys.forEach(function(key) {
|
|
41
|
+
_define_property(target, key, source[key]);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
function ownKeys(object, enumerableOnly) {
|
|
47
|
+
var keys = Object.keys(object);
|
|
48
|
+
if (Object.getOwnPropertySymbols) {
|
|
49
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
50
|
+
if (enumerableOnly) {
|
|
51
|
+
symbols = symbols.filter(function(sym) {
|
|
52
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
keys.push.apply(keys, symbols);
|
|
56
|
+
}
|
|
57
|
+
return keys;
|
|
58
|
+
}
|
|
59
|
+
function _object_spread_props(target, source) {
|
|
60
|
+
source = source != null ? source : {};
|
|
61
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
62
|
+
else {
|
|
63
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
64
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
// markdown-it, like mdast, has no wikilink, embed, or %%comment%% token -- literal text resolved
|
|
70
|
+
// by regex passes over non-code text (code/inline code is placeholder-held and spliced back verbatim).
|
|
21
71
|
var COMMENT_PAIR = /%%[\s\S]*?%%/g;
|
|
22
72
|
// An embed always yields its target, whatever follows a pipe (a resize suffix, never an alias);
|
|
23
73
|
// must run before the wikilink regex below, bang included, or that regex matches first.
|
|
@@ -29,7 +79,7 @@ var BLOCK_ID = / \^[A-Za-z0-9-]+$/gm;
|
|
|
29
79
|
// A callout marker is only ever the first thing in a blockquote's text (Obsidian's grammar),
|
|
30
80
|
// so this anchors to blockquote output alone -- never applied to prose in general.
|
|
31
81
|
var CALLOUT_MARKER = /^\[!\w[\w-]*\][+-]?[ \t]?/;
|
|
32
|
-
// An html
|
|
82
|
+
// An html token's content is raw HTML, block or inline: a full <!-- --> comment is dropped, any
|
|
33
83
|
// remaining tags are stripped, and the text a browser would still render survives.
|
|
34
84
|
var HTML_COMMENT = /<!--[\s\S]*?-->/g;
|
|
35
85
|
var HTML_TAG = /<[^>]+>/g;
|
|
@@ -60,92 +110,339 @@ function resolveFlavor(text) {
|
|
|
60
110
|
return wikilinkText(inner);
|
|
61
111
|
}).replace(BLOCK_ID, '');
|
|
62
112
|
}
|
|
63
|
-
// Sibling blocks (list items, blockquote content, footnote bodies) joined one per line;
|
|
64
|
-
// empties dropped so a blank child never widens the gap between its neighbors.
|
|
65
|
-
function joinBlocks(nodes, code) {
|
|
66
|
-
return nodes.map(function(n) {
|
|
67
|
-
return extractNode(n, code);
|
|
68
|
-
}).filter(function(s) {
|
|
69
|
-
return s.length > 0;
|
|
70
|
-
}).join('\n');
|
|
71
|
-
}
|
|
72
|
-
// Inline content (headings, paragraphs, emphasis, links) concatenated with no separator: the
|
|
73
|
-
// source text nodes already carry whatever spacing separates them.
|
|
74
|
-
function joinInline(nodes, code) {
|
|
75
|
-
return nodes.map(function(n) {
|
|
76
|
-
return extractNode(n, code);
|
|
77
|
-
}).join('');
|
|
78
|
-
}
|
|
79
113
|
// U+E000 (Private Use Area) never appears in real markdown text, so it is a collision-free
|
|
80
114
|
// placeholder delimiter, spliced back to the literal code value after flavor resolution.
|
|
81
115
|
function codePlaceholder(value, code) {
|
|
82
116
|
var idx = code.push(value) - 1;
|
|
83
117
|
return "".concat(idx, "");
|
|
84
118
|
}
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
// GFM's autolink literal ends where its path machine stops: a trail of punctuation is a genuine
|
|
120
|
+
// end (link stops before it) only when trailEndsAt accepts it, else the marks are part of the link.
|
|
121
|
+
var PUNCT = new Set([
|
|
122
|
+
'!',
|
|
123
|
+
'"',
|
|
124
|
+
'&',
|
|
125
|
+
"'",
|
|
126
|
+
')',
|
|
127
|
+
'*',
|
|
128
|
+
',',
|
|
129
|
+
'.',
|
|
130
|
+
';',
|
|
131
|
+
':',
|
|
132
|
+
'<',
|
|
133
|
+
'?',
|
|
134
|
+
'_',
|
|
135
|
+
'~',
|
|
136
|
+
']'
|
|
137
|
+
]);
|
|
138
|
+
var TRAIL_PUNCT = new Set([
|
|
139
|
+
'!',
|
|
140
|
+
'"',
|
|
141
|
+
"'",
|
|
142
|
+
')',
|
|
143
|
+
'*',
|
|
144
|
+
',',
|
|
145
|
+
'.',
|
|
146
|
+
';',
|
|
147
|
+
':',
|
|
148
|
+
'?',
|
|
149
|
+
'_',
|
|
150
|
+
'~'
|
|
151
|
+
]);
|
|
152
|
+
var isAlpha = function isAlpha(c) {
|
|
153
|
+
return c !== undefined && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
|
|
154
|
+
};
|
|
155
|
+
function trailEndsAt(s, j) {
|
|
156
|
+
for(;;){
|
|
157
|
+
var c = s[j];
|
|
158
|
+
if (c === undefined) return true;
|
|
159
|
+
if (TRAIL_PUNCT.has(c)) {
|
|
160
|
+
j += 1;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (c === '&') {
|
|
164
|
+
j += 1;
|
|
165
|
+
if (!isAlpha(s[j])) return false;
|
|
166
|
+
j += 1;
|
|
167
|
+
while(isAlpha(s[j]))j += 1;
|
|
168
|
+
if (s[j] !== ';') return false;
|
|
169
|
+
j += 1;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (c === ']') {
|
|
173
|
+
j += 1;
|
|
174
|
+
var d = s[j];
|
|
175
|
+
return d === undefined || d === '(' || d === '[' || RegExp("\\s", "u").test(d !== null && d !== void 0 ? d : ' ');
|
|
176
|
+
}
|
|
177
|
+
if (c === '<') return true;
|
|
178
|
+
if (c !== undefined && RegExp("^\\s$", "u").test(c)) return true;
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Where the GFM autolink ends in S (the linkifier's text plus the following text), old-style:
|
|
183
|
+
// punctuation that fails the trail test, or a ) with closes <= opens, extends the link.
|
|
184
|
+
function gfmAutolinkEnd(s) {
|
|
185
|
+
var open = 0;
|
|
186
|
+
var close = 0;
|
|
187
|
+
for(var i = 0; i < s.length; i++){
|
|
188
|
+
var c = s[i];
|
|
189
|
+
if (c === '(') {
|
|
190
|
+
open += 1;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (c === ')' && close < open) {
|
|
194
|
+
close += 1;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (PUNCT.has(c) && trailEndsAt(s, i)) return i;
|
|
198
|
+
if (c !== undefined && RegExp("^\\s$", "u").test(c)) return i;
|
|
199
|
+
}
|
|
200
|
+
return s.length;
|
|
201
|
+
}
|
|
202
|
+
// linkify-it links more than GFM's autolink literal (bare domains, ftp://, //host); only the
|
|
203
|
+
// GFM forms (http(s)://, www., email) drop their text.
|
|
204
|
+
function isGfmUrl(text) {
|
|
205
|
+
return /^https?:\/\//i.test(text) || /^www\./i.test(text);
|
|
206
|
+
}
|
|
207
|
+
// Only a bare address is GFM's email autolink: a url keeps its @, since a path can hold one.
|
|
208
|
+
function isGfmEmail(text) {
|
|
209
|
+
return !isGfmUrl(text) && text.includes('@');
|
|
210
|
+
}
|
|
211
|
+
// The task-lists plugin injects its checkbox as the item's first inline child.
|
|
212
|
+
function isTaskCheckbox(token) {
|
|
213
|
+
return (token === null || token === void 0 ? void 0 : token.type) === 'html_inline' && /^<input\b/i.test(token.content);
|
|
214
|
+
}
|
|
215
|
+
// A linkify span can swallow the & of a following entity (span ...c& + text amp; z); the
|
|
216
|
+
// re-emitted lead is then a reference the entity rule never saw, so decode it old-style.
|
|
217
|
+
var LEAD_ENTITY = /^&[a-z#][a-z0-9]{1,31};/i;
|
|
218
|
+
// Split a flat token range into its top-level blocks: nesting 1 opens, nesting 0 is one block.
|
|
219
|
+
function topLevelBlocks(tokens) {
|
|
220
|
+
var out = [];
|
|
221
|
+
var i = 0;
|
|
222
|
+
while(i < tokens.length){
|
|
223
|
+
var token = tokens[i];
|
|
224
|
+
if (token.nesting === 1) {
|
|
225
|
+
var depth = 1;
|
|
226
|
+
var j = i + 1;
|
|
227
|
+
while(j < tokens.length && depth > 0){
|
|
228
|
+
depth += tokens[j].nesting === 1 ? 1 : tokens[j].nesting === -1 ? -1 : 0;
|
|
229
|
+
j += 1;
|
|
230
|
+
}
|
|
231
|
+
out.push(tokens.slice(i, j));
|
|
232
|
+
i = j;
|
|
233
|
+
} else if (token.nesting === 0) {
|
|
234
|
+
out.push(tokens.slice(i, i + 1));
|
|
235
|
+
i += 1;
|
|
236
|
+
} else {
|
|
237
|
+
i += 1;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return out;
|
|
241
|
+
}
|
|
242
|
+
// A first line with no source content (a bare task checkbox, whitespace) contributes no line to
|
|
243
|
+
// the value, so its softbreak is dropped; a first line whose content extraction removes (an
|
|
244
|
+
// autolink, an image) still leaves its line ending behind.
|
|
245
|
+
function paragraphText(children, code) {
|
|
246
|
+
var _children_k;
|
|
247
|
+
var k = 0;
|
|
248
|
+
var first = children[0];
|
|
249
|
+
if (isTaskCheckbox(first)) k = 1;
|
|
250
|
+
while(k < children.length && children[k].type === 'text' && children[k].content.trim() === '')k += 1;
|
|
251
|
+
if (k > 0 && ((_children_k = children[k]) === null || _children_k === void 0 ? void 0 : _children_k.type) === 'softbreak') return inlineText(children.slice(k + 1), code);
|
|
252
|
+
return inlineText(children, code);
|
|
253
|
+
}
|
|
254
|
+
function blockText(tokens, code) {
|
|
255
|
+
var first = tokens[0];
|
|
256
|
+
if (!first) return '';
|
|
257
|
+
switch(first.type){
|
|
258
|
+
case 'heading_open':
|
|
259
|
+
case 'paragraph_open':
|
|
101
260
|
{
|
|
102
|
-
var
|
|
103
|
-
|
|
261
|
+
var _inline_children;
|
|
262
|
+
var inline = tokens.find(function(t) {
|
|
263
|
+
return t.type === 'inline';
|
|
264
|
+
});
|
|
265
|
+
return inline ? paragraphText((_inline_children = inline.children) !== null && _inline_children !== void 0 ? _inline_children : [], code) : '';
|
|
104
266
|
}
|
|
105
|
-
case '
|
|
106
|
-
case '
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
case '
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
case '
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
case '
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return joinInline(node.children, code);
|
|
122
|
-
case 'image':
|
|
123
|
-
case 'imageReference':
|
|
124
|
-
var _node_alt;
|
|
125
|
-
return (_node_alt = node.alt) !== null && _node_alt !== void 0 ? _node_alt : '';
|
|
126
|
-
case 'text':
|
|
127
|
-
return node.value;
|
|
128
|
-
case 'inlineCode':
|
|
129
|
-
case 'code':
|
|
130
|
-
return codePlaceholder(node.value, code);
|
|
131
|
-
case 'html':
|
|
132
|
-
return stripHtml(node.value);
|
|
133
|
-
case 'break':
|
|
134
|
-
return ' ';
|
|
267
|
+
case 'fence':
|
|
268
|
+
case 'code_block':
|
|
269
|
+
// Fence and indented code tokens carry the closing newline their lines were joined with.
|
|
270
|
+
return codePlaceholder(first.content.replace(/\n$/, ''), code);
|
|
271
|
+
case 'table_open':
|
|
272
|
+
return tableText(tokens, code);
|
|
273
|
+
case 'ordered_list_open':
|
|
274
|
+
case 'bullet_list_open':
|
|
275
|
+
return listItemsText(tokens, code);
|
|
276
|
+
case 'blockquote_open':
|
|
277
|
+
return blocksIn(tokens.slice(1, -1), code).replace(CALLOUT_MARKER, '');
|
|
278
|
+
case 'html_block':
|
|
279
|
+
// A non-final-line html block carries its last line's terminator, which the mdast value lacked.
|
|
280
|
+
return stripHtml(first.content.replace(/\n$/, ''));
|
|
281
|
+
case 'footnote_reference_open':
|
|
282
|
+
return blocksIn(tokens.slice(1, -1), code);
|
|
135
283
|
default:
|
|
136
284
|
return '';
|
|
137
285
|
}
|
|
138
286
|
}
|
|
287
|
+
// Sibling blocks (list items, blockquote children, footnote bodies) joined one per line;
|
|
288
|
+
// empties dropped so a blank child never widens the gap between its neighbors.
|
|
289
|
+
function blocksIn(tokens, code) {
|
|
290
|
+
return topLevelBlocks(tokens).map(function(b) {
|
|
291
|
+
return blockText(b, code);
|
|
292
|
+
}).filter(function(s) {
|
|
293
|
+
return s.length > 0;
|
|
294
|
+
}).join('\n');
|
|
295
|
+
}
|
|
296
|
+
// The task-lists plugin slices 3 of the marker's 4 chars, leaving its trailing space on the text
|
|
297
|
+
// after the checkbox token. Returns a copy with that space dropped, never a mutation: a block is
|
|
298
|
+
// extracted more than once (parse pre-extracts headings, group.ts extracts again).
|
|
299
|
+
function withoutTaskMarker(item) {
|
|
300
|
+
for(var i = 0; i < item.length; i++){
|
|
301
|
+
var _token_children;
|
|
302
|
+
var token = item[i];
|
|
303
|
+
// The checkbox, if any, sits in the item's first inline only.
|
|
304
|
+
if (token.type !== 'inline' || !((_token_children = token.children) === null || _token_children === void 0 ? void 0 : _token_children.length)) continue;
|
|
305
|
+
var second = token.children[1];
|
|
306
|
+
if (!isTaskCheckbox(token.children[0]) || (second === null || second === void 0 ? void 0 : second.type) !== 'text' || !second.content.startsWith(' ')) return item;
|
|
307
|
+
var children = token.children.slice();
|
|
308
|
+
children[1] = _object_spread_props(_object_spread({}, second), {
|
|
309
|
+
content: second.content.slice(1)
|
|
310
|
+
});
|
|
311
|
+
var copy = item.slice();
|
|
312
|
+
copy[i] = _object_spread_props(_object_spread({}, token), {
|
|
313
|
+
children: children
|
|
314
|
+
});
|
|
315
|
+
return copy;
|
|
316
|
+
}
|
|
317
|
+
return item;
|
|
318
|
+
}
|
|
319
|
+
function listItemsText(tokens, code) {
|
|
320
|
+
var items = [];
|
|
321
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
322
|
+
try {
|
|
323
|
+
for(var _iterator = topLevelBlocks(tokens.slice(1, -1))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
324
|
+
var item = _step.value;
|
|
325
|
+
items.push(blocksIn(withoutTaskMarker(item).slice(1, -1), code));
|
|
326
|
+
}
|
|
327
|
+
} catch (err) {
|
|
328
|
+
_didIteratorError = true;
|
|
329
|
+
_iteratorError = err;
|
|
330
|
+
} finally{
|
|
331
|
+
try {
|
|
332
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
333
|
+
_iterator.return();
|
|
334
|
+
}
|
|
335
|
+
} finally{
|
|
336
|
+
if (_didIteratorError) {
|
|
337
|
+
throw _iteratorError;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return items.filter(function(s) {
|
|
342
|
+
return s.length > 0;
|
|
343
|
+
}).join('\n');
|
|
344
|
+
}
|
|
345
|
+
// Table rows joined by newline, cells by space (mdast's tableRow/tableCell joiners).
|
|
346
|
+
function tableText(tokens, code) {
|
|
347
|
+
var rows = [];
|
|
348
|
+
var cells = [];
|
|
349
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
350
|
+
try {
|
|
351
|
+
for(var _iterator = tokens[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
352
|
+
var token = _step.value;
|
|
353
|
+
var _token_children;
|
|
354
|
+
if (token.type === 'tr_open') cells = [];
|
|
355
|
+
else if (token.type === 'inline') cells.push(inlineText((_token_children = token.children) !== null && _token_children !== void 0 ? _token_children : [], code));
|
|
356
|
+
else if (token.type === 'tr_close') rows.push(cells.join(' '));
|
|
357
|
+
}
|
|
358
|
+
} catch (err) {
|
|
359
|
+
_didIteratorError = true;
|
|
360
|
+
_iteratorError = err;
|
|
361
|
+
} finally{
|
|
362
|
+
try {
|
|
363
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
364
|
+
_iterator.return();
|
|
365
|
+
}
|
|
366
|
+
} finally{
|
|
367
|
+
if (_didIteratorError) {
|
|
368
|
+
throw _iteratorError;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return rows.join('\n');
|
|
373
|
+
}
|
|
374
|
+
// Inline content (headings, paragraphs, emphasis, links) concatenated with no separator: the
|
|
375
|
+
// source text tokens already carry whatever spacing separates them.
|
|
376
|
+
function inlineText(tokens, code) {
|
|
377
|
+
var inAlt = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
378
|
+
var out = '';
|
|
379
|
+
for(var i = 0; i < tokens.length; i++){
|
|
380
|
+
var token = tokens[i];
|
|
381
|
+
if (token.type === 'link_open') {
|
|
382
|
+
var skip = 0;
|
|
383
|
+
var j = i + 1;
|
|
384
|
+
var depth = 1;
|
|
385
|
+
while(j < tokens.length && depth > 0){
|
|
386
|
+
if (tokens[j].type === 'link_open') depth += 1;
|
|
387
|
+
else if (tokens[j].type === 'link_close') depth -= 1;
|
|
388
|
+
j += 1;
|
|
389
|
+
}
|
|
390
|
+
var text = inlineText(tokens.slice(i + 1, j - 1), code, inAlt);
|
|
391
|
+
var markup = token.markup;
|
|
392
|
+
var next = tokens[j];
|
|
393
|
+
if (inAlt) {
|
|
394
|
+
// An image's alt is plain text: mdast kept every link's own text there, autolinks included.
|
|
395
|
+
out += text;
|
|
396
|
+
} else if (markup === 'linkify' && isGfmUrl(text)) {
|
|
397
|
+
// GFM drop: the next text token resumes at the old link's boundary, re-emitting any
|
|
398
|
+
// trimmed trail. <www.x> has no trail to absorb (the brackets bound it), keep the >.
|
|
399
|
+
// Emails keep their whole remainder: GFM's email machine has no trail, so the span
|
|
400
|
+
// already ends at the old boundary and the entity rule has decoded the rest.
|
|
401
|
+
var prev = tokens[i - 1];
|
|
402
|
+
var bracketed = (prev === null || prev === void 0 ? void 0 : prev.type) === 'text' && prev.content.endsWith('<') && (next === null || next === void 0 ? void 0 : next.type) === 'text' && next.content.startsWith('>');
|
|
403
|
+
var tail = (next === null || next === void 0 ? void 0 : next.type) === 'text' ? text + next.content : text;
|
|
404
|
+
var k = bracketed ? text.length : gfmAutolinkEnd(tail);
|
|
405
|
+
out += tail.slice(k).replace(LEAD_ENTITY, function(m) {
|
|
406
|
+
return (0, _parserts.parser)().utils.unescapeAll(m);
|
|
407
|
+
});
|
|
408
|
+
// The trail came out of the next text token, so that token is consumed here, not re-read.
|
|
409
|
+
if ((next === null || next === void 0 ? void 0 : next.type) === 'text') skip = 1;
|
|
410
|
+
} else if (markup === 'linkify' && isGfmEmail(text)) {
|
|
411
|
+
// Email drop: nothing after the span to trim, so the span alone is dropped.
|
|
412
|
+
} else if (markup === 'autolink') {
|
|
413
|
+
// <...> leaf: dropped whole, its brackets live inside the token so nothing follows to trim.
|
|
414
|
+
} else {
|
|
415
|
+
out += text; // user link or non-GFM linkify target: keep the display text
|
|
416
|
+
}
|
|
417
|
+
i = j - 1 + skip;
|
|
418
|
+
} else if (token.type === 'text') {
|
|
419
|
+
out += token.content;
|
|
420
|
+
} else if (token.type === 'softbreak') {
|
|
421
|
+
out += '\n';
|
|
422
|
+
} else if (token.type === 'hardbreak') {
|
|
423
|
+
out += ' ';
|
|
424
|
+
} else if (token.type === 'code_inline') {
|
|
425
|
+
out += codePlaceholder(token.content, code);
|
|
426
|
+
} else if (token.type === 'html_inline') {
|
|
427
|
+
out += stripHtml(token.content);
|
|
428
|
+
} else if (token.type === 'image') {
|
|
429
|
+
var _token_children;
|
|
430
|
+
out += inlineText((_token_children = token.children) !== null && _token_children !== void 0 ? _token_children : [], code, true);
|
|
431
|
+
}
|
|
432
|
+
// Emphasis, strikethrough and footnote markers carry no text of their own.
|
|
433
|
+
}
|
|
434
|
+
return out;
|
|
435
|
+
}
|
|
139
436
|
var CODE_PLACEHOLDER = /\uE000(\d+)\uE000/g;
|
|
140
|
-
function extractText(
|
|
437
|
+
function extractText(block) {
|
|
141
438
|
return extractTexts([
|
|
142
|
-
|
|
439
|
+
block
|
|
143
440
|
]);
|
|
144
441
|
}
|
|
145
|
-
function extractTexts(
|
|
442
|
+
function extractTexts(blocks) {
|
|
146
443
|
var code = [];
|
|
147
|
-
var joined =
|
|
148
|
-
return
|
|
444
|
+
var joined = blocks.map(function(b) {
|
|
445
|
+
return blockText(b.node, code);
|
|
149
446
|
}).filter(function(s) {
|
|
150
447
|
return s.length > 0;
|
|
151
448
|
}).join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/chunk/extract.ts"],"sourcesContent":["import type { Nodes } from 'mdast';\n\n// mdast has no wikilink, embed, or %%comment%% node -- literal text resolved by regex passes\n// over non-code text (code/inlineCode is placeholder-held and spliced back verbatim, below).\nconst COMMENT_PAIR = /%%[\\s\\S]*?%%/g;\n// An embed always yields its target, whatever follows a pipe (a resize suffix, never an alias);\n// must run before the wikilink regex below, bang included, or that regex matches first.\nconst EMBED = /!\\[\\[([^\\]]+)\\]\\]/g;\nconst WIKILINK = /\\[\\[([^\\]]+)\\]\\]/g;\n// A trailing \" ^id\" is an Obsidian block anchor, valid only at a line's end; a caret elsewhere\n// (mid-line) is ordinary text and is left alone.\nconst BLOCK_ID = / \\^[A-Za-z0-9-]+$/gm;\n// A callout marker is only ever the first thing in a blockquote's text (Obsidian's grammar),\n// so this anchors to blockquote output alone -- never applied to prose in general.\nconst CALLOUT_MARKER = /^\\[!\\w[\\w-]*\\][+-]?[ \\t]?/;\n// An html node's value is raw HTML, block or inline: a full <!-- --> comment is dropped, any\n// remaining tags are stripped, and the text a browser would still render survives.\nconst HTML_COMMENT = /<!--[\\s\\S]*?-->/g;\nconst HTML_TAG = /<[^>]+>/g;\n\nfunction stripHtml(value: string): string {\n return value.replace(HTML_COMMENT, '').replace(HTML_TAG, '');\n}\n\n// A `#anchor` keeps its text (hash dropped), unlike links.ts's parseWikilinkInner (the resolver\n// authority), which discards it entirely -- replicated here since that return value doesn't fit.\nfunction anchorText(base: string): string {\n const hashIdx = base.indexOf('#');\n if (hashIdx === -1) return base.trim();\n const target = base.slice(0, hashIdx).trim();\n const anchor = base.slice(hashIdx + 1).trim();\n return target ? `${target} ${anchor}` : anchor;\n}\n\nfunction wikilinkText(inner: string): string {\n const pipeIdx = inner.indexOf('|');\n return pipeIdx === -1 ? anchorText(inner) : inner.slice(pipeIdx + 1).trim();\n}\n\nfunction embedText(inner: string): string {\n const pipeIdx = inner.indexOf('|');\n return anchorText(pipeIdx === -1 ? inner : inner.slice(0, pipeIdx));\n}\n\nfunction resolveFlavor(text: string): string {\n return text\n .replace(HTML_COMMENT, '')\n .replace(COMMENT_PAIR, '')\n .replace(EMBED, (_, inner: string) => embedText(inner))\n .replace(WIKILINK, (_, inner: string) => wikilinkText(inner))\n .replace(BLOCK_ID, '');\n}\n\n// Sibling blocks (list items, blockquote content, footnote bodies) joined one per line;\n// empties dropped so a blank child never widens the gap between its neighbors.\nfunction joinBlocks(nodes: Nodes[], code: string[]): string {\n return nodes\n .map((n) => extractNode(n, code))\n .filter((s) => s.length > 0)\n .join('\\n');\n}\n\n// Inline content (headings, paragraphs, emphasis, links) concatenated with no separator: the\n// source text nodes already carry whatever spacing separates them.\nfunction joinInline(nodes: Nodes[], code: string[]): string {\n return nodes.map((n) => extractNode(n, code)).join('');\n}\n\n// U+E000 (Private Use Area) never appears in real markdown text, so it is a collision-free\n// placeholder delimiter, spliced back to the literal code value after flavor resolution.\nfunction codePlaceholder(value: string, code: string[]): string {\n const idx = code.push(value) - 1;\n return `\\uE000${idx}\\uE000`;\n}\n\n// A GFM autolink's display text is its own target, missing only the scheme\n// mdast-util-gfm-autolink-literal fills into node.url (http:// for www., mailto: for an email).\nconst SCHEME_PREFIX = /^[a-z][a-z0-9+.-]*:\\/{0,2}/i;\nfunction isAutolink(url: string, text: string): boolean {\n return url === text || url.replace(SCHEME_PREFIX, '') === text;\n}\n\nfunction extractNode(node: Nodes, code: string[]): string {\n switch (node.type) {\n case 'root':\n case 'list':\n case 'listItem':\n case 'footnoteDefinition':\n return joinBlocks(node.children, code);\n case 'blockquote':\n return joinBlocks(node.children, code).replace(CALLOUT_MARKER, '');\n case 'link': {\n const text = joinInline(node.children, code);\n return isAutolink(node.url, text) ? '' : text;\n }\n case 'heading':\n case 'paragraph':\n case 'linkReference':\n case 'emphasis':\n case 'strong':\n case 'delete':\n return joinInline(node.children, code);\n case 'table':\n return node.children.map((n) => extractNode(n, code)).join('\\n');\n case 'tableRow':\n return node.children.map((n) => extractNode(n, code)).join(' ');\n case 'tableCell':\n return joinInline(node.children, code);\n case 'image':\n case 'imageReference':\n return node.alt ?? '';\n case 'text':\n return node.value;\n case 'inlineCode':\n case 'code':\n return codePlaceholder(node.value, code);\n case 'html':\n return stripHtml(node.value);\n case 'break':\n return ' ';\n default:\n return '';\n }\n}\n\nconst CODE_PLACEHOLDER = /\\uE000(\\d+)\\uE000/g;\n\n// Plain text of one mdast node (or a whole tree): heading/list/table structure is kept as text,\n// markup (emphasis, link targets, task and callout markers) is dropped. Pure, synchronous.\nexport function extractText(node: Nodes): string {\n return extractTexts([node]);\n}\n\n// Blocks resolved together: a blank line inside %%...%% splits it across blocks, and a per-block\n// strip then never sees the closing %%. Code stays placeholder-held across all of them.\nexport function extractTexts(nodes: Nodes[]): string {\n const code: string[] = [];\n const joined = nodes\n .map((n) => extractNode(n, code))\n .filter((s) => s.length > 0)\n .join('\\n');\n const resolved = resolveFlavor(joined);\n return code.length === 0 ? resolved : resolved.replace(CODE_PLACEHOLDER, (_, i: string) => code[Number(i)]);\n}\n"],"names":["extractText","extractTexts","COMMENT_PAIR","EMBED","WIKILINK","BLOCK_ID","CALLOUT_MARKER","HTML_COMMENT","HTML_TAG","stripHtml","value","replace","anchorText","base","hashIdx","indexOf","trim","target","slice","anchor","wikilinkText","inner","pipeIdx","embedText","resolveFlavor","text","_","joinBlocks","nodes","code","map","n","extractNode","filter","s","length","join","joinInline","codePlaceholder","idx","push","SCHEME_PREFIX","isAutolink","url","node","type","children","alt","CODE_PLACEHOLDER","joined","resolved","i","Number"],"mappings":";;;;;;;;;;;QAiIgBA;eAAAA;;QAMAC;eAAAA;;;AArIhB,6FAA6F;AAC7F,6FAA6F;AAC7F,IAAMC,eAAe;AACrB,gGAAgG;AAChG,wFAAwF;AACxF,IAAMC,QAAQ;AACd,IAAMC,WAAW;AACjB,+FAA+F;AAC/F,iDAAiD;AACjD,IAAMC,WAAW;AACjB,6FAA6F;AAC7F,mFAAmF;AACnF,IAAMC,iBAAiB;AACvB,6FAA6F;AAC7F,mFAAmF;AACnF,IAAMC,eA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;gBACIe;YAAP,QAAOA,YAAAA,KAAKG,GAAG,cAARH,uBAAAA,YAAY;QACrB,KAAK;YACH,OAAOA,KAAKlC,KAAK;QACnB,KAAK;QACL,KAAK;YACH,OAAO4B,gBAAgBM,KAAKlC,KAAK,EAAEmB;QACrC,KAAK;YACH,OAAOpB,UAAUmC,KAAKlC,KAAK;QAC7B,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF;AAEA,IAAMsC,mBAAmB;AAIlB,SAAShD,YAAY4C,IAAW;IACrC,OAAO3C,aAAa;QAAC2C;KAAK;AAC5B;AAIO,SAAS3C,aAAa2B,KAAc;IACzC,IAAMC,OAAiB,EAAE;IACzB,IAAMoB,SAASrB,MACZE,GAAG,CAAC,SAACC;eAAMC,YAAYD,GAAGF;OAC1BI,MAAM,CAAC,SAACC;eAAMA,EAAEC,MAAM,GAAG;OACzBC,IAAI,CAAC;IACR,IAAMc,WAAW1B,cAAcyB;IAC/B,OAAOpB,KAAKM,MAAM,KAAK,IAAIe,WAAWA,SAASvC,OAAO,CAACqC,kBAAkB,SAACtB,GAAGyB;eAActB,IAAI,CAACuB,OAAOD,GAAG;;AAC5G"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/chunk/extract.ts"],"sourcesContent":["import type { Token } from 'markdown-it';\nimport { parser } from './parser.ts';\nimport type { Block } from './types.ts';\n\n// markdown-it, like mdast, has no wikilink, embed, or %%comment%% token -- literal text resolved\n// by regex passes over non-code text (code/inline code is placeholder-held and spliced back verbatim).\nconst COMMENT_PAIR = /%%[\\s\\S]*?%%/g;\n// An embed always yields its target, whatever follows a pipe (a resize suffix, never an alias);\n// must run before the wikilink regex below, bang included, or that regex matches first.\nconst EMBED = /!\\[\\[([^\\]]+)\\]\\]/g;\nconst WIKILINK = /\\[\\[([^\\]]+)\\]\\]/g;\n// A trailing \" ^id\" is an Obsidian block anchor, valid only at a line's end; a caret elsewhere\n// (mid-line) is ordinary text and is left alone.\nconst BLOCK_ID = / \\^[A-Za-z0-9-]+$/gm;\n// A callout marker is only ever the first thing in a blockquote's text (Obsidian's grammar),\n// so this anchors to blockquote output alone -- never applied to prose in general.\nconst CALLOUT_MARKER = /^\\[!\\w[\\w-]*\\][+-]?[ \\t]?/;\n// An html token's content is raw HTML, block or inline: a full <!-- --> comment is dropped, any\n// remaining tags are stripped, and the text a browser would still render survives.\nconst HTML_COMMENT = /<!--[\\s\\S]*?-->/g;\nconst HTML_TAG = /<[^>]+>/g;\n\nfunction stripHtml(value: string): string {\n return value.replace(HTML_COMMENT, '').replace(HTML_TAG, '');\n}\n\n// A `#anchor` keeps its text (hash dropped), unlike links.ts's parseWikilinkInner (the resolver\n// authority), which discards it entirely -- replicated here since that return value doesn't fit.\nfunction anchorText(base: string): string {\n const hashIdx = base.indexOf('#');\n if (hashIdx === -1) return base.trim();\n const target = base.slice(0, hashIdx).trim();\n const anchor = base.slice(hashIdx + 1).trim();\n return target ? `${target} ${anchor}` : anchor;\n}\n\nfunction wikilinkText(inner: string): string {\n const pipeIdx = inner.indexOf('|');\n return pipeIdx === -1 ? anchorText(inner) : inner.slice(pipeIdx + 1).trim();\n}\n\nfunction embedText(inner: string): string {\n const pipeIdx = inner.indexOf('|');\n return anchorText(pipeIdx === -1 ? inner : inner.slice(0, pipeIdx));\n}\n\nfunction resolveFlavor(text: string): string {\n return text\n .replace(HTML_COMMENT, '')\n .replace(COMMENT_PAIR, '')\n .replace(EMBED, (_, inner: string) => embedText(inner))\n .replace(WIKILINK, (_, inner: string) => wikilinkText(inner))\n .replace(BLOCK_ID, '');\n}\n\n// U+E000 (Private Use Area) never appears in real markdown text, so it is a collision-free\n// placeholder delimiter, spliced back to the literal code value after flavor resolution.\nfunction codePlaceholder(value: string, code: string[]): string {\n const idx = code.push(value) - 1;\n return `\\uE000${idx}\\uE000`;\n}\n\n// GFM's autolink literal ends where its path machine stops: a trail of punctuation is a genuine\n// end (link stops before it) only when trailEndsAt accepts it, else the marks are part of the link.\nconst PUNCT = new Set(['!', '\"', '&', \"'\", ')', '*', ',', '.', ';', ':', '<', '?', '_', '~', ']']);\nconst TRAIL_PUNCT = new Set(['!', '\"', \"'\", ')', '*', ',', '.', ';', ':', '?', '_', '~']);\nconst isAlpha = (c: string | undefined): boolean => c !== undefined && ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));\nfunction trailEndsAt(s: string, j: number): boolean {\n for (;;) {\n const c = s[j];\n if (c === undefined) return true;\n if (TRAIL_PUNCT.has(c)) {\n j += 1;\n continue;\n }\n if (c === '&') {\n j += 1;\n if (!isAlpha(s[j])) return false;\n j += 1;\n while (isAlpha(s[j])) j += 1;\n if (s[j] !== ';') return false;\n j += 1;\n continue;\n }\n if (c === ']') {\n j += 1;\n const d = s[j];\n return d === undefined || d === '(' || d === '[' || /\\s/u.test(d ?? ' ');\n }\n if (c === '<') return true;\n if (c !== undefined && /^\\s$/u.test(c)) return true;\n return false;\n }\n}\n// Where the GFM autolink ends in S (the linkifier's text plus the following text), old-style:\n// punctuation that fails the trail test, or a ) with closes <= opens, extends the link.\nfunction gfmAutolinkEnd(s: string): number {\n let open = 0;\n let close = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s[i];\n if (c === '(') {\n open += 1;\n continue;\n }\n if (c === ')' && close < open) {\n close += 1;\n continue;\n }\n if (PUNCT.has(c) && trailEndsAt(s, i)) return i;\n if (c !== undefined && /^\\s$/u.test(c)) return i;\n }\n return s.length;\n}\n// linkify-it links more than GFM's autolink literal (bare domains, ftp://, //host); only the\n// GFM forms (http(s)://, www., email) drop their text.\nfunction isGfmUrl(text: string): boolean {\n return /^https?:\\/\\//i.test(text) || /^www\\./i.test(text);\n}\n// Only a bare address is GFM's email autolink: a url keeps its @, since a path can hold one.\nfunction isGfmEmail(text: string): boolean {\n return !isGfmUrl(text) && text.includes('@');\n}\n// The task-lists plugin injects its checkbox as the item's first inline child.\nfunction isTaskCheckbox(token: Token | undefined): boolean {\n return token?.type === 'html_inline' && /^<input\\b/i.test(token.content);\n}\n// A linkify span can swallow the & of a following entity (span ...c& + text amp; z); the\n// re-emitted lead is then a reference the entity rule never saw, so decode it old-style.\nconst LEAD_ENTITY = /^&[a-z#][a-z0-9]{1,31};/i;\n\n// Split a flat token range into its top-level blocks: nesting 1 opens, nesting 0 is one block.\nfunction topLevelBlocks(tokens: Token[]): Token[][] {\n const out: Token[][] = [];\n let i = 0;\n while (i < tokens.length) {\n const token = tokens[i];\n if (token.nesting === 1) {\n let depth = 1;\n let j = i + 1;\n while (j < tokens.length && depth > 0) {\n depth += tokens[j].nesting === 1 ? 1 : tokens[j].nesting === -1 ? -1 : 0;\n j += 1;\n }\n out.push(tokens.slice(i, j));\n i = j;\n } else if (token.nesting === 0) {\n out.push(tokens.slice(i, i + 1));\n i += 1;\n } else {\n i += 1;\n }\n }\n return out;\n}\n\n// A first line with no source content (a bare task checkbox, whitespace) contributes no line to\n// the value, so its softbreak is dropped; a first line whose content extraction removes (an\n// autolink, an image) still leaves its line ending behind.\nfunction paragraphText(children: Token[], code: string[]): string {\n let k = 0;\n const first = children[0];\n if (isTaskCheckbox(first)) k = 1;\n while (k < children.length && children[k].type === 'text' && children[k].content.trim() === '') k += 1;\n if (k > 0 && children[k]?.type === 'softbreak') return inlineText(children.slice(k + 1), code);\n return inlineText(children, code);\n}\n\nfunction blockText(tokens: Token[], code: string[]): string {\n const first = tokens[0];\n if (!first) return '';\n switch (first.type) {\n case 'heading_open':\n case 'paragraph_open': {\n const inline = tokens.find((t) => t.type === 'inline');\n return inline ? paragraphText(inline.children ?? [], code) : '';\n }\n case 'fence':\n case 'code_block':\n // Fence and indented code tokens carry the closing newline their lines were joined with.\n return codePlaceholder(first.content.replace(/\\n$/, ''), code);\n case 'table_open':\n return tableText(tokens, code);\n case 'ordered_list_open':\n case 'bullet_list_open':\n return listItemsText(tokens, code);\n case 'blockquote_open':\n return blocksIn(tokens.slice(1, -1), code).replace(CALLOUT_MARKER, '');\n case 'html_block':\n // A non-final-line html block carries its last line's terminator, which the mdast value lacked.\n return stripHtml(first.content.replace(/\\n$/, ''));\n case 'footnote_reference_open':\n return blocksIn(tokens.slice(1, -1), code);\n default:\n return '';\n }\n}\n\n// Sibling blocks (list items, blockquote children, footnote bodies) joined one per line;\n// empties dropped so a blank child never widens the gap between its neighbors.\nfunction blocksIn(tokens: Token[], code: string[]): string {\n return topLevelBlocks(tokens)\n .map((b) => blockText(b, code))\n .filter((s) => s.length > 0)\n .join('\\n');\n}\n\n// The task-lists plugin slices 3 of the marker's 4 chars, leaving its trailing space on the text\n// after the checkbox token. Returns a copy with that space dropped, never a mutation: a block is\n// extracted more than once (parse pre-extracts headings, group.ts extracts again).\nfunction withoutTaskMarker(item: Token[]): Token[] {\n for (let i = 0; i < item.length; i++) {\n const token = item[i];\n // The checkbox, if any, sits in the item's first inline only.\n if (token.type !== 'inline' || !token.children?.length) continue;\n const second = token.children[1];\n if (!isTaskCheckbox(token.children[0]) || second?.type !== 'text' || !second.content.startsWith(' ')) return item;\n const children = token.children.slice();\n children[1] = { ...second, content: second.content.slice(1) } as Token;\n const copy = item.slice();\n copy[i] = { ...token, children } as Token;\n return copy;\n }\n return item;\n}\n\nfunction listItemsText(tokens: Token[], code: string[]): string {\n const items: string[] = [];\n for (const item of topLevelBlocks(tokens.slice(1, -1))) {\n items.push(blocksIn(withoutTaskMarker(item).slice(1, -1), code));\n }\n return items.filter((s) => s.length > 0).join('\\n');\n}\n\n// Table rows joined by newline, cells by space (mdast's tableRow/tableCell joiners).\nfunction tableText(tokens: Token[], code: string[]): string {\n const rows: string[] = [];\n let cells: string[] = [];\n for (const token of tokens) {\n if (token.type === 'tr_open') cells = [];\n else if (token.type === 'inline') cells.push(inlineText(token.children ?? [], code));\n else if (token.type === 'tr_close') rows.push(cells.join(' '));\n }\n return rows.join('\\n');\n}\n\n// Inline content (headings, paragraphs, emphasis, links) concatenated with no separator: the\n// source text tokens already carry whatever spacing separates them.\nfunction inlineText(tokens: Token[], code: string[], inAlt = false): string {\n let out = '';\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token.type === 'link_open') {\n let skip = 0;\n let j = i + 1;\n let depth = 1;\n while (j < tokens.length && depth > 0) {\n if (tokens[j].type === 'link_open') depth += 1;\n else if (tokens[j].type === 'link_close') depth -= 1;\n j += 1;\n }\n const text = inlineText(tokens.slice(i + 1, j - 1), code, inAlt);\n const markup = token.markup;\n const next = tokens[j];\n if (inAlt) {\n // An image's alt is plain text: mdast kept every link's own text there, autolinks included.\n out += text;\n } else if (markup === 'linkify' && isGfmUrl(text)) {\n // GFM drop: the next text token resumes at the old link's boundary, re-emitting any\n // trimmed trail. <www.x> has no trail to absorb (the brackets bound it), keep the >.\n // Emails keep their whole remainder: GFM's email machine has no trail, so the span\n // already ends at the old boundary and the entity rule has decoded the rest.\n const prev = tokens[i - 1];\n const bracketed = prev?.type === 'text' && prev.content.endsWith('<') && next?.type === 'text' && next.content.startsWith('>');\n const tail = next?.type === 'text' ? text + next.content : text;\n const k = bracketed ? text.length : gfmAutolinkEnd(tail);\n out += tail.slice(k).replace(LEAD_ENTITY, (m) => parser().utils.unescapeAll(m));\n // The trail came out of the next text token, so that token is consumed here, not re-read.\n if (next?.type === 'text') skip = 1;\n } else if (markup === 'linkify' && isGfmEmail(text)) {\n // Email drop: nothing after the span to trim, so the span alone is dropped.\n } else if (markup === 'autolink') {\n // <...> leaf: dropped whole, its brackets live inside the token so nothing follows to trim.\n } else {\n out += text; // user link or non-GFM linkify target: keep the display text\n }\n i = j - 1 + skip;\n } else if (token.type === 'text') {\n out += token.content;\n } else if (token.type === 'softbreak') {\n out += '\\n';\n } else if (token.type === 'hardbreak') {\n out += ' ';\n } else if (token.type === 'code_inline') {\n out += codePlaceholder(token.content, code);\n } else if (token.type === 'html_inline') {\n out += stripHtml(token.content);\n } else if (token.type === 'image') {\n out += inlineText(token.children ?? [], code, true);\n }\n // Emphasis, strikethrough and footnote markers carry no text of their own.\n }\n return out;\n}\n\nconst CODE_PLACEHOLDER = /\\uE000(\\d+)\\uE000/g;\n\n// Plain text of one parsed block: heading/list/table structure is kept as text, markup (emphasis,\n// link targets, task and callout markers) is dropped. Pure, synchronous.\nexport function extractText(block: Block): string {\n return extractTexts([block]);\n}\n\n// Blocks resolved together: a blank line inside %%...%% splits it across blocks, and a per-block\n// strip then never sees the closing %%. Code stays placeholder-held across all of them.\nexport function extractTexts(blocks: Block[]): string {\n const code: string[] = [];\n const joined = blocks\n .map((b) => blockText(b.node, code))\n .filter((s) => s.length > 0)\n .join('\\n');\n const resolved = resolveFlavor(joined);\n return code.length === 0 ? resolved : resolved.replace(CODE_PLACEHOLDER, (_, i: string) => code[Number(i)]);\n}\n"],"names":["extractText","extractTexts","COMMENT_PAIR","EMBED","WIKILINK","BLOCK_ID","CALLOUT_MARKER","HTML_COMMENT","HTML_TAG","stripHtml","value","replace","anchorText","base","hashIdx","indexOf","trim","target","slice","anchor","wikilinkText","inner","pipeIdx","embedText","resolveFlavor","text","_","codePlaceholder","code","idx","push","PUNCT","Set","TRAIL_PUNCT","isAlpha","c","undefined","trailEndsAt","s","j","has","d","test","gfmAutolinkEnd","open","close","i","length","isGfmUrl","isGfmEmail","includes","isTaskCheckbox","token","type","content","LEAD_ENTITY","topLevelBlocks","tokens","out","nesting","depth","paragraphText","children","k","first","inlineText","blockText","inline","find","t","tableText","listItemsText","blocksIn","map","b","filter","join","withoutTaskMarker","item","second","startsWith","copy","items","rows","cells","inAlt","skip","markup","next","prev","bracketed","endsWith","tail","m","parser","utils","unescapeAll","CODE_PLACEHOLDER","block","blocks","joined","node","resolved","Number"],"mappings":";;;;;;;;;;;QAqTgBA;eAAAA;;QAMAC;eAAAA;;;wBA1TO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvB,iGAAiG;AACjG,uGAAuG;AACvG,IAAMC,eAAe;AACrB,gGAAgG;AAChG,wFAAwF;AACxF,IAAMC,QAAQ;AACd,IAAMC,WAAW;AACjB,+FA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C;eAAMR,UAAUQ,EAAE2B,IAAI,EAAEzE;OAC7B+C,MAAM,CAAC,SAACrC;eAAMA,EAAES,MAAM,GAAG;OACzB6B,IAAI,CAAC;IACR,IAAM0B,WAAW9E,cAAc4E;IAC/B,OAAOxE,KAAKmB,MAAM,KAAK,IAAIuD,WAAWA,SAAS3F,OAAO,CAACsF,kBAAkB,SAACvE,GAAGoB;eAAclB,IAAI,CAAC2E,OAAOzD,GAAG;;AAC5G"}
|
package/dist/cjs/chunk/group.js
CHANGED
|
@@ -250,7 +250,7 @@ var ATOMIC_TYPES = new Set([
|
|
|
250
250
|
// without their header/delimiter rows would demote them to paragraph text.
|
|
251
251
|
function piece(pieceLines, startLine, endLine, blockType, textMode) {
|
|
252
252
|
var text = ATOMIC_TYPES.has(blockType) || textMode === 'raw' ? pieceLines.join('\n') : (0, _parsets.parse)(pieceLines.join('\n')).map(function(b) {
|
|
253
|
-
return (0, _extractts.extractText)(b
|
|
253
|
+
return (0, _extractts.extractText)(b);
|
|
254
254
|
}).join('\n');
|
|
255
255
|
return {
|
|
256
256
|
startLine: startLine,
|
|
@@ -362,7 +362,7 @@ function groupScope(scopeBlocks, lines, resolved) {
|
|
|
362
362
|
}
|
|
363
363
|
continue;
|
|
364
364
|
}
|
|
365
|
-
var extracted = (0, _extractts.extractText)(block
|
|
365
|
+
var extracted = (0, _extractts.extractText)(block);
|
|
366
366
|
var sizeText = resolved.text === 'raw' ? raw : extracted;
|
|
367
367
|
if (block.type === 'heading') {
|
|
368
368
|
addPart(extracted, sizeText, block.startLine, block.endLine);
|