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,9 +141,11 @@ func (chap *Chapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext,
if chap.includeInTOC {
// Add to TOC.
chapNumber := ""
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,6 +148,8 @@ func (subchap *Subchapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawCo
if subchap.includeInTOC {
// Add to TOC.
subchapNumber := ""
if subchap.showNumbering {
if subchap.chapterNum != 0 {
subchapNumber = strconv.Itoa(subchap.chapterNum)
}
@ -158,6 +160,7 @@ func (subchap *Subchapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawCo
subchapNumber += strconv.Itoa(subchap.subchapterNum) + "."
}
}
subchap.toc.Add(subchapNumber, subchap.title, strconv.Itoa(ctx.Page), 2)
}