Take showNumbering field into account for chapter and subchapter components

This commit is contained in:
Adrian-George Bostan 2019-01-09 20:51:46 +02:00
parent 15f437dc92
commit e060d942f6
2 changed files with 15 additions and 10 deletions

View File

@ -141,8 +141,10 @@ func (chap *Chapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext,
if chap.includeInTOC {
// Add to TOC.
chapNumber := ""
if chap.number != 0 {
chapNumber = strconv.Itoa(chap.number) + "."
if chap.showNumbering {
if chap.number != 0 {
chapNumber = strconv.Itoa(chap.number) + "."
}
}
chap.toc.Add(chapNumber, chap.title, strconv.Itoa(ctx.Page), 1)

View File

@ -148,15 +148,18 @@ func (subchap *Subchapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawCo
if subchap.includeInTOC {
// Add to TOC.
subchapNumber := ""
if subchap.chapterNum != 0 {
subchapNumber = strconv.Itoa(subchap.chapterNum)
}
if subchap.subchapterNum != 0 {
if subchapNumber != "" {
subchapNumber += "."
}
subchapNumber += strconv.Itoa(subchap.subchapterNum) + "."
if subchap.showNumbering {
if subchap.chapterNum != 0 {
subchapNumber = strconv.Itoa(subchap.chapterNum)
}
if subchap.subchapterNum != 0 {
if subchapNumber != "" {
subchapNumber += "."
}
subchapNumber += strconv.Itoa(subchap.subchapterNum) + "."
}
}
subchap.toc.Add(subchapNumber, subchap.title, strconv.Itoa(ctx.Page), 2)