| @@ 659-713 (lines=55) @@ | ||
| 656 | } |
|
| 657 | ||
| 658 | ||
| 659 | protected function doImages($text) { |
|
| 660 | # |
|
| 661 | # Turn Markdown image shortcuts into <img> tags. |
|
| 662 | # |
|
| 663 | # |
|
| 664 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 665 | # |
|
| 666 | $text = preg_replace_callback('{ |
|
| 667 | ( # wrap whole match in $1 |
|
| 668 | !\[ |
|
| 669 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 670 | \] |
|
| 671 | ||
| 672 | [ ]? # one optional space |
|
| 673 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 674 | ||
| 675 | \[ |
|
| 676 | (.*?) # id = $3 |
|
| 677 | \] |
|
| 678 | ||
| 679 | ) |
|
| 680 | }xs', |
|
| 681 | array($this, '_doImages_reference_callback'), $text); |
|
| 682 | ||
| 683 | # |
|
| 684 | # Next, handle inline images:  |
|
| 685 | # Don't forget: encode * and _ |
|
| 686 | # |
|
| 687 | $text = preg_replace_callback('{ |
|
| 688 | ( # wrap whole match in $1 |
|
| 689 | !\[ |
|
| 690 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 691 | \] |
|
| 692 | \s? # One optional whitespace character |
|
| 693 | \( # literal paren |
|
| 694 | [ \n]* |
|
| 695 | (?: |
|
| 696 | <(\S*)> # src url = $3 |
|
| 697 | | |
|
| 698 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 699 | ) |
|
| 700 | [ \n]* |
|
| 701 | ( # $5 |
|
| 702 | ([\'"]) # quote char = $6 |
|
| 703 | (.*?) # title = $7 |
|
| 704 | \6 # matching quote |
|
| 705 | [ \n]* |
|
| 706 | )? # title is optional |
|
| 707 | \) |
|
| 708 | ) |
|
| 709 | }xs', |
|
| 710 | array($this, '_doImages_inline_callback'), $text); |
|
| 711 | ||
| 712 | return $text; |
|
| 713 | } |
|
| 714 | protected function _doImages_reference_callback($matches) { |
|
| 715 | $whole_match = $matches[1]; |
|
| 716 | $alt_text = $matches[2]; |
|
| @@ 840-895 (lines=56) @@ | ||
| 837 | } |
|
| 838 | ||
| 839 | ||
| 840 | protected function doImages($text) { |
|
| 841 | # |
|
| 842 | # Turn Markdown image shortcuts into <img> tags. |
|
| 843 | # |
|
| 844 | # |
|
| 845 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 846 | # |
|
| 847 | $text = preg_replace_callback('{ |
|
| 848 | ( # wrap whole match in $1 |
|
| 849 | !\[ |
|
| 850 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 851 | \] |
|
| 852 | ||
| 853 | [ ]? # one optional space |
|
| 854 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 855 | ||
| 856 | \[ |
|
| 857 | (.*?) # id = $3 |
|
| 858 | \] |
|
| 859 | ||
| 860 | ) |
|
| 861 | }xs', |
|
| 862 | array($this, '_doImages_reference_callback'), $text); |
|
| 863 | ||
| 864 | # |
|
| 865 | # Next, handle inline images:  |
|
| 866 | # Don't forget: encode * and _ |
|
| 867 | # |
|
| 868 | $text = preg_replace_callback('{ |
|
| 869 | ( # wrap whole match in $1 |
|
| 870 | !\[ |
|
| 871 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 872 | \] |
|
| 873 | \s? # One optional whitespace character |
|
| 874 | \( # literal paren |
|
| 875 | [ \n]* |
|
| 876 | (?: |
|
| 877 | <(\S*)> # src url = $3 |
|
| 878 | | |
|
| 879 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 880 | ) |
|
| 881 | [ \n]* |
|
| 882 | ( # $5 |
|
| 883 | ([\'"]) # quote char = $6 |
|
| 884 | (.*?) # title = $7 |
|
| 885 | \6 # matching quote |
|
| 886 | [ \n]* |
|
| 887 | )? # title is optional |
|
| 888 | \) |
|
| 889 | (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes |
|
| 890 | ) |
|
| 891 | }xs', |
|
| 892 | array($this, '_doImages_inline_callback'), $text); |
|
| 893 | ||
| 894 | return $text; |
|
| 895 | } |
|
| 896 | protected function _doImages_reference_callback($matches) { |
|
| 897 | $whole_match = $matches[1]; |
|
| 898 | $alt_text = $matches[2]; |
|