diff --git a/README.md b/README.md index a5be041..089dff5 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ html := markdown.Render("# Header") PASS: TestEmpty PASS: TestParagraph PASS: TestHeader +PASS: TestItalic +PASS: TestBold PASS: TestLink PASS: TestList PASS: TestTables @@ -45,9 +47,9 @@ coverage: 100.0% of statements ## Benchmarks ``` -BenchmarkSmall-12 8846642 135.5 ns/op 32 B/op 1 allocs/op -BenchmarkMedium-12 711596 1465 ns/op 512 B/op 1 allocs/op -BenchmarkLarge-12 279253 3874 ns/op 2560 B/op 2 allocs/op +BenchmarkSmall-12 8109500 145.1 ns/op 32 B/op 1 allocs/op +BenchmarkMedium-12 556713 1906 ns/op 512 B/op 1 allocs/op +BenchmarkLarge-12 218116 4588 ns/op 2560 B/op 2 allocs/op ``` ## License diff --git a/Render.go b/Render.go index 3c03851..6679a00 100644 --- a/Render.go +++ b/Render.go @@ -122,18 +122,20 @@ func (r *renderer) processLine(line string) { return } - line = strings.TrimSpace(line[1:]) + if len(line) > 1 && line[1] == ' ' { + line = line[2:] - if r.listLevel == 0 { - r.WriteString("
italic
") + assert.Equal(t, markdown.Render("_italic_"), "italic
") +} + +func TestBold(t *testing.T) { + assert.Equal(t, markdown.Render("**bold**"), "bold
") + assert.Equal(t, markdown.Render("__bold__"), "bold
") +} + func TestLink(t *testing.T) { assert.Equal(t, markdown.Render("[text](https://example.com/)"), "") assert.Equal(t, markdown.Render("[text](https://example.com/"), "[text](https://example.com/
") @@ -42,6 +52,7 @@ func TestList(t *testing.T) { assert.Equal(t, markdown.Render("- Entry"), "-
") } func TestTables(t *testing.T) { @@ -77,6 +88,8 @@ func TestCombined(t *testing.T) { assert.Equal(t, markdown.Render("# Title\n\n- Entry 1\n- Entry 2\n\nText."), "Text.
") assert.Equal(t, markdown.Render("- Entry\n# Header"), "") + assert.Equal(t, markdown.Render("> **bold** and *italic* text."), "
- Entry
Header
") + assert.Equal(t, markdown.Render("> __bold__ and _italic_ text."), "bold and italic text.
") } func TestSecurity(t *testing.T) {bold and italic text.