From 52c995659dab6c224ce5f55b53970cfa23f60bc5 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 2 Apr 2024 19:48:35 +0200 Subject: [PATCH] Implemented text formatting --- README.md | 8 +++++--- Render.go | 50 +++++++++++++++++++++++++++++++++++++++----------- Render_test.go | 13 +++++++++++++ 3 files changed, 57 insertions(+), 14 deletions(-) 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("