Accept attributes in inline image syntax master
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 30 Mar 2009 11:15:02 +0000 (13:15 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 30 Mar 2009 11:15:02 +0000 (13:15 +0200)
The syntax ![alt](url "title" attr=val attr2=val2) is now valid

bin/MultiMarkdown.pl

index 88fd69c..4177af8 100755 (executable)
@@ -941,6 +941,11 @@ sub _DoImages {
                          \5            # matching quote
                          [ \t]*
                        )?                      # title is optional
+                       # MultiMarkdown addition for attribute support
+                       (                               # Attributes = $7
+                         (?<=\s)                       # lookbehind for whitespace
+                         (([ \t]*\n)?[ \t]*((\S+=\S+)|(\S+=".*?")))*
+                       )?
                  \)
                )
        }{
@@ -949,6 +954,7 @@ sub _DoImages {
                my $alt_text    = $2;
                my $url                 = $3;
                my $title               = (defined $6) ? $6 : '';
+               my $attrs = $7;
 
                $alt_text =~ s/"/&quot;/g;
                $title    =~ s/"/&quot;/g;
@@ -966,6 +972,9 @@ sub _DoImages {
                        $title =~ s!  _ !$g_escape_table{'_'}!gx;
                        $result .=  " title=\"$title\"";
                }
+               if (defined $attrs) {
+                       $result .= " $attrs";
+               }
                $result .= $g_empty_element_suffix;
 
                $result;