Browse Source

Markdown.pl: allow documented single-quote ref titles

The documentation claims that all of these work:

    [1]: url1.txt "title 1"
    [2]: url2.txt 'title 2'
    [3]: url3.txt (title 3)

However, the single-quote version was not being accepted.

Update the regular expression to grok the single-quote
variant and require the correct matching closing quote
in order to match.  This corrects the invalid acceptance
of mismatched quote titles such as "title) and (title".

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
master
Kyle J. McKay 5 years ago
parent
commit
505d70a6e7
  1. 8
      Markdown.pl

8
Markdown.pl

@ -551,9 +551,9 @@ sub _StripLinkDefinitions {
[ ]*
(?:
(?<=\s) # lookbehind for whitespace
["(]
(.+?) # title = $3
[")]
(?:(['"])|(\()) # title quote char
(.+?) # title = $5
(?(4)\)|\3) # match same quote
[ ]*
)? # title is optional
(?:\n+|\Z)
@ -561,7 +561,7 @@ sub _StripLinkDefinitions {
{}mx) {
my $id = _strip(lc $1); # Link IDs are case-insensitive
my $url = $2;
my $title = _strip($3);
my $title = _strip($5);
$url =~ s/\\\n\s*//gs;
if ($id ne "") {
$g_urls{$id} = _EncodeAmpsAndAngles($url);

Loading…
Cancel
Save