markup/asciidocext: Fix AsciiDoc TOC with code

Fixes #7649
This commit is contained in:
Helder Pereira
2020-09-09 22:41:53 +01:00
committed by Bjørn Erik Pedersen
parent 746ba803af
commit 6a848cbc3a
5 changed files with 99 additions and 59 deletions

View File

@@ -40,19 +40,19 @@ type Root struct {
}
// AddAt adds the header into the given location.
func (toc *Root) AddAt(h Header, y, x int) {
for i := len(toc.Headers); i <= y; i++ {
func (toc *Root) AddAt(h Header, row, level int) {
for i := len(toc.Headers); i <= row; i++ {
toc.Headers = append(toc.Headers, Header{})
}
if x == 0 {
toc.Headers[y] = h
if level == 0 {
toc.Headers[row] = h
return
}
header := &toc.Headers[y]
header := &toc.Headers[row]
for i := 1; i < x; i++ {
for i := 1; i < level; i++ {
if len(header.Headers) == 0 {
header.Headers = append(header.Headers, Header{})
}