fix issue where lists that didn't start at 1 were not respected (#116)

This commit is contained in:
R. Aidan Campbell
2021-08-12 03:45:29 +02:00
committed by GitHub
parent 8ea7b1c86c
commit 49f2da7fed
5 changed files with 21 additions and 1 deletions
+4
View File
@@ -129,6 +129,9 @@ func (tr *ANSIRenderer) NewElement(node ast.Node, source []byte) Element {
}
if node.Parent().(*ast.List).IsOrdered() {
e = l
if node.Parent().(*ast.List).Start != 1 {
e += uint(node.Parent().(*ast.List).Start) - 1
}
}
post := "\n"
@@ -153,6 +156,7 @@ func (tr *ANSIRenderer) NewElement(node ast.Node, source []byte) Element {
return Element{
Exiting: post,
Renderer: &ItemElement{
IsOrdered: node.Parent().(*ast.List).IsOrdered(),
Enumeration: e,
},
}
+2 -1
View File
@@ -7,12 +7,13 @@ import (
// An ItemElement is used to render items inside a list.
type ItemElement struct {
IsOrdered bool
Enumeration uint
}
func (e *ItemElement) Render(w io.Writer, ctx RenderContext) error {
var el *BaseElement
if e.Enumeration > 0 {
if e.IsOrdered {
el = &BaseElement{
Style: ctx.options.Styles.Enumeration,
Prefix: strconv.FormatInt(int64(e.Enumeration), 10),