#61 Make sure to prevent: Unsupported headline level: 7

This commit is contained in:
Johannes Zillmann 2024-03-18 17:19:29 -06:00
parent 4ba336f203
commit 33c2d3d3d5
2 changed files with 6 additions and 2 deletions

View File

@ -69,7 +69,7 @@ export default class DetectHeaders extends ToLineItemTransformation {
heights.forEach((height, i) => {
const headlineLevel = i + 2;
if (headlineLevel <= 6) {
const headlineType = headlineByLevel(2 + i);
const headlineType = headlineByLevel(headlineLevel);
parseResult.pages.forEach(page => {
page.items.forEach(item => {
if (!item.type && item.height == height && !isListItem(item.text())) {

View File

@ -244,8 +244,12 @@ function findHeadlineItems(page, headline) {
}
function addHeadlineItems(page, tocLink, foundItems, headlineTypeToHeightRange) {
const headlineLevel=tocLink.level + 2;
if(headlineLevel>6){
return ;
}
foundItems.headlineItems.forEach(item => item.annotation = REMOVED_ANNOTATION);
const headlineType = headlineByLevel(tocLink.level + 2);
const headlineType = headlineByLevel(headlineLevel);
const headlineHeight = foundItems.headlineItems.reduce((max, item) => Math.max(max, item.height), 0);
page.items.splice(foundItems.lineIndex + 1, 0, new LineItem({
...foundItems.headlineItems[0],