Skip to content

Commit

Permalink
backport PR #2760
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Jul 30, 2024
1 parent 852ef22 commit 1663642
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Fixes and validates input values headerRows and keepWithHeaderRows
- Fixed numbering nested ordered lists

## 0.2.10 - 2024-03-07

Expand Down
14 changes: 7 additions & 7 deletions src/docMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,16 +509,16 @@ DocMeasure.prototype.measureOrderedList = function (node) {
if (item.listMarker._inlines) {
node._gapSize.width = Math.max(node._gapSize.width, item.listMarker._inlines[0].width);
}
} // TODO: else - nested lists numbering

if (node.reversed) {
counter--;
} else {
counter++;
}
}

node._minWidth = Math.max(node._minWidth, items[i]._minWidth);
node._maxWidth = Math.max(node._maxWidth, items[i]._maxWidth);

if (node.reversed) {
counter--;
} else {
counter++;
}
}

node._minWidth += node._gapSize.width;
Expand Down
8 changes: 8 additions & 0 deletions tests/docMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ describe('DocMeasure', function () {
assert(result._gapSize);
});

it('should not increase listMarker when list item is a nested list', function () {
var node = { ol: ['parent item 1', { ol: ['nested item 1', 'nested item 2']}, 'parent item 2'] };
docPreprocessor.preprocessList(node);
var result = docMeasure.measureOrderedList(node);

assert.equal(result.ol[2].listMarker._inlines[0].text, '2. ');
});

it('should calculate _minWidth and _maxWidth of all elements', function () {
var node = { ol: ['this is a test', 'another one'] };
docPreprocessor.preprocessList(node);
Expand Down

0 comments on commit 1663642

Please sign in to comment.