From 1679f12690e1712f65e8ab51d9e38364e58eede6 Mon Sep 17 00:00:00 2001 From: Marcel Amirault Date: Wed, 18 Mar 2020 16:17:37 +0900 Subject: [PATCH 1/3] Enable multi-line links The markdown standard allows for link text split over multiple lines. This expands the link regex to enable this. --- lib/rouge/lexers/markdown.rb | 2 +- spec/visual/samples/markdown | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/markdown.rb b/lib/rouge/lexers/markdown.rb index a0e5fd0176..ef8f507b2c 100644 --- a/lib/rouge/lexers/markdown.rb +++ b/lib/rouge/lexers/markdown.rb @@ -102,7 +102,7 @@ def html end # links and images - rule %r/(!?\[)(#{edot}*?)(\])(?=[\[(])/ do + rule %r/(!?\[)(#{edot}*?|[^\]]*?)(\])(?=( ?\[|\())/ do groups Punctuation, Name::Variable, Punctuation push :link end diff --git a/spec/visual/samples/markdown b/spec/visual/samples/markdown index 42f992e900..3243d11081 100644 --- a/spec/visual/samples/markdown +++ b/spec/visual/samples/markdown @@ -1091,3 +1091,14 @@ $ echo "Sample feature output" [This is a link to a TOML section `[with brackets]` (and backticks)](example.com) [This is a link to a TOML section `[[with double brackets]]` (and backticks)](example.com) [This is not a link `with backticks`] (example.com) + +This link has text before it, [it's over two (lines), +has (parens too)](example.com), and text after it. + +[this is not a +link] + +[this is a link +split over two lines] [link ref] + +[link ref]: example.com From 3be137ec3b4e5d3da9e2ca91673214cdfe1614d0 Mon Sep 17 00:00:00 2001 From: Marcel Amirault Date: Wed, 25 Mar 2020 14:00:01 +0900 Subject: [PATCH 2/3] Don't allow a space in links anymore --- lib/rouge/lexers/markdown.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rouge/lexers/markdown.rb b/lib/rouge/lexers/markdown.rb index ef8f507b2c..d9e368a14e 100644 --- a/lib/rouge/lexers/markdown.rb +++ b/lib/rouge/lexers/markdown.rb @@ -102,7 +102,7 @@ def html end # links and images - rule %r/(!?\[)(#{edot}*?|[^\]]*?)(\])(?=( ?\[|\())/ do + rule %r/(!?\[)(#{edot}*?|[^\]]*?)(\])(?=[\[(])/ do groups Punctuation, Name::Variable, Punctuation push :link end From c3d94f75e0f46648dab59cc24458ead66433a72e Mon Sep 17 00:00:00 2001 From: Marcel Amirault Date: Wed, 25 Mar 2020 14:03:08 +0900 Subject: [PATCH 3/3] Remove unneeded example from markdown sample --- spec/visual/samples/markdown | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/visual/samples/markdown b/spec/visual/samples/markdown index 3243d11081..be2a700002 100644 --- a/spec/visual/samples/markdown +++ b/spec/visual/samples/markdown @@ -1097,8 +1097,3 @@ has (parens too)](example.com), and text after it. [this is not a link] - -[this is a link -split over two lines] [link ref] - -[link ref]: example.com