mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-30 13:48:51 +08:00
Take showNumbering field into account for chapter and subchapter components
This commit is contained in:
parent
15f437dc92
commit
e060d942f6
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user