You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
tells that there is an autoreplacement of https?|ftp URLs which is a nice feature. I stumpled upon the implementation as I tried to extend URL replacement in comments in os-autoinst/openQA#490 where I assumed Perl::Markdown does not have this feature at all.
current behavior
Researching code I found out that it actually does but only if the URL is surrounded by '<>' which was unexpected. IIUC standard markdown does not foresee URL auto-replacement for http/https/ftp, see http://daringfireball.net/projects/markdown/syntax
expected behavior
EITHER: no replacement
OR: replacement of all http[s]?|ftp references without the '<>' in all cases where it stands free and is not already part of a HTML block (or verbatim block, of course)
OR: support the common [link](url) syntax
suggestion
Replace $text =~ s{<((https?|ftp):[^'">\s]+)>}{<a href="$1">$1</a>}gi;
by $text =~ s{(?<!['"(])((http[s]?|ftp)://[^\s]*)}{<a href="$1">$1</a>}gi;
using "negative look-behind" to not match within quotes or html-hrefs or as part of a markdown link (using []() syntax)
matching also references without '<>'
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
observation
text-markdown/lib/Text/Markdown.pm
Line 1454 in 41a21be
os-autoinst/openQA#490 where I assumed Perl::Markdown does not have this feature at all.
current behavior
Researching code I found out that it actually does but only if the URL is surrounded by '<>' which was unexpected. IIUC standard markdown does not foresee URL auto-replacement for http/https/ftp, see http://daringfireball.net/projects/markdown/syntax
expected behavior
[link](url)
syntaxsuggestion
Replace
$text =~ s{<((https?|ftp):[^'">\s]+)>}{<a href="$1">$1</a>}gi;
by
$text =~ s{(?<!['"(])((http[s]?|ftp)://[^\s]*)}{<a href="$1">$1</a>}gi;
[]()
syntax)The text was updated successfully, but these errors were encountered: