mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-30 22:34:15 -05:00
16 lines
305 B
Go
16 lines
305 B
Go
package summary
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/russross/blackfriday"
|
|
)
|
|
|
|
func Markdown(input []byte, wordcount int) []byte {
|
|
words := bytes.Fields(blackfriday.Markdown(input, Renderer{}, 0))
|
|
if wordcount > len(words) {
|
|
wordcount = len(words)
|
|
}
|
|
|
|
return bytes.Join(words[0:wordcount], []byte{' '})
|
|
}
|