diff --git a/docs/changelog.txt b/docs/changelog.txt index 336dd1f..70a195d 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Lists supported in markdown. + + Rewrite admin console to avoid large dependencies. + "Bug" fixes. diff --git a/docs/honk.5 b/docs/honk.5 index 4caa697..82eb926 100644 --- a/docs/honk.5 +++ b/docs/honk.5 @@ -46,6 +46,11 @@ Inline `code fragments` with single ticks. int main() { return 0; } ``` .Ed +.It lists +Lists of items starting with either +.Sq + +or +.Sq - . .It images Inline images with img tags. .Bd -literal diff --git a/markitzero.go b/markitzero.go index 5611e50..b70c386 100644 --- a/markitzero.go +++ b/markitzero.go @@ -32,6 +32,7 @@ var re_quoter = regexp.MustCompile(`(?m:^> (.*)\n?)`) var re_link = regexp.MustCompile(`.?.?https?://[^\s"]+[\w/)!]`) var re_zerolink = regexp.MustCompile(`\[([^]]*)\]\(([^)]*\)?)\)`) var re_imgfix = regexp.MustCompile(`]*)>`) +var re_lister = regexp.MustCompile(`((^|\n)(\+|-).*)+\n?`) var lighter = synlight.New(synlight.Options{Format: synlight.HTML}) @@ -78,6 +79,17 @@ func markitzero(s string) string { s = re_italicer.ReplaceAllString(s, "$1$2$3") s = re_quoter.ReplaceAllString(s, "
$1

") + s = re_lister.ReplaceAllStringFunc(s, func(m string) string { + m = strings.Trim(m, "\n") + items := strings.Split(m, "\n") + r := "

" + return r + }) + // restore images s = strings.Replace(s, "<img x>", "", -1) s = re_imgfix.ReplaceAllStringFunc(s, func(string) string { @@ -105,6 +117,7 @@ func markitzero(s string) string { s = strings.Replace(s, "\n", "
", -1) s = strings.Replace(s, "

", "
", -1) s = strings.Replace(s, "
", "
", -1)
+	s = strings.Replace(s, "
    ", "
      ", -1) s = strings.Replace(s, "


      ", "

      ", -1) return s } diff --git a/markitzero_test.go b/markitzero_test.go index 541fc5a..6cd176b 100644 --- a/markitzero_test.go +++ b/markitzero_test.go @@ -94,3 +94,15 @@ func TestImagelink(t *testing.T) { output := `an image caption and linked ` doonezerotest(t, input, output) } + +func TestLists(t *testing.T) { + input := `hello ++ a list ++ the list + +para + +- singleton` + output := `hello

      • a list
      • the list

      para

      • singleton

      ` + doonezerotest(t, input, output) +}