| @@ 813-867 (lines=55) @@ | ||
| 810 | } |
|
| 811 | ||
| 812 | ||
| 813 | function doImages($text) { |
|
| 814 | # |
|
| 815 | # Turn Markdown image shortcuts into <img> tags. |
|
| 816 | # |
|
| 817 | # |
|
| 818 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 819 | # |
|
| 820 | $text = preg_replace_callback('{ |
|
| 821 | ( # wrap whole match in $1 |
|
| 822 | !\[ |
|
| 823 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 824 | \] |
|
| 825 | ||
| 826 | [ ]? # one optional space |
|
| 827 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 828 | ||
| 829 | \[ |
|
| 830 | (.*?) # id = $3 |
|
| 831 | \] |
|
| 832 | ||
| 833 | ) |
|
| 834 | }xs', |
|
| 835 | array(&$this, '_doImages_reference_callback'), $text); |
|
| 836 | ||
| 837 | # |
|
| 838 | # Next, handle inline images:  |
|
| 839 | # Don't forget: encode * and _ |
|
| 840 | # |
|
| 841 | $text = preg_replace_callback('{ |
|
| 842 | ( # wrap whole match in $1 |
|
| 843 | !\[ |
|
| 844 | ('.$this->nested_brackets_re.') # alt text = $2 |
|
| 845 | \] |
|
| 846 | \s? # One optional whitespace character |
|
| 847 | \( # literal paren |
|
| 848 | [ \n]* |
|
| 849 | (?: |
|
| 850 | <(\S*)> # src url = $3 |
|
| 851 | | |
|
| 852 | ('.$this->nested_url_parenthesis_re.') # src url = $4 |
|
| 853 | ) |
|
| 854 | [ \n]* |
|
| 855 | ( # $5 |
|
| 856 | ([\'"]) # quote char = $6 |
|
| 857 | (.*?) # title = $7 |
|
| 858 | \6 # matching quote |
|
| 859 | [ \n]* |
|
| 860 | )? # title is optional |
|
| 861 | \) |
|
| 862 | ) |
|
| 863 | }xs', |
|
| 864 | array(&$this, '_doImages_inline_callback'), $text); |
|
| 865 | ||
| 866 | return $text; |
|
| 867 | } |
|
| 868 | function _doImages_reference_callback($matches) { |
|
| 869 | $whole_match = $matches[1]; |
|
| 870 | $alt_text = $matches[2]; |
|
| @@ 572-639 (lines=68) @@ | ||
| 569 | ||
| 570 | ** |
|
| 571 | */ |
|
| 572 | function doImages($text) |
|
| 573 | { |
|
| 574 | # |
|
| 575 | # Turn Markdown image shortcuts into <img> tags. |
|
| 576 | # |
|
| 577 | ||
| 578 | # |
|
| 579 | # gofromiel: added align options |
|
| 580 | # |
|
| 581 | ||
| 582 | # |
|
| 583 | # First, handle reference-style labeled images: ![alt text][id] |
|
| 584 | # |
|
| 585 | ||
| 586 | $text = preg_replace_callback |
|
| 587 | ( |
|
| 588 | '{ |
|
| 589 | ( # wrap whole match in $1 |
|
| 590 | ! # start |
|
| 591 | (\<|\||\>|\=)? # alignment = $2 |
|
| 592 | \[ |
|
| 593 | ('.$this->nested_brackets_re.') # alt text = $3 |
|
| 594 | \] |
|
| 595 | ||
| 596 | [ ]? # one optional space |
|
| 597 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
| 598 | ||
| 599 | \[ |
|
| 600 | (.*?) # id = $4 |
|
| 601 | \] |
|
| 602 | ||
| 603 | ) |
|
| 604 | }xs', array(&$this, '_doImages_reference_callback'), $text |
|
| 605 | ); |
|
| 606 | ||
| 607 | # |
|
| 608 | # Next, handle inline images:  |
|
| 609 | # Don't forget: encode * and _ |
|
| 610 | # |
|
| 611 | $text = preg_replace_callback('{ |
|
| 612 | ( # wrap whole match in $1 |
|
| 613 | ! |
|
| 614 | (\<|\||\>|\=)? # alignment = $2 |
|
| 615 | \[ |
|
| 616 | ('.$this->nested_brackets_re.') # alt text = $3 |
|
| 617 | \] |
|
| 618 | \s? # One optional whitespace character |
|
| 619 | \( # literal paren |
|
| 620 | [ ]* |
|
| 621 | (?: |
|
| 622 | <(\S*)> # src url = $4 |
|
| 623 | | |
|
| 624 | ('.$this->nested_url_parenthesis_re.') # src url = $5 |
|
| 625 | ) |
|
| 626 | [ ]* |
|
| 627 | ( # $6 |
|
| 628 | ([\'"]) # quote char = $7 |
|
| 629 | (.*?) # title = $8 |
|
| 630 | \6 # matching quote |
|
| 631 | [ ]* |
|
| 632 | )? # title is optional |
|
| 633 | \) |
|
| 634 | ) |
|
| 635 | }xs', |
|
| 636 | array(&$this, '_doImages_inline_callback'), $text); |
|
| 637 | ||
| 638 | return $text; |
|
| 639 | } |
|
| 640 | ||
| 641 | static protected $images_reference_callback; |
|
| 642 | ||