github.com/charmbracelet/glamour@v0.7.0/ansi/listitem.go (about) 1 package ansi 2 3 import ( 4 "io" 5 "strconv" 6 ) 7 8 // An ItemElement is used to render items inside a list. 9 type ItemElement struct { 10 IsOrdered bool 11 Enumeration uint 12 } 13 14 func (e *ItemElement) Render(w io.Writer, ctx RenderContext) error { 15 var el *BaseElement 16 if e.IsOrdered { 17 el = &BaseElement{ 18 Style: ctx.options.Styles.Enumeration, 19 Prefix: strconv.FormatInt(int64(e.Enumeration), 10), 20 } 21 } else { 22 el = &BaseElement{ 23 Style: ctx.options.Styles.Item, 24 } 25 } 26 27 return el.Render(w, ctx) 28 }