Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DetectTOC: only go for lines containing '...' words #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/javascript/models/transformations/lineitem/DetectTOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ export default class DetectTOC extends ToLineItemTransformation {
const pageTocLinks = [];
var lastWordsWithoutNumber;
var lastLine;
//find lines ending with a number per page
page.items.forEach(line => {
// find lines with words containing only "." ...
const tocLines = page.items.filter(line => line.words.includes(word => hasOnly(word.string, '.')))
// ... and ending with a number per page
tocLines.forEach(line => {
var words = line.words.filter(word => !hasOnly(word.string, '.'));
const digits = [];
while (words.length > 0 && isNumber(words[words.length - 1].string)) {
Expand Down