| @@ 863-924 (lines=62) @@ | ||
| 860 | return $this->hashPart($result); |
|
| 861 | } |
|
| 862 | ||
| 863 | function doImages($text) |
|
| 864 | { |
|
| 865 | # |
|
| 866 | # Turn Markdown image shortcuts into <img> tags. |
|
| 867 | # |
|
| 868 | # |
|
| 869 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 870 | # |
|
| 871 | $text = preg_replace_callback( |
|
| 872 | '{ |
|
| 873 | ( # wrap whole match in $1 |
|
| 874 | !\[ |
|
| 875 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
| 876 | \] |
|
| 877 | ||
| 878 | [ ]? # one optional space |
|
| 879 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 880 | ||
| 881 | \[ |
|
| 882 | (.*?) # id = $3 |
|
| 883 | \] |
|
| 884 | ||
| 885 | ) |
|
| 886 | }xs', |
|
| 887 | array(&$this, '_doImages_reference_callback'), |
|
| 888 | $text |
|
| 889 | ); |
|
| 890 | ||
| 891 | # |
|
| 892 | # Next, handle inline images:  |
|
| 893 | # Don't forget: encode * and _ |
|
| 894 | # |
|
| 895 | $text = preg_replace_callback( |
|
| 896 | '{ |
|
| 897 | ( # wrap whole match in $1 |
|
| 898 | !\[ |
|
| 899 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
| 900 | \] |
|
| 901 | \s? # One optional whitespace character |
|
| 902 | \( # literal paren |
|
| 903 | [ \n]* |
|
| 904 | (?: |
|
| 905 | <(\S*)> # src url = $3 |
|
| 906 | | |
|
| 907 | (' . $this->nested_url_parenthesis_re . ') # src url = $4 |
|
| 908 | ) |
|
| 909 | [ \n]* |
|
| 910 | ( # $5 |
|
| 911 | ([\'"]) # quote char = $6 |
|
| 912 | (.*?) # title = $7 |
|
| 913 | \6 # matching quote |
|
| 914 | [ \n]* |
|
| 915 | )? # title is optional |
|
| 916 | \) |
|
| 917 | ) |
|
| 918 | }xs', |
|
| 919 | array(&$this, '_doImages_inline_callback'), |
|
| 920 | $text |
|
| 921 | ); |
|
| 922 | ||
| 923 | return $text; |
|
| 924 | } |
|
| 925 | ||
| 926 | function _doImages_reference_callback($matches) |
|
| 927 | { |
|
| @@ 2691-2753 (lines=63) @@ | ||
| 2688 | return $this->hashPart($result); |
|
| 2689 | } |
|
| 2690 | ||
| 2691 | function doImages($text) |
|
| 2692 | { |
|
| 2693 | # |
|
| 2694 | # Turn Markdown image shortcuts into <img> tags. |
|
| 2695 | # |
|
| 2696 | # |
|
| 2697 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 2698 | # |
|
| 2699 | $text = preg_replace_callback( |
|
| 2700 | '{ |
|
| 2701 | ( # wrap whole match in $1 |
|
| 2702 | !\[ |
|
| 2703 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
| 2704 | \] |
|
| 2705 | ||
| 2706 | [ ]? # one optional space |
|
| 2707 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 2708 | ||
| 2709 | \[ |
|
| 2710 | (.*?) # id = $3 |
|
| 2711 | \] |
|
| 2712 | ||
| 2713 | ) |
|
| 2714 | }xs', |
|
| 2715 | array(&$this, '_doImages_reference_callback'), |
|
| 2716 | $text |
|
| 2717 | ); |
|
| 2718 | ||
| 2719 | # |
|
| 2720 | # Next, handle inline images:  |
|
| 2721 | # Don't forget: encode * and _ |
|
| 2722 | # |
|
| 2723 | $text = preg_replace_callback( |
|
| 2724 | '{ |
|
| 2725 | ( # wrap whole match in $1 |
|
| 2726 | !\[ |
|
| 2727 | (' . $this->nested_brackets_re . ') # alt text = $2 |
|
| 2728 | \] |
|
| 2729 | \s? # One optional whitespace character |
|
| 2730 | \( # literal paren |
|
| 2731 | [ \n]* |
|
| 2732 | (?: |
|
| 2733 | <(\S*)> # src url = $3 |
|
| 2734 | | |
|
| 2735 | (' . $this->nested_url_parenthesis_re . ') # src url = $4 |
|
| 2736 | ) |
|
| 2737 | [ \n]* |
|
| 2738 | ( # $5 |
|
| 2739 | ([\'"]) # quote char = $6 |
|
| 2740 | (.*?) # title = $7 |
|
| 2741 | \6 # matching quote |
|
| 2742 | [ \n]* |
|
| 2743 | )? # title is optional |
|
| 2744 | \) |
|
| 2745 | (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
| 2746 | ) |
|
| 2747 | }xs', |
|
| 2748 | array(&$this, '_doImages_inline_callback'), |
|
| 2749 | $text |
|
| 2750 | ); |
|
| 2751 | ||
| 2752 | return $text; |
|
| 2753 | } |
|
| 2754 | ||
| 2755 | function _doImages_reference_callback($matches) |
|
| 2756 | { |
|