2021-02-01 00:10:16 +01:00
|
|
|
package md2man
|
|
|
|
|
|
|
|
import (
|
2024-09-26 22:33:05 +02:00
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
|
2021-02-01 00:10:16 +01:00
|
|
|
"github.com/russross/blackfriday/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Render converts a markdown document into a roff formatted document.
|
|
|
|
func Render(doc []byte) []byte {
|
|
|
|
renderer := NewRoffRenderer()
|
2024-09-26 22:33:05 +02:00
|
|
|
var r blackfriday.Renderer = renderer
|
|
|
|
if v, _ := strconv.ParseBool(os.Getenv("MD2MAN_DEBUG")); v {
|
|
|
|
r = &debugDecorator{Renderer: r}
|
|
|
|
}
|
2021-02-01 00:10:16 +01:00
|
|
|
|
|
|
|
return blackfriday.Run(doc,
|
2023-10-16 14:33:03 +02:00
|
|
|
[]blackfriday.Option{
|
2024-09-26 22:33:05 +02:00
|
|
|
blackfriday.WithRenderer(r),
|
2023-10-16 14:33:03 +02:00
|
|
|
blackfriday.WithExtensions(renderer.GetExtensions()),
|
|
|
|
}...)
|
2021-02-01 00:10:16 +01:00
|
|
|
}
|