From dc22bb7523a4d011fb9e9fa3889b62bc7709c6b9 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Mon, 10 Aug 2026 21:22:34 +0000 Subject: [PATCH] fix: a style keeps the line spacing its document default does not MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Word writes 1.08 into w:docDefaults, so a style declaring single spacing was dropped as "the default anyway" and inherited 1.08 instead — every Title and every heading that asks for 1 rendered a line too tall. The parent style is the yardstick, which ownProps already applies. --- src/lib/import/docx.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/import/docx.ts b/src/lib/import/docx.ts index ac552b2..0d23166 100644 --- a/src/lib/import/docx.ts +++ b/src/lib/import/docx.ts @@ -661,9 +661,11 @@ function stylePara(ctx: Ctx, id: string | null): ParaProps { const sp = ctx.styles.paragraphSpacing(id); if (sp.before != null) out.spaceBefore = snapPt(twipToPt(sp.before)); if (sp.after != null) out.spaceAfter = snapPt(twipToPt(sp.after)); + // Not suppressed against single spacing — the document default may be something else + // (Word writes 1.08), and a style declaring 1 would then inherit that instead. What + // the parent style already supplies is dropped by the caller's ownProps. if (sp.line != null && (!sp.lineRule || sp.lineRule === 'auto')) { - const mult = round2(sp.line / 240); - if (Math.abs(mult - 1) > 0.01) out.lineHeight = String(mult); + out.lineHeight = String(round2(sp.line / 240)); } const jc = ctx.styles.paragraphAlign(id); if (jc === 'center') out.textAlign = 'center';