bradchoate / text-textile

Text::Textile -- Perl module for handling Textile format
20 stars 11 forks source link

sorry - wrong regex - created pull request with new & better solution (Do not allow spaces directly after '!' in image processing) #8

Closed serap closed 10 years ago

serap commented 10 years ago

sub format_inline { ...

# images must be processed before encoding the text since they might
# have the <, > alignment specifiers...

my $pattern = '(?<=[^!])\s*';
# !blah (alt)! -> image
$text =~ s!(?:^|(?<=[\s>])|([{[]))     # $1: open brace/bracket
           \!                          # opening
           ($imgalignre?)              # $2: optional alignment
           ($clstypadre*)              # $3: optional CSS class/id
           ($imgalignre?)              # $4: optional alignment
           ($pattern)                     # space between alignment/css stuff
           ([^\s\(\!]+)                # $5: filename
           (\s*[^\(\!]*(?:\([^\)]+\))?[^\!]*) # $6: extras (alt text)
           \!                          # closing
           (?::(\d+|$urlre))?          # $7: optional URL
           (?:$|([\]}])|(?=$punct{1,2}|\s))# $8: closing brace/bracket
          !_repl(\@repl, $self->format_image(pre => $1, src => $5, align => $2||$4, extra => $6, url => $7, clsty => $3, post => $8))!gemx;

... }