diff options
| author | Michael Williamson <mike@zwobble.org> | 2019-03-17 18:15:04 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2019-03-17 18:15:04 +0000 |
| commit | 2c99c227c9df508812b932096f00547ea54f8b80 (patch) | |
| tree | 623e43e229e163ffaad610e1a942f0bb5e08dd10 /lib | |
| parent | 59d569588c22a429b6da8a696119b7b35a6603a9 (diff) | |
Defer resolution of abstract nums until necessary
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx/numbering-xml.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/docx/numbering-xml.js b/lib/docx/numbering-xml.js index 2cfd9e1..e74c917 100644 --- a/lib/docx/numbering-xml.js +++ b/lib/docx/numbering-xml.js @@ -2,12 +2,12 @@ exports.readNumberingXml = readNumberingXml; exports.Numbering = Numbering; exports.defaultNumbering = new Numbering({}); -function Numbering(nums) { +function Numbering(nums, abstractNums) { return { findLevel: function(numId, level) { var num = nums[numId]; if (num) { - return num[level]; + return abstractNums[num.abstractNumId][level]; } else { return null; } @@ -18,7 +18,7 @@ function Numbering(nums) { function readNumberingXml(root) { var abstractNums = readAbstractNums(root); var nums = readNums(root, abstractNums); - return new Numbering(nums); + return new Numbering(nums, abstractNums); } function readAbstractNums(root) { @@ -43,12 +43,12 @@ function readAbstractNum(element) { return levels; } -function readNums(root, abstractNums) { +function readNums(root) { var nums = {}; root.getElementsByTagName("w:num").forEach(function(element) { - var id = element.attributes["w:numId"]; + var numId = element.attributes["w:numId"]; var abstractNumId = element.first("w:abstractNumId").attributes["w:val"]; - nums[id] = abstractNums[abstractNumId]; + nums[numId] = {abstractNumId: abstractNumId}; }); return nums; } |
