Skip to content

Commit e40d875

Browse files
render <br/> directly as hard-line-break
1 parent 5493558 commit e40d875

8 files changed

Lines changed: 58 additions & 18 deletions

File tree

plugin/commonmark/commonmark_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func TestOptionFunc(t *testing.T) {
152152
commonmark.WithHeadingStyle("setext"),
153153
},
154154
input: `<h1>important<br/>heading</h1>`,
155-
expected: "important\n\\\nheading\n=========",
155+
expected: "important\nheading\n=========",
156156
},
157157

158158
// - - - - - - - - - - Link - - - - - - - - - - //

plugin/commonmark/render_break.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package commonmark
22

33
import (
44
"github.com/JohannesKaufmann/html-to-markdown/v2/converter"
5-
"github.com/JohannesKaufmann/html-to-markdown/v2/marker"
65
"golang.org/x/net/html"
76
)
87

98
func (c *commonmark) renderBreak(_ converter.Context, w converter.Writer, _ *html.Node) converter.RenderStatus {
10-
w.Write(marker.BytesMarkerLineBreak)
11-
w.Write(marker.BytesMarkerLineBreak)
9+
// w.Write(marker.BytesMarkerLineBreak)
10+
// w.Write(marker.BytesMarkerLineBreak)
11+
// w.WriteString("\n")
12+
13+
w.WriteString(" \n")
1214
return converter.RenderSuccess
1315
}

plugin/commonmark/testdata/GoldenFiles/blockquote.out.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
<!--with one break-->
88

99
> Line A
10-
Line B
10+
> Line B
1111
1212
<!--with multiple breaks-->
1313

1414
> Start Line
1515
>
16+
>
17+
>
18+
>
19+
>
20+
>
21+
>
22+
>
1623
> End Line
1724
1825
<!--large blockquote-->

plugin/commonmark/testdata/GoldenFiles/heading.out.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,14 @@ not title
105105
* * *
106106

107107
> [**Heading 2**
108-
> \
109108
> **Heading 5**](/page.html)
110109
111110
* * *
112111

113112
> [**Heading 2**
114113
> \
115114
> Description Line 1
116-
> \
117115
> Description Line 2
118-
> \
119116
> Description Line 3
120117
> \
121118
> "Some quote"](/page.html)

plugin/commonmark/testdata/GoldenFiles/image.out.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
<!--image inside a link-->
7878

79-
[![image alt text](/image.jpg "image title text")](/page.html "link title text")
79+
[![image alt text](/image.jpg "image title text")](/page.html "link title text")
8080

8181
<!--image inside an empty link-->
8282

plugin/commonmark/testdata/GoldenFiles/link.out.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,39 @@ before [content](/) after
143143

144144
[Start Line
145145
\
146+
\
147+
\
148+
\
149+
\
150+
\
151+
\
152+
\
146153
End Line](/)
147154

148155
<!--newlines inside link-->
149156

157+
158+
159+
160+
150161
[newlines around the link content](/)
151162

163+
164+
165+
166+
152167
<!--multiline link inside a list item-->
153168

154169
- [first text
170+
\
171+
\
172+
\
173+
\
174+
\
175+
\
176+
\
177+
\
178+
\
155179
\
156180
second text](/)
157181

@@ -170,8 +194,7 @@ second text](/page.html)
170194
<!--link with headings-->
171195

172196
[**Heading A**
173-
\
174-
**Heading B**](/page.html)
197+
**Heading B**](/page.html)
175198

176199
<!--link with an svg-->
177200

plugin/commonmark/testdata/GoldenFiles/list.out.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ A paragraph
1111
- - 5.1
1212

1313
5 After
14-
- 6 Before
15-
14+
- 6 Before
1615
6 also Before
1716

1817
- 6A.1
@@ -56,9 +55,8 @@ List Item without Container
5655

5756
<!-- list with blockquote that contains break -->
5857

59-
1. > Line A
60-
61-
Line B
58+
1. > Line A
59+
> Line B
6260
6361
* * *
6462

@@ -118,6 +116,8 @@ text between
118116

119117
<!--THE END-->
120118

119+
120+
121121
- List 7
122122

123123
* * *
@@ -136,6 +136,13 @@ text between
136136

137137
- Start Line
138138

139+
140+
141+
142+
143+
144+
145+
139146
End Line
140147

141148
<!--------------------------------------

plugin/commonmark/testdata/GoldenFiles/metadata.out.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ A &amp; B
2424
\[foo]: /url "not a reference"
2525
&amp;ouml; not a character entity
2626

27-
Start Line
28-
27+
Start Line
28+
29+
30+
31+
32+
2933
End Line

0 commit comments

Comments
 (0)