diff --git a/markitzero.go b/markitzero.go index 36a50b8..dfe263d 100644 --- a/markitzero.go +++ b/markitzero.go @@ -35,6 +35,7 @@ var re_zerolink = regexp.MustCompile(`\[([^]]*)\]\(([^)]*\)?)\)`) var re_imgfix = regexp.MustCompile(`]*)>`) var re_lister = regexp.MustCompile(`((^|\n)(\+|-).*)+\n?`) var re_tabler = regexp.MustCompile(`((^|\n)\|.*)+\n?`) +var re_header = regexp.MustCompile(`(^|\n)(#+) (.*)`) var lighter = synlight.New(synlight.Options{Format: synlight.HTML}) @@ -135,6 +136,11 @@ func markitzero(s string) string { r.WriteString("
")
return r.String()
})
+ s = re_header.ReplaceAllStringFunc(s, func(s string) string {
+ m := re_header.FindStringSubmatch(s)
+ num := len(m[2])
+ return fmt.Sprintf("
", num, m[3], num) + }) // restore images s = strings.Replace(s, "<img x>", "", -1) diff --git a/markitzero_test.go b/markitzero_test.go index 208e159..4d49ff6 100644 --- a/markitzero_test.go +++ b/markitzero_test.go @@ -120,6 +120,15 @@ para doonezerotest(t, input, output) } +func TestHeaders(t *testing.T) { + input := `hello +## fruits +Love 'em. Eat 'em. +` + output := `hello
Love 'em. Eat 'em.` + doonezerotest(t, input, output) +} + var benchData, simpleData string func init() {