Implemented separators
This commit is contained in:
parent
4a4b9e168b
commit
a06f513d65
@ -10,6 +10,7 @@ A markdown renderer that supports only a subset of the CommonMark spec in order
|
|||||||
- Headers
|
- Headers
|
||||||
- Paragraphs
|
- Paragraphs
|
||||||
- Quotes
|
- Quotes
|
||||||
|
- Separators
|
||||||
- Tables
|
- Tables
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -35,6 +36,7 @@ PASS: TestList
|
|||||||
PASS: TestTables
|
PASS: TestTables
|
||||||
PASS: TestCode
|
PASS: TestCode
|
||||||
PASS: TestQuote
|
PASS: TestQuote
|
||||||
|
PASS: TestSeparator
|
||||||
PASS: TestCombined
|
PASS: TestCombined
|
||||||
PASS: TestSecurity
|
PASS: TestSecurity
|
||||||
coverage: 100.0% of statements
|
coverage: 100.0% of statements
|
||||||
|
@ -117,6 +117,11 @@ func (r *renderer) processLine(line string) {
|
|||||||
return
|
return
|
||||||
|
|
||||||
case '-', '*':
|
case '-', '*':
|
||||||
|
if strings.HasPrefix(line, "---") {
|
||||||
|
r.WriteString("<hr>")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
line = strings.TrimSpace(line[1:])
|
line = strings.TrimSpace(line[1:])
|
||||||
|
|
||||||
if r.listLevel == 0 {
|
if r.listLevel == 0 {
|
||||||
|
@ -64,6 +64,11 @@ func TestQuote(t *testing.T) {
|
|||||||
assert.Equal(t, markdown.Render("Line 1\n> Line 2\n> Line 3\nLine 4"), "<p>Line 1</p><blockquote><p>Line 2 Line 3</p></blockquote><p>Line 4</p>")
|
assert.Equal(t, markdown.Render("Line 1\n> Line 2\n> Line 3\nLine 4"), "<p>Line 1</p><blockquote><p>Line 2 Line 3</p></blockquote><p>Line 4</p>")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSeparator(t *testing.T) {
|
||||||
|
assert.Equal(t, markdown.Render("---"), "<hr>")
|
||||||
|
assert.Equal(t, markdown.Render("Line 1\n\n---\n\nLine 2"), "<p>Line 1</p><hr><p>Line 2</p>")
|
||||||
|
}
|
||||||
|
|
||||||
func TestCombined(t *testing.T) {
|
func TestCombined(t *testing.T) {
|
||||||
assert.Equal(t, markdown.Render("# Header\n\nLine 1."), "<h1>Header</h1><p>Line 1.</p>")
|
assert.Equal(t, markdown.Render("# Header\n\nLine 1."), "<h1>Header</h1><p>Line 1.</p>")
|
||||||
assert.Equal(t, markdown.Render("# Header\nLine 1.\nLine 2.\nLine 3."), "<h1>Header</h1><p>Line 1. Line 2. Line 3.</p>")
|
assert.Equal(t, markdown.Render("# Header\nLine 1.\nLine 2.\nLine 3."), "<h1>Header</h1><p>Line 1. Line 2. Line 3.</p>")
|
||||||
|
Loading…
Reference in New Issue
Block a user