diff --git a/extension/cjk.go b/extension/cjk.go index 60e07ff..cb6f955 100644 --- a/extension/cjk.go +++ b/extension/cjk.go @@ -2,6 +2,7 @@ package extension import ( "github.com/yuin/goldmark" + "github.com/yuin/goldmark/parser" "github.com/yuin/goldmark/renderer/html" ) @@ -45,5 +46,6 @@ func (e *cjk) Extend(m goldmark.Markdown) { } if e.EscapedSpace { m.Renderer().AddOptions(html.WithWriter(html.NewWriter(html.WithEscapedSpace()))) + m.Parser().AddOptions(parser.WithEscapedSpace()) } } diff --git a/extension/cjk_test.go b/extension/cjk_test.go index 8863a10..1903ff1 100644 --- a/extension/cjk_test.go +++ b/extension/cjk_test.go @@ -56,6 +56,31 @@ func TestEscapedSpace(t *testing.T) { }, t, ) + + // ' ' triggers Linkify extension inline parser. + // Escaped spaces should not trigger the inline parser. + + markdown = goldmark.New(goldmark.WithRendererOptions( + html.WithXHTML(), + html.WithUnsafe(), + ), + goldmark.WithExtensions( + NewCJK(WithEscapedSpace()), + Linkify, + ), + ) + + no = 4 + testutil.DoTestCase( + markdown, + testutil.MarkdownTestCase{ + No: no, + Description: "Escaped space and linkfy extension", + Markdown: "太郎は\\ **「こんにちわ」**\\ と言った\nんです", + Expected: "
太郎は「こんにちわ」と言った\nんです
", + }, + t, + ) } func TestEastAsianLineBreaks(t *testing.T) { diff --git a/parser/parser.go b/parser/parser.go index bac0704..f41e8a2 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -430,6 +430,7 @@ type Config struct { InlineParsers util.PrioritizedSlice /*