Modifying PHP markdown editor -


i want change how php markdown port creates images:

function doimages($text) { # # turn markdown image shortcuts <img> tags. #     #     # first, handle reference-style labeled images: ![alt text][id]     #     $text = preg_replace_callback('{         (               # wrap whole match in $1           !\[             ('.$this->nested_brackets_re.')     # alt text = $2           \]            [ ]?              # 1 optional space           (?:\n[ ]*)?       # 1 optional newline followed spaces            \[             (.*?)       # id = $3           \]          )         }xs',          array(&$this, '_doimages_reference_callback'), $text);      #     # next, handle inline images:  ![alt text](url "optional title")     # don't forget: encode * , _     #     $text = preg_replace_callback('{         (               # wrap whole match in $1           !\[             ('.$this->nested_brackets_re.')     # alt text = $2           \]           \s?           # 1 optional whitespace character           \(            # literal paren             [ \n]*             (?:                 <(\s*)> # src url = $3             |                 ('.$this->nested_url_parenthesis_re.')  # src url = $4             )             [ \n]*             (           # $5               ([\'"])   # quote char = $6               (.*?)     # title = $7               \6        # matching quote               [ \n]*             )?          # title optional           \)         )         }xs',         array(&$this, '_doimages_inline_callback'), $text);      return $text; } 

i know it's ![alt](image), but, believe [alt] , (image) unnecessary complication*. simple !http://imageuri, , optional alt.

so !http://image [optional alt], or ![optional alt]http://imageuri

i've tried following regex in kiki, no avail:

(   !(?:\n[  ]*)? \[(.*?)\]    ) 

edit:

it's been pointed out should signal link ends:

!link![alt]

this '!(.*?)!' finds !link!, how find optional alt?

(my sister didn't see point of alt, 'well if don't want include alt?...')


Comments