Skip to content

Commit

Permalink
Merge pull request #2760 from fe-cj/fix/issue-875-2582
Browse files Browse the repository at this point in the history
Fixes #875 and #2582
  • Loading branch information
liborm85 committed Jul 30, 2024
2 parents 7fcee56 + 17b2818 commit e5d1cbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/DocMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,17 @@ class DocMeasure {
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/unit/DocMeasure.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,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 e5d1cbf

Please sign in to comment.