1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
package list
// RenderMarkdown renders the List in the Markdown format. Example:
// * Game Of Thrones
// * Winter
// * Is
// * Coming
// * This
// * Is
// * Known
// * The Dark Tower
// * The Gunslinger
func (l *List) RenderMarkdown() string {
// make a copy of the original style and ensure it is restored on exit
originalStyle := l.style
defer func() {
if originalStyle == nil {
l.style = nil
} else {
l.SetStyle(*originalStyle)
}
}()
// override whatever style was set with StyleMarkdown
l.SetStyle(StyleMarkdown)
// render like a regular list
return l.Render()
}
|