mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fixed bug related newline code
This commit is contained in:
parent
ae42b9179f
commit
c71a97b837
2 changed files with 38 additions and 17 deletions
|
|
@ -176,4 +176,25 @@ func TestEastAsianLineBreaks(t *testing.T) {
|
||||||
},
|
},
|
||||||
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,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -567,16 +567,16 @@ type ASTTransformer interface {
|
||||||
// DefaultBlockParsers returns a new list of default BlockParsers.
|
// DefaultBlockParsers returns a new list of default BlockParsers.
|
||||||
// Priorities of default BlockParsers are:
|
// Priorities of default BlockParsers are:
|
||||||
//
|
//
|
||||||
// SetextHeadingParser, 100
|
// SetextHeadingParser, 100
|
||||||
// ThematicBreakParser, 200
|
// ThematicBreakParser, 200
|
||||||
// ListParser, 300
|
// ListParser, 300
|
||||||
// ListItemParser, 400
|
// ListItemParser, 400
|
||||||
// CodeBlockParser, 500
|
// CodeBlockParser, 500
|
||||||
// ATXHeadingParser, 600
|
// ATXHeadingParser, 600
|
||||||
// FencedCodeBlockParser, 700
|
// FencedCodeBlockParser, 700
|
||||||
// BlockquoteParser, 800
|
// BlockquoteParser, 800
|
||||||
// HTMLBlockParser, 900
|
// HTMLBlockParser, 900
|
||||||
// ParagraphParser, 1000
|
// ParagraphParser, 1000
|
||||||
func DefaultBlockParsers() []util.PrioritizedValue {
|
func DefaultBlockParsers() []util.PrioritizedValue {
|
||||||
return []util.PrioritizedValue{
|
return []util.PrioritizedValue{
|
||||||
util.Prioritized(NewSetextHeadingParser(), 100),
|
util.Prioritized(NewSetextHeadingParser(), 100),
|
||||||
|
|
@ -595,11 +595,11 @@ func DefaultBlockParsers() []util.PrioritizedValue {
|
||||||
// DefaultInlineParsers returns a new list of default InlineParsers.
|
// DefaultInlineParsers returns a new list of default InlineParsers.
|
||||||
// Priorities of default InlineParsers are:
|
// Priorities of default InlineParsers are:
|
||||||
//
|
//
|
||||||
// CodeSpanParser, 100
|
// CodeSpanParser, 100
|
||||||
// LinkParser, 200
|
// LinkParser, 200
|
||||||
// AutoLinkParser, 300
|
// AutoLinkParser, 300
|
||||||
// RawHTMLParser, 400
|
// RawHTMLParser, 400
|
||||||
// EmphasisParser, 500
|
// EmphasisParser, 500
|
||||||
func DefaultInlineParsers() []util.PrioritizedValue {
|
func DefaultInlineParsers() []util.PrioritizedValue {
|
||||||
return []util.PrioritizedValue{
|
return []util.PrioritizedValue{
|
||||||
util.Prioritized(NewCodeSpanParser(), 100),
|
util.Prioritized(NewCodeSpanParser(), 100),
|
||||||
|
|
@ -613,7 +613,7 @@ func DefaultInlineParsers() []util.PrioritizedValue {
|
||||||
// DefaultParagraphTransformers returns a new list of default ParagraphTransformers.
|
// DefaultParagraphTransformers returns a new list of default ParagraphTransformers.
|
||||||
// Priorities of default ParagraphTransformers are:
|
// Priorities of default ParagraphTransformers are:
|
||||||
//
|
//
|
||||||
// LinkReferenceParagraphTransformer, 100
|
// LinkReferenceParagraphTransformer, 100
|
||||||
func DefaultParagraphTransformers() []util.PrioritizedValue {
|
func DefaultParagraphTransformers() []util.PrioritizedValue {
|
||||||
return []util.PrioritizedValue{
|
return []util.PrioritizedValue{
|
||||||
util.Prioritized(LinkReferenceParagraphTransformer, 100),
|
util.Prioritized(LinkReferenceParagraphTransformer, 100),
|
||||||
|
|
@ -1178,7 +1178,7 @@ func (p *parser) parseBlock(block text.BlockReader, parent ast.Node, pc Context)
|
||||||
if c == '\n' {
|
if c == '\n' {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
isSpace := util.IsSpace(c)
|
isSpace := util.IsSpace(c) && c != '\r' && c != '\n'
|
||||||
isPunct := util.IsPunct(c)
|
isPunct := util.IsPunct(c)
|
||||||
if (isPunct && !escaped) || isSpace && !(escaped && p.escapedSpace) || i == 0 {
|
if (isPunct && !escaped) || isSpace && !(escaped && p.escapedSpace) || i == 0 {
|
||||||
parserChar := c
|
parserChar := c
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue