From ecde2ea0f52598c1849fb73a06200b87946590e5 Mon Sep 17 00:00:00 2001 From: Johannes Zillmann Date: Tue, 2 May 2017 19:26:11 +0200 Subject: [PATCH] Prevent headline detection code from detecting headline > 6 --- .../lineitem/DetectHeaders.jsx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/javascript/models/transformations/lineitem/DetectHeaders.jsx b/src/javascript/models/transformations/lineitem/DetectHeaders.jsx index 58d283b..ac99a57 100644 --- a/src/javascript/models/transformations/lineitem/DetectHeaders.jsx +++ b/src/javascript/models/transformations/lineitem/DetectHeaders.jsx @@ -67,16 +67,19 @@ export default class DetectHeaders extends ToLineItemTransformation { heights.sort((a, b) => b - a); heights.forEach((height, i) => { - const headlineType = headlineByLevel(2 + i); - parseResult.pages.forEach(page => { - page.items.forEach(item => { - if (!item.type && item.height == height && !isListItem(item.text())) { - detectedHeaders++; - item.annotation = DETECTED_ANNOTATION; - item.type = headlineType; - } + const headlineLevel = i + 2; + if (headlineLevel <= 6) { + const headlineType = headlineByLevel(2 + i); + parseResult.pages.forEach(page => { + page.items.forEach(item => { + if (!item.type && item.height == height && !isListItem(item.text())) { + detectedHeaders++; + item.annotation = DETECTED_ANNOTATION; + item.type = headlineType; + } + }); }); - }); + } }); }