fix: bound OneNote export output

This commit is contained in:
2026-07-22 20:03:55 +02:00
parent 45880fcf2b
commit 572a67148a
7 changed files with 1049 additions and 121 deletions

View File

@@ -13,6 +13,7 @@ import type {
} from '../one/content-model.js';
import {
createOneNoteExportPlan,
enforceSerializedTextOutput,
exportResourceKey,
type OneNoteExportPlan,
type PlannedOneNoteResource,
@@ -91,7 +92,11 @@ export function serializeStructuredJsonWithPlan(
warnings: plan.warnings,
unsupportedContent: plan.unsupportedContent,
};
return `${JSON.stringify(value, null, 2)}\n`;
return enforceSerializedTextOutput(
`${JSON.stringify(value, null, 2)}\n`,
plan,
'Structured JSON export'
);
}
export function serializePlainTextWithPlan(
@@ -138,10 +143,14 @@ export function serializePlainTextWithPlan(
}
}
appendPlainWarnings(lines, plan);
return `${lines
.join('\n')
.replace(/\n{4,}/gu, '\n\n\n')
.trimEnd()}\n`;
return enforceSerializedTextOutput(
`${lines
.join('\n')
.replace(/\n{4,}/gu, '\n\n\n')
.trimEnd()}\n`,
plan,
'Plain-text export'
);
}
export function serializeMarkdownWithPlan(
@@ -192,10 +201,14 @@ export function serializeMarkdownWithPlan(
}
}
appendMarkdownWarnings(lines, plan);
return `${lines
.join('\n')
.replace(/\n{4,}/gu, '\n\n\n')
.trimEnd()}\n`;
return enforceSerializedTextOutput(
`${lines
.join('\n')
.replace(/\n{4,}/gu, '\n\n\n')
.trimEnd()}\n`,
plan,
'Markdown export'
);
}
export function serializeHtmlWithPlan(
@@ -214,7 +227,8 @@ export function serializeHtmlWithPlan(
.map((section) => htmlSection(section, context))
.join('\n');
const warnings = htmlWarnings(plan);
return `<!doctype html>
return enforceSerializedTextOutput(
`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
@@ -246,7 +260,10 @@ ${sections}
${warnings}
</body>
</html>
`;
`,
plan,
'Semantic HTML export'
);
}
function htmlSection(