File: render_markdown.go

package info (click to toggle)
golang-github-jedib0t-go-pretty 6.2.4-1~bpo11%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye-backports
  • size: 1,168 kB
  • sloc: makefile: 31; sh: 14
file content (29 lines) | stat: -rw-r--r-- 637 bytes parent folder | download | duplicates (2)
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()
}