Add flag for removing leading H1 heading in markdown; fixes #35

This commit is contained in:
Luke Fritz
2020-11-16 23:50:25 -06:00
parent 94707f13b0
commit 9c9c6a0ccd
2 changed files with 17 additions and 0 deletions

View File

@@ -90,3 +90,13 @@ func CompileMarkdown(
return string(html)
}
// dropH1Markdown will drop leading H1 headings to prevent
// duplication of or conflict with page titles.
func DropH1Markdown(
markdown []byte,
) []byte {
h1 := regexp.MustCompile(`^#[^#].*\n`)
markdown = h1.ReplaceAll(markdown, []byte(""))
return markdown
}