mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-03 07:27:19 -04:00
fix issue where lists that didn't start at 1 were not respected (#116)
This commit is contained in:
@@ -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
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user