From 21f36a9d4e9e8ff6b7a25b03bc38868fa0ecc7ad Mon Sep 17 00:00:00 2001 From: Johannes Zillmann Date: Fri, 26 Feb 2021 12:10:26 +0100 Subject: [PATCH] Quick fix for not crashing when TOC detection thinks a headline is > 6 --- src/javascript/models/transformations/lineitem/DetectTOC.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/javascript/models/transformations/lineitem/DetectTOC.jsx b/src/javascript/models/transformations/lineitem/DetectTOC.jsx index 46525f5..1fcfda0 100644 --- a/src/javascript/models/transformations/lineitem/DetectTOC.jsx +++ b/src/javascript/models/transformations/lineitem/DetectTOC.jsx @@ -146,7 +146,7 @@ export default class DetectTOC extends ToLineItemTransformation { const rollupLastNotFound = (currentPageNumber) => { if (lastNotFound.length > 0) { lastNotFound.forEach(notFoundTocLink => { - const headlineType = headlineByLevel(notFoundTocLink.level + 2); + const headlineType = headlineByLevel(Math.min(notFoundTocLink.level + 2, 6)); const heightRange = headlineTypeToHeightRange[headlineType.name]; if (heightRange) { const [pageIndex, lineIndex] = findPageAndLineFromHeadline(parseResult.pages, notFoundTocLink, heightRange, fromPage, currentPageNumber);