| @@ 812-866 (lines=55) @@ | ||
| 809 | } |
|
| 810 | ||
| 811 | ||
| 812 | function doImages($text) { |
|
| 813 | # |
|
| 814 | # Turn Markdown image shortcuts into <img> tags. |
|
| 815 | # |
|
| 816 | # |
|
| 817 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 818 | # |
|
| 819 | $text = preg_replace_callback('{ |
|
| 820 | ( # wrap whole match in $1 |
|
| 821 | !\[ |
|
| 822 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 823 | \] |
|
| 824 | ||
| 825 | [ ]? # one optional space |
|
| 826 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 827 | ||
| 828 | \[ |
|
| 829 | (.*?) # id = $3 |
|
| 830 | \] |
|
| 831 | ||
| 832 | ) |
|
| 833 | }xs', |
|
| 834 | array(&$this, '_doImages_reference_callback'), $text); |
|
| 835 | ||
| 836 | # |
|
| 837 | # Next, handle inline images:  |
|
| 838 | # Don't forget: encode * and _ |
|
| 839 | # |
|
| 840 | $text = preg_replace_callback('{ |
|
| 841 | ( # wrap whole match in $1 |
|
| 842 | !\[ |
|
| 843 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 844 | \] |
|
| 845 | \s? # One optional whitespace character |
|
| 846 | \( # literal paren |
|
| 847 | [ \n]* |
|
| 848 | (?: |
|
| 849 | <(\S*)> # src url = $3 |
|
| 850 | | |
|
| 851 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 852 | ) |
|
| 853 | [ \n]* |
|
| 854 | ( # $5 |
|
| 855 | ([\'"]) # quote char = $6 |
|
| 856 | (.*?) # title = $7 |
|
| 857 | \6 # matching quote |
|
| 858 | [ \n]* |
|
| 859 | )? # title is optional |
|
| 860 | \) |
|
| 861 | ) |
|
| 862 | }xs', |
|
| 863 | array(&$this, '_doImages_inline_callback'), $text); |
|
| 864 | ||
| 865 | return $text; |
|
| 866 | } |
|
| 867 | function _doImages_reference_callback($matches) { |
|
| 868 | $whole_match = $matches[1]; |
|
| 869 | $alt_text = $matches[2]; |
|
| @@ 2501-2556 (lines=56) @@ | ||
| 2498 | } |
|
| 2499 | ||
| 2500 | ||
| 2501 | function doImages($text) { |
|
| 2502 | # |
|
| 2503 | # Turn Markdown image shortcuts into <img> tags. |
|
| 2504 | # |
|
| 2505 | # |
|
| 2506 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 2507 | # |
|
| 2508 | $text = preg_replace_callback('{ |
|
| 2509 | ( # wrap whole match in $1 |
|
| 2510 | !\[ |
|
| 2511 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 2512 | \] |
|
| 2513 | ||
| 2514 | [ ]? # one optional space |
|
| 2515 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 2516 | ||
| 2517 | \[ |
|
| 2518 | (.*?) # id = $3 |
|
| 2519 | \] |
|
| 2520 | ||
| 2521 | ) |
|
| 2522 | }xs', |
|
| 2523 | array(&$this, '_doImages_reference_callback'), $text); |
|
| 2524 | ||
| 2525 | # |
|
| 2526 | # Next, handle inline images:  |
|
| 2527 | # Don't forget: encode * and _ |
|
| 2528 | # |
|
| 2529 | $text = preg_replace_callback('{ |
|
| 2530 | ( # wrap whole match in $1 |
|
| 2531 | !\[ |
|
| 2532 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 2533 | \] |
|
| 2534 | \s? # One optional whitespace character |
|
| 2535 | \( # literal paren |
|
| 2536 | [ \n]* |
|
| 2537 | (?: |
|
| 2538 | <(\S*)> # src url = $3 |
|
| 2539 | | |
|
| 2540 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 2541 | ) |
|
| 2542 | [ \n]* |
|
| 2543 | ( # $5 |
|
| 2544 | ([\'"]) # quote char = $6 |
|
| 2545 | (.*?) # title = $7 |
|
| 2546 | \6 # matching quote |
|
| 2547 | [ \n]* |
|
| 2548 | )? # title is optional |
|
| 2549 | \) |
|
| 2550 | (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes |
|
| 2551 | ) |
|
| 2552 | }xs', |
|
| 2553 | array(&$this, '_doImages_inline_callback'), $text); |
|
| 2554 | ||
| 2555 | return $text; |
|
| 2556 | } |
|
| 2557 | function _doImages_reference_callback($matches) { |
|
| 2558 | $whole_match = $matches[1]; |
|
| 2559 | $alt_text = $matches[2]; |
|