Skip to content

Commit

Permalink
fix: updated numbering xml generation
Browse files Browse the repository at this point in the history
  • Loading branch information
privateOmega committed May 28, 2020
1 parent 2e28b5e commit 81b7a82
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/docx-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,27 @@ class DocxDocument {

// eslint-disable-next-line class-methods-use-this
generateNumberingXML() {
const numberingInstancesXML = this.numberingObjects.reduce(
const xmlFragment = fragment({
namespaceAlias: { w: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main' },
});

this.numberingObjects.forEach(
// eslint-disable-next-line array-callback-return
(xmlFragment, { numberingId, ordered }) => {
xmlFragment
({ numberingId, ordered }) => {
const numberingFragment = fragment({
namespaceAlias: { w: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main' },
})
.ele('@w', 'num')
.att('@w', 'numId', String(numberingId))
.ele('@w', 'abstractNumId')
.att('@w', 'val', ordered ? '1' : '2')
.up()
.up();
},
fragment({
namespaceAlias: { w: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main' },
})
xmlFragment.import(numberingFragment);
}
);

return generateNumberingXML(numberingInstancesXML);
return generateNumberingXML(xmlFragment.toString({ prettyPrint: true }) || '');
}

// eslint-disable-next-line class-methods-use-this
Expand Down

0 comments on commit 81b7a82

Please sign in to comment.