Skip to content

Commit 07afb48

Browse files
Fix an issue where SVG highlight rectangles sometimes stuck out into the margin
1 parent 4a113cc commit 07afb48

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

highlight-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,8 @@ function Highlighter(options = hhDefaultOptions) {
13081308
mergedRect.width = rect.width;
13091309
}
13101310
// Process then remove rects that apply to the current line
1311-
const minLeft = Math.min(mergedRect.x, rect.x);
1312-
const maxRight = Math.max(mergedRect.right, rect.right);
1311+
const minLeft = Math.max(paragraphRect.left, Math.min(mergedRect.x, rect.x));
1312+
const maxRight = Math.min(paragraphRect.right, Math.max(mergedRect.right, rect.right));
13131313
mergedRect.width = maxRight - minLeft;
13141314
mergedRect.x = minLeft;
13151315
unmergedRects.splice(r, 1); r--;

0 commit comments

Comments
 (0)