| @@ 635-689 (lines=55) @@ | ||
| 632 | } |
|
| 633 | ||
| 634 | ||
| 635 | protected function doImages($text) { |
|
| 636 | # |
|
| 637 | # Turn Markdown image shortcuts into <img> tags. |
|
| 638 | # |
|
| 639 | # |
|
| 640 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 641 | # |
|
| 642 | $text = preg_replace_callback('{ |
|
| 643 | ( # wrap whole match in $1 |
|
| 644 | !\[ |
|
| 645 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 646 | \] |
|
| 647 | ||
| 648 | [ ]? # one optional space |
|
| 649 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 650 | ||
| 651 | \[ |
|
| 652 | (.*?) # id = $3 |
|
| 653 | \] |
|
| 654 | ||
| 655 | ) |
|
| 656 | }xs', |
|
| 657 | array(&$this, '_doImages_reference_callback'), $text); |
|
| 658 | ||
| 659 | # |
|
| 660 | # Next, handle inline images:  |
|
| 661 | # Don't forget: encode * and _ |
|
| 662 | # |
|
| 663 | $text = preg_replace_callback('{ |
|
| 664 | ( # wrap whole match in $1 |
|
| 665 | !\[ |
|
| 666 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 667 | \] |
|
| 668 | \s? # One optional whitespace character |
|
| 669 | \( # literal paren |
|
| 670 | [ \n]* |
|
| 671 | (?: |
|
| 672 | <(\S*)> # src url = $3 |
|
| 673 | | |
|
| 674 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 675 | ) |
|
| 676 | [ \n]* |
|
| 677 | ( # $5 |
|
| 678 | ([\'"]) # quote char = $6 |
|
| 679 | (.*?) # title = $7 |
|
| 680 | \6 # matching quote |
|
| 681 | [ \n]* |
|
| 682 | )? # title is optional |
|
| 683 | \) |
|
| 684 | ) |
|
| 685 | }xs', |
|
| 686 | array(&$this, '_doImages_inline_callback'), $text); |
|
| 687 | ||
| 688 | return $text; |
|
| 689 | } |
|
| 690 | protected function _doImages_reference_callback($matches) { |
|
| 691 | $whole_match = $matches[1]; |
|
| 692 | $alt_text = $matches[2]; |
|
| @@ 2337-2392 (lines=56) @@ | ||
| 2334 | } |
|
| 2335 | ||
| 2336 | ||
| 2337 | protected function doImages($text) { |
|
| 2338 | # |
|
| 2339 | # Turn Markdown image shortcuts into <img> tags. |
|
| 2340 | # |
|
| 2341 | # |
|
| 2342 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 2343 | # |
|
| 2344 | $text = preg_replace_callback('{ |
|
| 2345 | ( # wrap whole match in $1 |
|
| 2346 | !\[ |
|
| 2347 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 2348 | \] |
|
| 2349 | ||
| 2350 | [ ]? # one optional space |
|
| 2351 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 2352 | ||
| 2353 | \[ |
|
| 2354 | (.*?) # id = $3 |
|
| 2355 | \] |
|
| 2356 | ||
| 2357 | ) |
|
| 2358 | }xs', |
|
| 2359 | array(&$this, '_doImages_reference_callback'), $text); |
|
| 2360 | ||
| 2361 | # |
|
| 2362 | # Next, handle inline images:  |
|
| 2363 | # Don't forget: encode * and _ |
|
| 2364 | # |
|
| 2365 | $text = preg_replace_callback('{ |
|
| 2366 | ( # wrap whole match in $1 |
|
| 2367 | !\[ |
|
| 2368 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 2369 | \] |
|
| 2370 | \s? # One optional whitespace character |
|
| 2371 | \( # literal paren |
|
| 2372 | [ \n]* |
|
| 2373 | (?: |
|
| 2374 | <(\S*)> # src url = $3 |
|
| 2375 | | |
|
| 2376 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 2377 | ) |
|
| 2378 | [ \n]* |
|
| 2379 | ( # $5 |
|
| 2380 | ([\'"]) # quote char = $6 |
|
| 2381 | (.*?) # title = $7 |
|
| 2382 | \6 # matching quote |
|
| 2383 | [ \n]* |
|
| 2384 | )? # title is optional |
|
| 2385 | \) |
|
| 2386 | (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes |
|
| 2387 | ) |
|
| 2388 | }xs', |
|
| 2389 | array(&$this, '_doImages_inline_callback'), $text); |
|
| 2390 | ||
| 2391 | return $text; |
|
| 2392 | } |
|
| 2393 | protected function _doImages_reference_callback($matches) { |
|
| 2394 | $whole_match = $matches[1]; |
|
| 2395 | $alt_text = $matches[2]; |
|