Preserve QPowerPoint paragraph breaks on import
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user