Skip to content

Commit 3529c0c

Browse files
authored
fix: emit paragraph sectPr and update snapshots (#862)
1 parent f8d9f40 commit 3529c0c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

docx-core/src/documents/elements/paragraph_property.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ impl BuildXML for ParagraphProperty {
244244
.apply_each(&self.tabs, |tab, b| b.tab(tab.val, tab.leader, tab.pos))?
245245
.close()
246246
})?
247+
.add_optional_child(&self.section_property)?
247248
.close()?
248249
.into_inner()
249250
}
@@ -252,6 +253,7 @@ impl BuildXML for ParagraphProperty {
252253
#[cfg(test)]
253254
mod tests {
254255
use super::*;
256+
use crate::types::SectionType;
255257
use crate::types::LineSpacingType;
256258
#[cfg(test)]
257259
use pretty_assertions::assert_eq;
@@ -333,4 +335,17 @@ mod tests {
333335
r#"<w:pPr><w:rPr /><w:spacing w:line="100" w:lineRule="atLeast" /></w:pPr>"#
334336
)
335337
}
338+
339+
#[test]
340+
fn test_section_property() {
341+
let props = ParagraphProperty::new().section_property(SectionProperty {
342+
section_type: Some(SectionType::NextPage),
343+
..Default::default()
344+
});
345+
let bytes = props.build();
346+
assert_eq!(
347+
str::from_utf8(&bytes).unwrap(),
348+
r#"<w:pPr><w:rPr /><w:sectPr><w:pgSz w:w="11906" w:h="16838" /><w:pgMar w:top="1985" w:right="1701" w:bottom="1701" w:left="1701" w:header="851" w:footer="992" w:gutter="0" /><w:cols w:space="425" w:num="1" /><w:type w:val="nextPage" /></w:sectPr></w:pPr>"#
349+
)
350+
}
336351
}

0 commit comments

Comments
 (0)