mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-03 13:52:33 +00:00
Add flag for removing leading H1 heading in markdown; fixes #35
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user