Fixed bug related newline code

This commit is contained in:
yuin 2022-09-25 23:47:23 +09:00
parent ae42b9179f
commit c71a97b837
2 changed files with 38 additions and 17 deletions

View file

@ -176,4 +176,25 @@ func TestEastAsianLineBreaks(t *testing.T) {
},
t,
)
markdown = goldmark.New(goldmark.WithRendererOptions(
html.WithXHTML(),
html.WithUnsafe(),
),
goldmark.WithExtensions(
NewCJK(WithEastAsianLineBreaks()),
Linkify,
),
)
no = 7
testutil.DoTestCase(
markdown,
testutil.MarkdownTestCase{
No: no,
Description: "WithEastAsianLineBreaks and linkfy extension",
Markdown: "太郎は\\ **「こんにちわ」**\\ と言った\r\nんです",
Expected: "<p>太郎は\\ <strong>「こんにちわ」</strong>\\ と言ったんです</p>",
},
t,
)
}

View file

@ -1178,7 +1178,7 @@ func (p *parser) parseBlock(block text.BlockReader, parent ast.Node, pc Context)
if c == '\n' {
break
}
isSpace := util.IsSpace(c)
isSpace := util.IsSpace(c) && c != '\r' && c != '\n'
isPunct := util.IsPunct(c)
if (isPunct && !escaped) || isSpace && !(escaped && p.escapedSpace) || i == 0 {
parserChar := c