From 2a86c1ea310d72f978a48de6501d35fb0c832d14 Mon Sep 17 00:00:00 2001
From: jsteuer
Date: Sun, 16 Feb 2020 17:56:09 +0100
Subject: [PATCH 1/2] allow inline links with empty link text. see #101
---
commonmark_test.go | 23 +++++++++++++++++++++++
parser/link.go | 5 -----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/commonmark_test.go b/commonmark_test.go
index e1a2d1b..bd367e0 100644
--- a/commonmark_test.go
+++ b/commonmark_test.go
@@ -42,3 +42,26 @@ func TestSpec(t *testing.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: "
",
+ },
+ testutil.MarkdownTestCase{
+ No: -1,
+ Markdown: "[]()",
+ Expected: "
",
+ },
+ }
+ markdown := New(WithRendererOptions(
+ html.WithXHTML(),
+ html.WithUnsafe(),
+ ))
+ testutil.DoTestCases(markdown, cases, t)
+}
diff --git a/parser/link.go b/parser/link.go
index 8611194..e7c6966 100644
--- a/parser/link.go
+++ b/parser/link.go
@@ -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)
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()
l, pos := block.Position()
From 3a828e641d7e3f982e2fb0753ad00f74a22b5f42 Mon Sep 17 00:00:00 2001
From: jsteuer
Date: Sun, 16 Feb 2020 18:07:23 +0100
Subject: [PATCH 2/2] move test to its correct place...
---
_test/extra.txt | 18 ++++++++++++++++++
commonmark_test.go | 23 -----------------------
2 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/_test/extra.txt b/_test/extra.txt
index c7a4be7..d500717 100644
--- a/_test/extra.txt
+++ b/_test/extra.txt
@@ -76,3 +76,21 @@ place where everything breaks")
place where everything breaks">This link won't be rendered
correctly
//= = = = = = = = = = = = = = = = = = = = = = = =//
+
+
+
+7
+//- - - - - - - - -//
+[](./target.md)
+//- - - - - - - - -//
+
+//= = = = = = = = = = = = = = = = = = = = = = = =//
+
+
+
+8
+//- - - - - - - - -//
+[]()
+//- - - - - - - - -//
+
+//= = = = = = = = = = = = = = = = = = = = = = = =//
\ No newline at end of file
diff --git a/commonmark_test.go b/commonmark_test.go
index bd367e0..e1a2d1b 100644
--- a/commonmark_test.go
+++ b/commonmark_test.go
@@ -42,26 +42,3 @@ func TestSpec(t *testing.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: "
",
- },
- testutil.MarkdownTestCase{
- No: -1,
- Markdown: "[]()",
- Expected: "
",
- },
- }
- markdown := New(WithRendererOptions(
- html.WithXHTML(),
- html.WithUnsafe(),
- ))
- testutil.DoTestCases(markdown, cases, t)
-}