mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-01 22:17:29 +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 {
|
if chap.includeInTOC {
|
||||||
// Add to TOC.
|
// Add to TOC.
|
||||||
chapNumber := ""
|
chapNumber := ""
|
||||||
if chap.number != 0 {
|
if chap.showNumbering {
|
||||||
chapNumber = strconv.Itoa(chap.number) + "."
|
if chap.number != 0 {
|
||||||
|
chapNumber = strconv.Itoa(chap.number) + "."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chap.toc.Add(chapNumber, chap.title, strconv.Itoa(ctx.Page), 1)
|
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 {
|
if subchap.includeInTOC {
|
||||||
// Add to TOC.
|
// Add to TOC.
|
||||||
subchapNumber := ""
|
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)
|
subchap.toc.Add(subchapNumber, subchap.title, strconv.Itoa(ctx.Page), 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user