Preserve QPowerPoint paragraph breaks on import

This commit is contained in:
Курнат Андрей
2026-06-01 08:12:05 +03:00
parent 66406c2c0c
commit 51dac642e7
3 changed files with 39 additions and 3 deletions
+9 -1
View File
@@ -178,7 +178,7 @@ function extractSlideTextBlocks(slideXml: unknown): SlideTextBlock[] {
const textBodies = recordsByKey(slideXml, "txBody");
const blocks = textBodies
.map((textBody) => {
const text = normalizeWhitespace(extractTextBlocks(textBody).join("\n"));
const text = extractTextBodyText(textBody);
if (!text) {
return null;
}
@@ -199,6 +199,14 @@ function extractSlideTextBlocks(slideXml: unknown): SlideTextBlock[] {
return blocks.length > 0 ? blocks : extractTextBlocks(slideXml).map((text) => ({ text }));
}
function extractTextBodyText(textBody: Record<string, unknown>) {
const paragraphs = toArray(textBody.p)
.map((paragraph) => normalizeWhitespace(extractTextBlocks(paragraph).join("")))
.filter(Boolean);
return paragraphs.length > 0 ? paragraphs.join("\n") : normalizeWhitespace(extractTextBlocks(textBody).join("\n"));
}
export function listSlidePaths(
zip: ZipArchive,
presentationXml?: unknown,