This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-docs.git
The following commit(s) were added to refs/heads/master by this push:
new ee734d7 support empty links
ee734d7 is described below
commit ee734d7a1ea14bbc477ddd6b9c43e259541c564f
Author: Alex Heneveld <[email protected]>
AuthorDate: Tue Sep 7 11:49:19 2021 +0100
support empty links
[http://foo]() now correclty links to http://foo
---
_plugins/jekyll_relative_links.rb | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/_plugins/jekyll_relative_links.rb
b/_plugins/jekyll_relative_links.rb
index 9f1a427..4ed14d9 100644
--- a/_plugins/jekyll_relative_links.rb
+++ b/_plugins/jekyll_relative_links.rb
@@ -43,7 +43,7 @@ module JekyllRelativeLinks
FRAGMENT_REGEX = %r!(#.+?|)?!.freeze
TITLE_REGEX =
%r{(\s+"(?:\\"|[^"])*(?<!\\)"|\s+"(?:\\'|[^'])*(?<!\\)')?}.freeze
FRAG_AND_TITLE_REGEX = %r!#{FRAGMENT_REGEX}#{TITLE_REGEX}!.freeze
- INLINE_LINK_REGEX =
%r!\[#{LINK_TEXT_REGEX}\]\(([^\)]+?)#{FRAG_AND_TITLE_REGEX}\)!.freeze
+ INLINE_LINK_REGEX =
%r!\[#{LINK_TEXT_REGEX}\]\(([^\)]*?)#{FRAG_AND_TITLE_REGEX}\)!.freeze
REFERENCE_LINK_REGEX = %r!^\s*?\[#{LINK_TEXT_REGEX}\]:
(.+?)#{FRAG_AND_TITLE_REGEX}\s*?$!.freeze
LINK_REGEX = %r!(#{INLINE_LINK_REGEX}|#{REFERENCE_LINK_REGEX})!.freeze
CONVERTER_CLASS = Jekyll::Converters::Markdown
@@ -108,19 +108,21 @@ module JekyllRelativeLinks
content.dup.gsub(LINK_REGEX) do |original|
link = link_parts(Regexp.last_match)
+ puts "link #{link}"
if (link.path == "" && link.fragment == "" && link.text &&
link.text.start_with?("http"))
+ puts "empty link #{link}"
link.path = link.text
- return replacement_text(link)
- end
- next original unless replaceable_link?(link.path)
+ else
+ next original unless replaceable_link?(link.path)
- path = path_from_root(link.path, url_base)
- url = url_for_path(path, relative_to_path)
+ path = path_from_root(link.path, url_base)
+ url = url_for_path(path, relative_to_path)
- next original unless url
+ next original unless url
- link.path = url
+ link.path = url
+ end
replacement_text(link)
end
end