mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
10 lines
291 B
Go
10 lines
291 B
Go
package utils
|
|
|
|
import "regexp"
|
|
|
|
// ExtractFrontMatter Extract markdown header information and return clean text
|
|
func ExtractFrontMatter(data []byte) ([]byte, []byte) {
|
|
re := regexp.MustCompile(`(?s)^\s*---\s*\n.*?\n\s*---\s*\n`)
|
|
return re.FindSubmatch(data)[0], re.ReplaceAll(data, nil)
|
|
}
|