mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
allow inline links with empty link text. see #101
This commit is contained in:
parent
70a5404a11
commit
2a86c1ea31
2 changed files with 23 additions and 5 deletions
|
|
@ -42,3 +42,26 @@ func TestSpec(t *testing.T) {
|
||||||
))
|
))
|
||||||
testutil.DoTestCases(markdown, cases, t)
|
testutil.DoTestCases(markdown, cases, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSpec_EdgeCase_LinkWithEmptyText(t *testing.T) {
|
||||||
|
// TODO: maybe this test cases will be part of the official spec in the future.
|
||||||
|
// check: https://github.com/commonmark/commonmark-spec/issues/636
|
||||||
|
|
||||||
|
cases := []testutil.MarkdownTestCase{
|
||||||
|
testutil.MarkdownTestCase{
|
||||||
|
No: -1,
|
||||||
|
Markdown: "[](./target.md)",
|
||||||
|
Expected: "<p><a href=\"./target.md\"></a></p>",
|
||||||
|
},
|
||||||
|
testutil.MarkdownTestCase{
|
||||||
|
No: -1,
|
||||||
|
Markdown: "[]()",
|
||||||
|
Expected: "<p><a href=\"\"></a></p>",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
markdown := New(WithRendererOptions(
|
||||||
|
html.WithXHTML(),
|
||||||
|
html.WithUnsafe(),
|
||||||
|
))
|
||||||
|
testutil.DoTestCases(markdown, cases, t)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,11 +147,6 @@ func (s *linkParser) Parse(parent ast.Node, block text.Reader, pc Context) ast.N
|
||||||
ast.MergeOrReplaceTextSegment(last.Parent(), last, last.Segment)
|
ast.MergeOrReplaceTextSegment(last.Parent(), last, last.Segment)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
labelValue := block.Value(text.NewSegment(last.Segment.Start+1, segment.Start))
|
|
||||||
if util.IsBlank(labelValue) && !last.IsImage {
|
|
||||||
ast.MergeOrReplaceTextSegment(last.Parent(), last, last.Segment)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
c := block.Peek()
|
c := block.Peek()
|
||||||
l, pos := block.Position()
|
l, pos := block.Position()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue