diff --git a/Markdown.pl b/Markdown.pl index d457813..ddfb2bc 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -539,7 +539,7 @@ sub _StripLinkDefinitions { [ ]* \n? # maybe *one* newline [ ]* - ? # url = $2 + ? # url = $2 [ ]* \n? # maybe one newline [ ]* @@ -556,6 +556,7 @@ sub _StripLinkDefinitions { my $id = _strip(lc $1); # Link IDs are case-insensitive my $url = $2; my $title = _strip($3); + $url =~ s/\\\n\s*//gs; if ($id ne "") { $g_urls{$id} = _EncodeAmpsAndAngles($url); if (defined($title) && $title ne "") { @@ -2258,7 +2259,7 @@ sub _PrefixURL { $url =~ m,^//, || $url =~ /^[A-Za-z][A-Za-z0-9+.-]*:/; my $ans = $opt{url_prefix}; $ans = $opt{img_prefix} - if $opt{img_prefix} ne '' && $url =~ m"^[^#]*\.(?:png|gif|jpe?g|svgz?)(?:#|$)"i; + if $opt{img_prefix} ne '' && $url =~ m"^[^#?]*\.(?:png|gif|jpe?g|svgz?)(?:[#?]|$)"i; return $url unless $ans ne ''; $ans .= '/' if substr($ans, -1, 1) ne '/'; $ans .= substr($url, 0, 1) eq '/' ? substr($url, 1) : $url; diff --git a/syntax.md b/syntax.md index d1bdf26..48ae4bb 100644 --- a/syntax.md +++ b/syntax.md @@ -1096,6 +1096,37 @@ The first dimension sets the "width" attribute and the second dimension sets the "height" attribute. The dimensions are then removed from the "title" attribute. +It's possible to wrap the url when it's specified in a reference. +Both of these examples: + + [id]: url/\ + t\ + o/image + "Optional title" + + [id]: url/to/image "Optional title" + +Produce identical "img" tags. Only the url can be wrapped and +only when it's in a reference. The backslash ("\") must be the +last character on the line and the next line (after optional +ignored leading whitespace) must contain at least one additional +character that's part of the URL. + +This can be useful for data: urls like so: + + ![image][1] + + [1]: data:image/gif;base64,R0lGODlhFwAXAPMAMf///+7u7t3d3czMzLu7u6qqqp\ + mZmYiIiHd3d2ZmZlVVVURERDMzMyIiIhEREQAAACwAAAAAFwAXAAAExxDISau9Mg\ + She8DURhhHWRLDB26FkSjKqxxFqlbBWOwF4fOGgsCycRkInI+ocEAQNBNWq0caCJ\ + i9aSqqGwwIL4MAsRATeMMMEykYHBLIt7DNHETrAPrBihVwDAh2ansBXygaAj5sa1\ + x7iTUAKomEBU53B0hGVoVMTleEg0hkCD0DJAhwAlVcQT6nLwgHR1liUQNaqgkMDT\ + NWXWkSbS6lZ0eKTUIWuTSbGzlNlkS3LSYksjtPK6YJCzEwNMAgbT9nKBwg6Onq6B\ + EAOw== "title (100x100)" + +Thus allowing small amounts of image data to be embedded directly in the +source "text" file with minimal fuss. + - - - - -