Quick fix for not crashing when TOC detection thinks a headline is > 6

This commit is contained in:
Johannes Zillmann 2021-02-26 12:10:26 +01:00
parent ea67f4b244
commit 21f36a9d4e

View File

@ -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);