2022-04-04 20:06:48 +00:00
|
|
|
package md2man
|
|
|
|
|
|
|
|
import (
|
2024-10-24 17:33:51 +00:00
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
|
2022-04-04 20:06:48 +00:00
|
|
|
"github.com/russross/blackfriday/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Render converts a markdown document into a roff formatted document.
|
|
|
|
func Render(doc []byte) []byte {
|
|
|
|
renderer := NewRoffRenderer()
|
2024-10-24 17:33:51 +00:00
|
|
|
var r blackfriday.Renderer = renderer
|
|
|
|
if v, _ := strconv.ParseBool(os.Getenv("MD2MAN_DEBUG")); v {
|
|
|
|
r = &debugDecorator{Renderer: r}
|
|
|
|
}
|
2022-04-04 20:06:48 +00:00
|
|
|
|
|
|
|
return blackfriday.Run(doc,
|
2024-06-11 16:52:57 +00:00
|
|
|
[]blackfriday.Option{
|
2024-10-24 17:33:51 +00:00
|
|
|
blackfriday.WithRenderer(r),
|
2024-06-11 16:52:57 +00:00
|
|
|
blackfriday.WithExtensions(renderer.GetExtensions()),
|
|
|
|
}...)
|
2022-04-04 20:06:48 +00:00
|
|
|
}
|