diff --git a/README.md b/README.md index 62900f1..4c65a88 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,9 @@ coverage: 100.0% of statements ## Benchmarks ``` -BenchmarkSmall-12 5933677 190.8 ns/op 32 B/op 1 allocs/op -BenchmarkMedium-12 971929 1085 ns/op 512 B/op 1 allocs/op -BenchmarkLarge-12 277028 4075 ns/op 2560 B/op 2 allocs/op +BenchmarkSmall-12 5836533 205.3 ns/op 32 B/op 1 allocs/op +BenchmarkMedium-12 967740 1103 ns/op 512 B/op 1 allocs/op +BenchmarkLarge-12 277908 4099 ns/op 2560 B/op 2 allocs/op ``` ## License diff --git a/Render.go b/Render.go index 148bf9a..eeae870 100644 --- a/Render.go +++ b/Render.go @@ -17,6 +17,7 @@ type renderer struct { paragraphLevel int quoteLevel int listLevel int + olistLevel int tableLevel int codeLines int tableHeaderWritten bool @@ -200,6 +201,26 @@ func (r *renderer) processLine(line string) { } } + pos := 0 + + for pos < len(line) && line[pos] >= '0' && line[pos] <= '9' { + pos++ + + if pos < len(line) && (line[pos] == '.' || line[pos] == ')') { + line = strings.TrimSpace(line[pos+1:]) + + if r.olistLevel == 0 { + r.WriteString("
") r.paragraphLevel++ @@ -233,7 +254,12 @@ func (r *renderer) closeLists() { r.WriteString("") } + for range r.olistLevel { + r.WriteString("
-
") + assert.Equal(t, markdown.Render("- "), "-
") +} + +func TestOrderedList(t *testing.T) { + assert.Equal(t, markdown.Render("1"), "1
") + assert.Equal(t, markdown.Render("1."), "