diff options
| author | Michael Williamson <mike@zwobble.org> | 2019-03-17 20:53:23 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2019-03-17 20:53:23 +0000 |
| commit | e568765535b48643e1377dfd8479920fa755feb0 (patch) | |
| tree | 5853eace48c39cc3e074e5f4ca6591db7da33f09 /lib | |
| parent | 82f8b03022950069c4ee2239e9fa4368fbecd661 (diff) | |
Follow w:numStyleLink in w:abstractNum
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx/numbering-xml.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/docx/numbering-xml.js b/lib/docx/numbering-xml.js index 028bf01..90e479e 100644 --- a/lib/docx/numbering-xml.js +++ b/lib/docx/numbering-xml.js @@ -2,16 +2,24 @@ exports.readNumberingXml = readNumberingXml; exports.Numbering = Numbering; exports.defaultNumbering = new Numbering({}); -function Numbering(nums, abstractNums) { - return { - findLevel: function(numId, level) { - var num = nums[numId]; - if (num) { +function Numbering(nums, abstractNums, styles) { + function findLevel(numId, level) { + var num = nums[numId]; + if (num) { + var abstractNum = abstractNums[num.abstractNumId]; + if (abstractNum.numStyleLink == null) { return abstractNums[num.abstractNumId].levels[level]; } else { - return null; + var style = styles.findNumberingStyleById(abstractNum.numStyleLink); + return findLevel(style.numId, level); } + } else { + return null; } + } + + return { + findLevel: findLevel }; } @@ -22,7 +30,7 @@ function readNumberingXml(root, options) { var abstractNums = readAbstractNums(root); var nums = readNums(root, abstractNums); - return new Numbering(nums, abstractNums); + return new Numbering(nums, abstractNums, options.styles); } function readAbstractNums(root) { @@ -44,7 +52,10 @@ function readAbstractNum(element) { level: levelIndex }; }); - return {levels: levels}; + + var numStyleLink = element.firstOrEmpty("w:numStyleLink").attributes["w:val"]; + + return {levels: levels, numStyleLink: numStyleLink}; } function readNums(root) { |
