Работа над ContentsPage

This commit is contained in:
Book Pauk
2020-11-13 22:45:34 +07:00
parent e947b887fe
commit 952c337b76
2 changed files with 36 additions and 16 deletions

View File

@@ -58,6 +58,7 @@ export default class BookParser {
let curSubtitle = {paraIndex: -1, title: ''};
let inTitle = false;
let inSubtitle = false;
let sectionLevel = 0;
let paraIndex = -1;
let paraOffset = 0;
@@ -234,7 +235,7 @@ export default class BookParser {
center = true;
inTitle = true;
curTitle = {paraIndex, title: '', subtitles: []};
curTitle = {paraIndex, title: '', inset: sectionLevel, subtitles: []};
this.contents.push(curTitle);
}
@@ -242,6 +243,7 @@ export default class BookParser {
if (!isFirstSection)
newParagraph(' ', 1);
isFirstSection = false;
sectionLevel++;
}
if (tag == 'emphasis' || tag == 'strong') {
@@ -264,7 +266,7 @@ export default class BookParser {
center = true;
inSubtitle = true;
curSubtitle = {paraIndex, title: ''};
curSubtitle = {paraIndex, inset: sectionLevel, title: ''};
curTitle.subtitles.push(curSubtitle);
}
@@ -298,6 +300,10 @@ export default class BookParser {
inTitle = false;
}
if (tag == 'section') {
sectionLevel--;
}
if (tag == 'emphasis' || tag == 'strong') {
growParagraph(`</${tag}>`, 0);
}