diff --git a/deno.lock b/deno.lock index 644c8c6..8287051 100644 --- a/deno.lock +++ b/deno.lock @@ -2,9 +2,12 @@ "version": "5", "specifiers": { "jsr:@std/assert@^1.0.19": "1.0.19", + "jsr:@std/expect@1.0.19": "1.0.19", "jsr:@std/fmt@1.0.10": "1.0.10", + "jsr:@std/internal@^1.0.12": "1.0.13", "jsr:@std/internal@^1.0.13": "1.0.13", "jsr:@std/path@1.1.4": "1.1.4", + "jsr:@std/path@^1.1.4": "1.1.4", "jsr:@std/testing@1.0.18": "1.0.18", "npm:eslint@10.4.0": "10.4.0", "npm:fontoxpath@3.34.0": "3.34.0", @@ -13,7 +16,18 @@ }, "jsr": { "@std/assert@1.0.19": { - "integrity": "eaada96ee120cb980bc47e040f82814d786fe8162ecc53c91d8df60b8755991e" + "integrity": "eaada96ee120cb980bc47e040f82814d786fe8162ecc53c91d8df60b8755991e", + "dependencies": [ + "jsr:@std/internal@^1.0.12" + ] + }, + "@std/expect@1.0.19": { + "integrity": "25271785688c7ff902fa54875d6aa4001f552c5578f7f0fefb5b5aac1fc2ed8a", + "dependencies": [ + "jsr:@std/assert", + "jsr:@std/internal@^1.0.13", + "jsr:@std/path@^1.1.4" + ] }, "@std/fmt@1.0.10": { "integrity": "90dfba288802ac6de82fb31d0917eb9e4450b9925b954d5e51fc29ac07419db5" @@ -22,13 +36,16 @@ "integrity": "2f9546691d4ac2d32859c82dff284aaeac980ddeca38430d07941e7e288725c0" }, "@std/path@1.1.4": { - "integrity": "1d2d43f39efb1b42f0b1882a25486647cb851481862dc7313390b2bb044314b5" + "integrity": "1d2d43f39efb1b42f0b1882a25486647cb851481862dc7313390b2bb044314b5", + "dependencies": [ + "jsr:@std/internal@^1.0.12" + ] }, "@std/testing@1.0.18": { "integrity": "d3152f57b11666bf6358d0e127c7e3488e91178b0c2d8fbf0793e1c53cd13cb1", "dependencies": [ "jsr:@std/assert", - "jsr:@std/internal" + "jsr:@std/internal@^1.0.13" ] } }, diff --git a/lib/properties/src/paragraph-properties.ts b/lib/properties/src/paragraph-properties.ts index fc5d036..ebcd44f 100644 --- a/lib/properties/src/paragraph-properties.ts +++ b/lib/properties/src/paragraph-properties.ts @@ -95,6 +95,10 @@ export type ParagraphProperties = { */ change?: null | (ChangeInformation & Omit); pageBreakBefore?: null | boolean; + /** + * Suppress space above/below when the adjacent paragraph uses the same style. + */ + contextualSpacing?: null | boolean; /** * Used for formatting of the `rPr` elements at the top level of a paragraph. * This is text property changes applied to the whole parent paragraph. @@ -175,7 +179,8 @@ export function paragraphPropertiesFromNode( "date": @${QNS.w}date/string(), "_node": ./${QNS.w}pPr }, - "pageBreakBefore": docxml:ct-on-off(./${QNS.w}pageBreakBefore), + "pageBreakBefore": docxml:ct-on-off(./${QNS.w}pageBreakBefore), + "contextualSpacing": docxml:ct-on-off(./${QNS.w}contextualSpacing), "tabs": ./${QNS.w}tabs/array {${QNS.w}tab/map { "type": @${QNS.w}val/string(), "leader": @${QNS.w}leader/string(), @@ -294,8 +299,12 @@ export async function paragraphPropertiesToNode( $rpr, $sectpr, - if (exists($pageBreakBefore)) then element ${QNS.w}pageBreakBefore { - attribute ${QNS.w}val { $pageBreakBefore } + if (exists($pageBreakBefore)) then element ${QNS.w}pageBreakBefore { + attribute ${QNS.w}val { $pageBreakBefore } + } else (), + + if (exists($contextualSpacing)) then element ${QNS.w}contextualSpacing { + attribute ${QNS.w}val { $contextualSpacing } } else (), if (exists($change)) then element ${QNS.w}pPrChange { @@ -359,6 +368,7 @@ export async function paragraphPropertiesToNode( : null, listItem: data.listItem || null, pageBreakBefore: data.pageBreakBefore || null, + contextualSpacing: data.contextualSpacing || null, change: data.change ? { id: data.change.id, diff --git a/lib/properties/test/paragraph-properties.test.ts b/lib/properties/test/paragraph-properties.test.ts index fe7a704..819ab38 100644 --- a/lib/properties/test/paragraph-properties.test.ts +++ b/lib/properties/test/paragraph-properties.test.ts @@ -227,4 +227,20 @@ describe('Paragraph formatting', () => { } ); }); + + describe('contextualSpacing', () => { + test( + ` + + `, + { contextualSpacing: true } + ); + + test( + ` + + `, + { contextualSpacing: false } + ); + }); });