| @@ 801-848 (lines=48) @@ | ||
| 798 | * @param string $text |
|
| 799 | * @return string |
|
| 800 | */ |
|
| 801 | protected function doImages($text) { |
|
| 802 | // First, handle reference-style labeled images: ![alt text][id] |
|
| 803 | $text = preg_replace_callback('{ |
|
| 804 | ( # wrap whole match in $1 |
|
| 805 | !\[ |
|
| 806 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 807 | \] |
|
| 808 | ||
| 809 | [ ]? # one optional space |
|
| 810 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 811 | ||
| 812 | \[ |
|
| 813 | (.*?) # id = $3 |
|
| 814 | \] |
|
| 815 | ||
| 816 | ) |
|
| 817 | }xs', |
|
| 818 | array($this, '_doImages_reference_callback'), $text); |
|
| 819 | ||
| 820 | // Next, handle inline images:  |
|
| 821 | // Don't forget: encode * and _ |
|
| 822 | $text = preg_replace_callback('{ |
|
| 823 | ( # wrap whole match in $1 |
|
| 824 | !\[ |
|
| 825 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 826 | \] |
|
| 827 | \s? # One optional whitespace character |
|
| 828 | \( # literal paren |
|
| 829 | [ \n]* |
|
| 830 | (?: |
|
| 831 | <(\S*)> # src url = $3 |
|
| 832 | | |
|
| 833 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 834 | ) |
|
| 835 | [ \n]* |
|
| 836 | ( # $5 |
|
| 837 | ([\'"]) # quote char = $6 |
|
| 838 | (.*?) # title = $7 |
|
| 839 | \6 # matching quote |
|
| 840 | [ \n]* |
|
| 841 | )? # title is optional |
|
| 842 | \) |
|
| 843 | ) |
|
| 844 | }xs', |
|
| 845 | array($this, '_doImages_inline_callback'), $text); |
|
| 846 | ||
| 847 | return $text; |
|
| 848 | } |
|
| 849 | ||
| 850 | /** |
|
| 851 | * Callback to parse references image tags |
|
| @@ 935-983 (lines=49) @@ | ||
| 932 | * @param string $text |
|
| 933 | * @return string |
|
| 934 | */ |
|
| 935 | protected function doImages($text) { |
|
| 936 | // First, handle reference-style labeled images: ![alt text][id] |
|
| 937 | $text = preg_replace_callback('{ |
|
| 938 | ( # wrap whole match in $1 |
|
| 939 | !\[ |
|
| 940 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
| 941 | \] |
|
| 942 | ||
| 943 | [ ]? # one optional space |
|
| 944 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 945 | ||
| 946 | \[ |
|
| 947 | (.*?) # id = $3 |
|
| 948 | \] |
|
| 949 | ||
| 950 | ) |
|
| 951 | }xs', |
|
| 952 | array($this, '_doImages_reference_callback'), $text); |
|
| 953 | ||
| 954 | // Next, handle inline images:  |
|
| 955 | // Don't forget: encode * and _ |
|
| 956 | $text = preg_replace_callback('{ |
|
| 957 | ( # wrap whole match in $1 |
|
| 958 | !\[ |
|
| 959 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
| 960 | \] |
|
| 961 | \s? # One optional whitespace character |
|
| 962 | \( # literal paren |
|
| 963 | [ \n]* |
|
| 964 | (?: |
|
| 965 | <(\S*)> # src url = $3 |
|
| 966 | | |
|
| 967 | (' . $this->nested_url_parenthesis_re . ') # src url = $4 |
|
| 968 | ) |
|
| 969 | [ \n]* |
|
| 970 | ( # $5 |
|
| 971 | ([\'"]) # quote char = $6 |
|
| 972 | (.*?) # title = $7 |
|
| 973 | \6 # matching quote |
|
| 974 | [ \n]* |
|
| 975 | )? # title is optional |
|
| 976 | \) |
|
| 977 | (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
| 978 | ) |
|
| 979 | }xs', |
|
| 980 | array($this, '_doImages_inline_callback'), $text); |
|
| 981 | ||
| 982 | return $text; |
|
| 983 | } |
|
| 984 | ||
| 985 | /** |
|
| 986 | * Callback for referenced images |
|