@@ 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 |
@@ 965-1013 (lines=49) @@ | ||
962 | * @param string $text |
|
963 | * @return string |
|
964 | */ |
|
965 | protected function doImages($text) { |
|
966 | // First, handle reference-style labeled images: ![alt text][id] |
|
967 | $text = preg_replace_callback('{ |
|
968 | ( # wrap whole match in $1 |
|
969 | !\[ |
|
970 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
971 | \] |
|
972 | ||
973 | [ ]? # one optional space |
|
974 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
975 | ||
976 | \[ |
|
977 | (.*?) # id = $3 |
|
978 | \] |
|
979 | ||
980 | ) |
|
981 | }xs', |
|
982 | array($this, '_doImages_reference_callback'), $text); |
|
983 | ||
984 | // Next, handle inline images:  |
|
985 | // Don't forget: encode * and _ |
|
986 | $text = preg_replace_callback('{ |
|
987 | ( # wrap whole match in $1 |
|
988 | !\[ |
|
989 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
990 | \] |
|
991 | \s? # One optional whitespace character |
|
992 | \( # literal paren |
|
993 | [ \n]* |
|
994 | (?: |
|
995 | <(\S*)> # src url = $3 |
|
996 | | |
|
997 | (' . $this->nested_url_parenthesis_re . ') # src url = $4 |
|
998 | ) |
|
999 | [ \n]* |
|
1000 | ( # $5 |
|
1001 | ([\'"]) # quote char = $6 |
|
1002 | (.*?) # title = $7 |
|
1003 | \6 # matching quote |
|
1004 | [ \n]* |
|
1005 | )? # title is optional |
|
1006 | \) |
|
1007 | (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
1008 | ) |
|
1009 | }xs', |
|
1010 | array($this, '_doImages_inline_callback'), $text); |
|
1011 | ||
1012 | return $text; |
|
1013 | } |
|
1014 | ||
1015 | /** |
|
1016 | * Callback for referenced images |