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