lens-content-processor 0.4.0 → 0.5.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/dist/bundler/video.d.ts +12 -6
- package/dist/bundler/video.js +57 -34
- package/dist/bundler/video.js.map +1 -1
- package/dist/cli.d.ts +11 -2
- package/dist/cli.js +36 -19
- package/dist/cli.js.map +1 -1
- package/dist/content-schema.js +64 -16
- package/dist/content-schema.js.map +1 -1
- package/dist/dedupe-errors.d.ts +14 -0
- package/dist/dedupe-errors.js +33 -0
- package/dist/dedupe-errors.js.map +1 -0
- package/dist/flattener/index.d.ts +3 -28
- package/dist/flattener/index.js +497 -741
- package/dist/flattener/index.js.map +1 -1
- package/dist/flattener/resolve-text-links.d.ts +25 -0
- package/dist/flattener/resolve-text-links.js +248 -0
- package/dist/flattener/resolve-text-links.js.map +1 -0
- package/dist/flattener/test-helpers.d.ts +1 -1
- package/dist/flattener/test-helpers.js +1 -3
- package/dist/flattener/test-helpers.js.map +1 -1
- package/dist/index.d.ts +51 -21
- package/dist/index.js +285 -140
- package/dist/index.js.map +1 -1
- package/dist/parser/article.d.ts +2 -1
- package/dist/parser/article.js +75 -14
- package/dist/parser/article.js.map +1 -1
- package/dist/parser/course.d.ts +1 -1
- package/dist/parser/course.js +79 -22
- package/dist/parser/course.js.map +1 -1
- package/dist/parser/frontmatter.d.ts +1 -1
- package/dist/parser/frontmatter.js +38 -12
- package/dist/parser/frontmatter.js.map +1 -1
- package/dist/parser/learning-outcome.d.ts +5 -2
- package/dist/parser/learning-outcome.js +75 -37
- package/dist/parser/learning-outcome.js.map +1 -1
- package/dist/parser/lens.d.ts +33 -34
- package/dist/parser/lens.js +205 -271
- package/dist/parser/lens.js.map +1 -1
- package/dist/parser/module.d.ts +7 -15
- package/dist/parser/module.js +135 -171
- package/dist/parser/module.js.map +1 -1
- package/dist/parser/sections.d.ts +12 -1
- package/dist/parser/sections.js +74 -95
- package/dist/parser/sections.js.map +1 -1
- package/dist/parser/video-transcript.d.ts +2 -1
- package/dist/parser/video-transcript.js +8 -7
- package/dist/parser/video-transcript.js.map +1 -1
- package/dist/reference-graph.d.ts +8 -0
- package/dist/reference-graph.js +105 -0
- package/dist/reference-graph.js.map +1 -0
- package/dist/validator/card-module-membership.d.ts +2 -0
- package/dist/validator/card-module-membership.js +80 -0
- package/dist/validator/card-module-membership.js.map +1 -0
- package/dist/validator/output-integrity.js +5 -5
- package/dist/validator/output-integrity.js.map +1 -1
- package/dist/validator/segment-fields.d.ts +1 -1
- package/dist/validator/segment-fields.js +2 -2
- package/dist/validator/segment-fields.js.map +1 -1
- package/dist/validator/test-segments.d.ts +12 -0
- package/dist/validator/test-segments.js +40 -0
- package/dist/validator/test-segments.js.map +1 -0
- package/dist/validator/url-reachability.d.ts +2 -1
- package/dist/validator/url-reachability.js +40 -20
- package/dist/validator/url-reachability.js.map +1 -1
- package/package.json +1 -1
- package/dist/validator/chat-precedence.d.ts +0 -9
- package/dist/validator/chat-precedence.js +0 -32
- package/dist/validator/chat-precedence.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { parseFrontmatter } from
|
|
2
|
-
import { parseSections, LO_SECTION_TYPES } from
|
|
3
|
-
import { parseWikilink, resolveWikilinkPath, hasRelativePath } from
|
|
4
|
-
import { detectFieldTypos } from
|
|
5
|
-
import { validateFrontmatter } from
|
|
6
|
-
import {
|
|
1
|
+
import { parseFrontmatter } from "./frontmatter.js";
|
|
2
|
+
import { parseSections, LO_SECTION_TYPES, } from "./sections.js";
|
|
3
|
+
import { parseWikilink, resolveWikilinkPath, hasRelativePath, } from "./wikilink.js";
|
|
4
|
+
import { detectFieldTypos } from "../validator/field-typos.js";
|
|
5
|
+
import { validateFrontmatter } from "../validator/validate-frontmatter.js";
|
|
6
|
+
import { validateTestSegments } from "../validator/test-segments.js";
|
|
7
|
+
import { convertSegment, stripAuthoringMarkup, LENS_SEGMENT_TYPES, } from "./lens.js";
|
|
7
8
|
export function parseLearningOutcome(content, file) {
|
|
8
9
|
const errors = [];
|
|
9
10
|
// Strip authoring markup (CriticMarkup + Obsidian comments) before parsing
|
|
@@ -15,25 +16,25 @@ export function parseLearningOutcome(content, file) {
|
|
|
15
16
|
return { learningOutcome: null, errors };
|
|
16
17
|
}
|
|
17
18
|
const { frontmatter, body, bodyStartLine } = frontmatterResult;
|
|
18
|
-
const frontmatterErrors = validateFrontmatter(frontmatter,
|
|
19
|
+
const frontmatterErrors = validateFrontmatter(frontmatter, "learning-outcome", file);
|
|
19
20
|
errors.push(...frontmatterErrors);
|
|
20
|
-
if (frontmatterErrors.some(e => e.severity ===
|
|
21
|
+
if (frontmatterErrors.some((e) => e.severity === "error")) {
|
|
21
22
|
return { learningOutcome: null, errors };
|
|
22
23
|
}
|
|
23
24
|
// LO-specific: id must be a string
|
|
24
|
-
if (typeof frontmatter.id !==
|
|
25
|
+
if (typeof frontmatter.id !== "string") {
|
|
25
26
|
errors.push({
|
|
26
27
|
file,
|
|
27
28
|
line: 2,
|
|
28
29
|
message: `Field 'id' must be a string, got ${typeof frontmatter.id}`,
|
|
29
30
|
suggestion: "Use quotes: id: '12345'",
|
|
30
|
-
severity:
|
|
31
|
+
severity: "error",
|
|
31
32
|
});
|
|
32
33
|
return { learningOutcome: null, errors };
|
|
33
34
|
}
|
|
34
35
|
// Step 2: Parse sections with H2 level and LO_SECTION_TYPES + 'submodule'
|
|
35
|
-
const loSectionTypes = new Set([...LO_SECTION_TYPES,
|
|
36
|
-
const sectionsResult = parseSections(body,
|
|
36
|
+
const loSectionTypes = new Set([...LO_SECTION_TYPES, "submodule"]);
|
|
37
|
+
const sectionsResult = parseSections(body, 0, loSectionTypes, file);
|
|
37
38
|
// Adjust line numbers to account for frontmatter
|
|
38
39
|
for (const error of sectionsResult.errors) {
|
|
39
40
|
if (error.line) {
|
|
@@ -53,9 +54,9 @@ export function parseLearningOutcome(content, file) {
|
|
|
53
54
|
errors.push({
|
|
54
55
|
file,
|
|
55
56
|
line: section.line,
|
|
56
|
-
message:
|
|
57
|
+
message: "Lens section missing source:: field",
|
|
57
58
|
suggestion: "Add 'source:: [[../Lenses/filename.md|Display]]' to the lens section",
|
|
58
|
-
severity:
|
|
59
|
+
severity: "error",
|
|
59
60
|
});
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
@@ -63,7 +64,7 @@ export function parseLearningOutcome(content, file) {
|
|
|
63
64
|
if (!wikilink || wikilink.error) {
|
|
64
65
|
const suggestion = wikilink?.correctedPath
|
|
65
66
|
? `Did you mean '[[${wikilink.correctedPath}]]'?`
|
|
66
|
-
:
|
|
67
|
+
: "Use format [[../Lenses/filename.md|Display Text]]";
|
|
67
68
|
errors.push({
|
|
68
69
|
file,
|
|
69
70
|
line: section.line,
|
|
@@ -71,7 +72,7 @@ export function parseLearningOutcome(content, file) {
|
|
|
71
72
|
? `${wikilink.error} in source:: field: ${source}`
|
|
72
73
|
: `Invalid wikilink format in source:: field: ${source}`,
|
|
73
74
|
suggestion,
|
|
74
|
-
severity:
|
|
75
|
+
severity: "error",
|
|
75
76
|
});
|
|
76
77
|
return null;
|
|
77
78
|
}
|
|
@@ -80,17 +81,41 @@ export function parseLearningOutcome(content, file) {
|
|
|
80
81
|
file,
|
|
81
82
|
line: section.line,
|
|
82
83
|
message: `source:: path must be relative (contain /): ${wikilink.path}`,
|
|
83
|
-
suggestion:
|
|
84
|
-
severity:
|
|
84
|
+
suggestion: "Use format [[../Lenses/filename.md|Display Text]] with relative path",
|
|
85
|
+
severity: "error",
|
|
85
86
|
});
|
|
86
87
|
return null;
|
|
87
88
|
}
|
|
88
89
|
const resolvedPath = resolveWikilinkPath(wikilink.path, file);
|
|
89
|
-
const optional = section.fields.optional?.toLowerCase() ===
|
|
90
|
-
|
|
90
|
+
const optional = section.fields.optional?.toLowerCase() === "true";
|
|
91
|
+
const hide = section.fields.hide?.toLowerCase() === "true";
|
|
92
|
+
return { source, resolvedPath, optional, hide };
|
|
91
93
|
}
|
|
92
94
|
// Helper: extract test ref from a parsed section
|
|
93
95
|
function extractTestRef(section) {
|
|
96
|
+
const id = section.fields.id;
|
|
97
|
+
if (!id) {
|
|
98
|
+
const hasSource = Boolean(section.fields.source);
|
|
99
|
+
const hasSegmentHeader = /^(#{1,6})\s+(Text|Question|Chat|Roleplay)(?::|\s*$)/im.test(section.body);
|
|
100
|
+
const hasKnownTestFields = [
|
|
101
|
+
"content",
|
|
102
|
+
"assessment-instructions",
|
|
103
|
+
"ai-instructions",
|
|
104
|
+
"opening-message",
|
|
105
|
+
"feedback",
|
|
106
|
+
].some((field) => section.fields[field] !== undefined);
|
|
107
|
+
if (!hasSource && !hasSegmentHeader && !hasKnownTestFields) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
errors.push({
|
|
111
|
+
file,
|
|
112
|
+
line: section.line,
|
|
113
|
+
message: "Test section missing required id:: field",
|
|
114
|
+
suggestion: "Add an id:: field with a UUID (e.g., id:: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)",
|
|
115
|
+
severity: "error",
|
|
116
|
+
});
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
94
119
|
const source = section.fields.source;
|
|
95
120
|
let resolvedPath;
|
|
96
121
|
if (source) {
|
|
@@ -98,7 +123,7 @@ export function parseLearningOutcome(content, file) {
|
|
|
98
123
|
if (!wikilink || wikilink.error) {
|
|
99
124
|
const suggestion = wikilink?.correctedPath
|
|
100
125
|
? `Did you mean '[[${wikilink.correctedPath}]]'?`
|
|
101
|
-
:
|
|
126
|
+
: "Use format [[../Tests/filename.md|Display Text]]";
|
|
102
127
|
errors.push({
|
|
103
128
|
file,
|
|
104
129
|
line: section.line,
|
|
@@ -106,22 +131,31 @@ export function parseLearningOutcome(content, file) {
|
|
|
106
131
|
? `${wikilink.error} in source:: field: ${source}`
|
|
107
132
|
: `Invalid wikilink format in source:: field: ${source}`,
|
|
108
133
|
suggestion,
|
|
109
|
-
severity:
|
|
134
|
+
severity: "error",
|
|
110
135
|
});
|
|
111
136
|
return undefined;
|
|
112
137
|
}
|
|
113
138
|
resolvedPath = resolveWikilinkPath(wikilink.path, file);
|
|
114
139
|
}
|
|
115
|
-
const {
|
|
140
|
+
const { sections: rawSegments, errors: segmentErrors } = parseSections(section.body, section.level, LENS_SEGMENT_TYPES, file, true);
|
|
116
141
|
for (const err of segmentErrors) {
|
|
117
142
|
if (err.line) {
|
|
118
143
|
err.line += bodyStartLine - 1;
|
|
119
144
|
}
|
|
120
145
|
}
|
|
121
146
|
errors.push(...segmentErrors);
|
|
147
|
+
// A Test is an assessment: only question/roleplay segments are rendered and
|
|
148
|
+
// scored. Flag any other segment type (e.g. intro text) — it is silently dropped.
|
|
149
|
+
const testSegmentErrors = validateTestSegments(rawSegments, file);
|
|
150
|
+
for (const err of testSegmentErrors) {
|
|
151
|
+
if (err.line) {
|
|
152
|
+
err.line += bodyStartLine - 1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
errors.push(...testSegmentErrors);
|
|
122
156
|
const testSegments = [];
|
|
123
157
|
for (const rawSeg of rawSegments) {
|
|
124
|
-
const { segment, errors: conversionErrors } = convertSegment(rawSeg,
|
|
158
|
+
const { segment, errors: conversionErrors } = convertSegment(rawSeg, "lens", file);
|
|
125
159
|
for (const err of conversionErrors) {
|
|
126
160
|
if (err.line) {
|
|
127
161
|
err.line += bodyStartLine - 1;
|
|
@@ -132,28 +166,28 @@ export function parseLearningOutcome(content, file) {
|
|
|
132
166
|
testSegments.push(segment);
|
|
133
167
|
}
|
|
134
168
|
}
|
|
135
|
-
return { source, resolvedPath, segments: testSegments };
|
|
169
|
+
return { id, source, resolvedPath, segments: testSegments };
|
|
136
170
|
}
|
|
137
171
|
// Step 3: Check for submodule sections
|
|
138
|
-
const hasSubmodules = sectionsResult.sections.some(s => s.type ===
|
|
172
|
+
const hasSubmodules = sectionsResult.sections.some((s) => s.type === "submodule");
|
|
139
173
|
const lenses = [];
|
|
140
174
|
let testRef;
|
|
141
175
|
let submodules;
|
|
142
176
|
if (hasSubmodules) {
|
|
143
177
|
// All-or-nothing: reject top-level lens/test sections when submodules exist
|
|
144
|
-
const orphanedSections = sectionsResult.sections.filter(s => s.type !==
|
|
178
|
+
const orphanedSections = sectionsResult.sections.filter((s) => s.type !== "submodule");
|
|
145
179
|
if (orphanedSections.length > 0) {
|
|
146
180
|
errors.push({
|
|
147
181
|
file,
|
|
148
182
|
line: orphanedSections[0].line,
|
|
149
|
-
message:
|
|
150
|
-
suggestion:
|
|
151
|
-
severity:
|
|
183
|
+
message: "Content found outside submodule boundaries — when using Submodule markers, all content must be inside a submodule",
|
|
184
|
+
suggestion: "Move this content into a Submodule section",
|
|
185
|
+
severity: "error",
|
|
152
186
|
});
|
|
153
187
|
}
|
|
154
188
|
submodules = [];
|
|
155
189
|
for (const section of sectionsResult.sections) {
|
|
156
|
-
if (section.type !==
|
|
190
|
+
if (section.type !== "submodule")
|
|
157
191
|
continue;
|
|
158
192
|
const group = {
|
|
159
193
|
title: section.title,
|
|
@@ -163,14 +197,14 @@ export function parseLearningOutcome(content, file) {
|
|
|
163
197
|
// Process children (lens/test sections at H3)
|
|
164
198
|
if (section.children) {
|
|
165
199
|
for (const child of section.children) {
|
|
166
|
-
if (child.type ===
|
|
200
|
+
if (child.type === "lens") {
|
|
167
201
|
const ref = extractLensRef(child);
|
|
168
202
|
if (ref) {
|
|
169
203
|
group.lenses.push(ref);
|
|
170
204
|
lenses.push(ref); // Also add to flat list for validation
|
|
171
205
|
}
|
|
172
206
|
}
|
|
173
|
-
else if (child.type ===
|
|
207
|
+
else if (child.type === "test") {
|
|
174
208
|
group.test = extractTestRef(child);
|
|
175
209
|
}
|
|
176
210
|
}
|
|
@@ -183,12 +217,12 @@ export function parseLearningOutcome(content, file) {
|
|
|
183
217
|
for (const section of sectionsResult.sections) {
|
|
184
218
|
const typoWarnings = detectFieldTypos(section.fields, file, section.line);
|
|
185
219
|
errors.push(...typoWarnings);
|
|
186
|
-
if (section.type ===
|
|
220
|
+
if (section.type === "lens") {
|
|
187
221
|
const ref = extractLensRef(section);
|
|
188
222
|
if (ref)
|
|
189
223
|
lenses.push(ref);
|
|
190
224
|
}
|
|
191
|
-
else if (section.type ===
|
|
225
|
+
else if (section.type === "test") {
|
|
192
226
|
testRef = extractTestRef(section);
|
|
193
227
|
}
|
|
194
228
|
}
|
|
@@ -198,11 +232,14 @@ export function parseLearningOutcome(content, file) {
|
|
|
198
232
|
errors.push({
|
|
199
233
|
file,
|
|
200
234
|
line: bodyStartLine,
|
|
201
|
-
message:
|
|
235
|
+
message: "Learning Outcome must have at least one ## Lens: section",
|
|
202
236
|
suggestion: "Add a '## Lens: <title>' section with a source:: field",
|
|
203
|
-
severity:
|
|
237
|
+
severity: "error",
|
|
204
238
|
});
|
|
205
239
|
}
|
|
240
|
+
const loAddToAiContext = "add_to_ai_context" in frontmatter
|
|
241
|
+
? frontmatter.add_to_ai_context
|
|
242
|
+
: undefined;
|
|
206
243
|
// Return result even if there are errors (partial success)
|
|
207
244
|
const learningOutcome = {
|
|
208
245
|
id: frontmatter.id,
|
|
@@ -210,6 +247,7 @@ export function parseLearningOutcome(content, file) {
|
|
|
210
247
|
test: testRef,
|
|
211
248
|
discussion: frontmatter.discussion,
|
|
212
249
|
submodules,
|
|
250
|
+
addToAiContext: loAddToAiContext,
|
|
213
251
|
};
|
|
214
252
|
return { learningOutcome, errors };
|
|
215
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"learning-outcome.js","sourceRoot":"","sources":["../../src/parser/learning-outcome.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"learning-outcome.js","sourceRoot":"","sources":["../../src/parser/learning-outcome.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,aAAa,EACb,gBAAgB,GAEjB,MAAM,eAAe,C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AAC;YAE7B,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC5B,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;gBACpC,IAAI,GAAG;oBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACnC,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI;YACJ,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,0DAA0D;YACnE,UAAU,EAAE,wDAAwD;YACpE,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,gBAAgB,GACpB,mBAAmB,IAAI,WAAW;QAChC,CAAC,CAAE,WAAW,CAAC,iBAAqC;QACpD,CAAC,CAAC,SAAS,CAAC;IAEhB,2DAA2D;IAC3D,MAAM,eAAe,GAA0B;QAC7C,EAAE,EAAE,WAAW,CAAC,EAAY;QAC5B,MAAM;QACN,IAAI,EAAE,OAAO;QACb,UAAU,EAAE,WAAW,CAAC,UAAgC;QACxD,UAAU;QACV,cAAc,EAAE,gBAAgB;KACjC,CAAC;IAEF,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/parser/lens.d.ts
CHANGED
|
@@ -6,22 +6,25 @@ export interface ParsedTextSegment {
|
|
|
6
6
|
}
|
|
7
7
|
export interface ParsedChatSegment {
|
|
8
8
|
type: 'chat';
|
|
9
|
-
title?: string;
|
|
10
9
|
instructions?: string;
|
|
11
10
|
hidePreviousContentFromUser?: boolean;
|
|
12
11
|
hidePreviousContentFromTutor?: boolean;
|
|
13
12
|
optional?: boolean;
|
|
14
13
|
}
|
|
15
|
-
export interface
|
|
16
|
-
type: 'article
|
|
14
|
+
export interface ParsedArticleSegment {
|
|
15
|
+
type: 'article';
|
|
16
|
+
source?: string;
|
|
17
|
+
resolvedPath?: string;
|
|
17
18
|
fromAnchor?: string;
|
|
18
19
|
toAnchor?: string;
|
|
19
20
|
optional?: boolean;
|
|
20
21
|
}
|
|
21
|
-
export interface
|
|
22
|
-
type: 'video
|
|
22
|
+
export interface ParsedVideoSegment {
|
|
23
|
+
type: 'video';
|
|
24
|
+
source?: string;
|
|
25
|
+
resolvedPath?: string;
|
|
23
26
|
fromTimeStr: string;
|
|
24
|
-
toTimeStr
|
|
27
|
+
toTimeStr?: string;
|
|
25
28
|
optional?: boolean;
|
|
26
29
|
}
|
|
27
30
|
export interface ParsedQuestionSegment {
|
|
@@ -41,41 +44,31 @@ export interface ParsedRoleplaySegment {
|
|
|
41
44
|
aiInstructions: string;
|
|
42
45
|
openingMessage?: string;
|
|
43
46
|
assessmentInstructions?: string;
|
|
47
|
+
userCustomizable?: boolean;
|
|
44
48
|
optional?: boolean;
|
|
45
49
|
feedback?: boolean;
|
|
46
50
|
}
|
|
47
|
-
export type ParsedLensSegment = ParsedTextSegment | ParsedChatSegment |
|
|
48
|
-
export interface ParsedLensSection {
|
|
49
|
-
type: string;
|
|
50
|
-
title: string;
|
|
51
|
-
source?: string;
|
|
52
|
-
resolvedPath?: string;
|
|
53
|
-
segments: ParsedLensSegment[];
|
|
54
|
-
line: number;
|
|
55
|
-
}
|
|
51
|
+
export type ParsedLensSegment = ParsedTextSegment | ParsedChatSegment | ParsedArticleSegment | ParsedVideoSegment | ParsedQuestionSegment | ParsedRoleplaySegment;
|
|
56
52
|
export interface ParsedLens {
|
|
57
53
|
id: string;
|
|
54
|
+
title?: string;
|
|
58
55
|
tldr?: string;
|
|
59
|
-
|
|
56
|
+
summaryForTutor?: string;
|
|
57
|
+
addToAiContext?: string[] | null;
|
|
58
|
+
segments: ParsedLensSegment[];
|
|
60
59
|
}
|
|
61
60
|
export interface LensParseResult {
|
|
62
61
|
lens: ParsedLens | null;
|
|
63
62
|
errors: ContentError[];
|
|
64
63
|
}
|
|
65
|
-
|
|
64
|
+
export declare const LENS_SEGMENT_TYPES: Set<string>;
|
|
65
|
+
/** Common interface for raw segments — compatible with ParsedSection */
|
|
66
|
+
export interface RawSegment {
|
|
66
67
|
type: string;
|
|
67
68
|
title?: string;
|
|
68
69
|
fields: Record<string, string>;
|
|
69
70
|
line: number;
|
|
70
71
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Parse H4 segments from a section body.
|
|
73
|
-
* Segments are defined by `#### <type>` headers within a section.
|
|
74
|
-
*/
|
|
75
|
-
export declare function parseSegments(sectionBody: string, bodyStartLine: number, file: string): {
|
|
76
|
-
segments: RawSegment[];
|
|
77
|
-
errors: ContentError[];
|
|
78
|
-
};
|
|
79
72
|
/**
|
|
80
73
|
* Convert a raw segment to a typed ParsedLensSegment.
|
|
81
74
|
*/
|
|
@@ -90,11 +83,11 @@ export declare function convertSegment(raw: RawSegment, sectionType: string, fil
|
|
|
90
83
|
export declare function stripObsidianComments(content: string): string;
|
|
91
84
|
/**
|
|
92
85
|
* Strip CriticMarkup from content using reject-all-changes behavior:
|
|
93
|
-
* - {>>comments<<}
|
|
94
|
-
* - {++additions++}
|
|
95
|
-
* - {--deletions--}
|
|
96
|
-
* - {~~old~>new~~}
|
|
97
|
-
* - {==highlights==}
|
|
86
|
+
* - {>>comments<<} -> removed
|
|
87
|
+
* - {++additions++} -> removed
|
|
88
|
+
* - {--deletions--} -> inner content kept (original preserved)
|
|
89
|
+
* - {~~old~>new~~} -> old text kept
|
|
90
|
+
* - {==highlights==} -> inner content kept, markers removed
|
|
98
91
|
*/
|
|
99
92
|
export declare function stripCriticMarkup(content: string): string;
|
|
100
93
|
/**
|
|
@@ -102,12 +95,18 @@ export declare function stripCriticMarkup(content: string): string;
|
|
|
102
95
|
* Call at the top of each parser before any processing.
|
|
103
96
|
*/
|
|
104
97
|
export declare function stripAuthoringMarkup(content: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* Apply source inheritance for article and video segments.
|
|
100
|
+
* Each article/video segment inherits source:: from the previous segment of the same type.
|
|
101
|
+
* Errors if the first segment of a type has no source.
|
|
102
|
+
*
|
|
103
|
+
* Mutates segments in place. Returns any errors.
|
|
104
|
+
*/
|
|
105
|
+
export declare function applySourceInheritance(segments: ParsedLensSegment[], file: string): ContentError[];
|
|
105
106
|
/**
|
|
106
107
|
* Parse a lens file into structured lens data.
|
|
107
108
|
*
|
|
108
|
-
* Lens files
|
|
109
|
-
*
|
|
110
|
-
* - H4 (`####`) for segments: Text, Chat, Article-excerpt, Video-excerpt
|
|
109
|
+
* Lens files are flat: frontmatter + H4 segments directly.
|
|
110
|
+
* No H3 section headers. Source is on segments with inheritance.
|
|
111
111
|
*/
|
|
112
112
|
export declare function parseLens(content: string, file: string): LensParseResult;
|
|
113
|
-
export {};
|