@@ 724-805 (lines=82) @@ | ||
721 | return $this->hashPart("<br$this->empty_element_suffix\n"); |
|
722 | } |
|
723 | ||
724 | function doAnchors($text) |
|
725 | { |
|
726 | # |
|
727 | # Turn Markdown link shortcuts into XHTML <a> tags. |
|
728 | # |
|
729 | if ($this->in_anchor) { |
|
730 | return $text; |
|
731 | } |
|
732 | $this->in_anchor = true; |
|
733 | ||
734 | # |
|
735 | # First, handle reference-style links: [link text] [id] |
|
736 | # |
|
737 | $text = preg_replace_callback( |
|
738 | '{ |
|
739 | ( # wrap whole match in $1 |
|
740 | \[ |
|
741 | (' . $this->nested_brackets_re . ') # link text = $2 |
|
742 | \] |
|
743 | ||
744 | [ ]? # one optional space |
|
745 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
746 | ||
747 | \[ |
|
748 | (.*?) # id = $3 |
|
749 | \] |
|
750 | ) |
|
751 | }xs', |
|
752 | array(&$this, '_doAnchors_reference_callback'), |
|
753 | $text |
|
754 | ); |
|
755 | ||
756 | # |
|
757 | # Next, inline-style links: [link text](url "optional title") |
|
758 | # |
|
759 | $text = preg_replace_callback( |
|
760 | '{ |
|
761 | ( # wrap whole match in $1 |
|
762 | \[ |
|
763 | (' . $this->nested_brackets_re . ') # link text = $2 |
|
764 | \] |
|
765 | \( # literal paren |
|
766 | [ \n]* |
|
767 | (?: |
|
768 | <(.+?)> # href = $3 |
|
769 | | |
|
770 | (' . $this->nested_url_parenthesis_re . ') # href = $4 |
|
771 | ) |
|
772 | [ \n]* |
|
773 | ( # $5 |
|
774 | ([\'"]) # quote char = $6 |
|
775 | (.*?) # Title = $7 |
|
776 | \6 # matching quote |
|
777 | [ \n]* # ignore any spaces/tabs between closing quote and ) |
|
778 | )? # title is optional |
|
779 | \) |
|
780 | ) |
|
781 | }xs', |
|
782 | array(&$this, '_doAnchors_inline_callback'), |
|
783 | $text |
|
784 | ); |
|
785 | ||
786 | # |
|
787 | # Last, handle reference-style shortcuts: [link text] |
|
788 | # These must come last in case you've also got [link text][1] |
|
789 | # or [link text](/foo) |
|
790 | # |
|
791 | $text = preg_replace_callback( |
|
792 | '{ |
|
793 | ( # wrap whole match in $1 |
|
794 | \[ |
|
795 | ([^\[\]]+) # link text = $2; can\'t contain [ or ] |
|
796 | \] |
|
797 | ) |
|
798 | }xs', |
|
799 | array(&$this, '_doAnchors_reference_callback'), |
|
800 | $text |
|
801 | ); |
|
802 | ||
803 | $this->in_anchor = false; |
|
804 | return $text; |
|
805 | } |
|
806 | ||
807 | function _doAnchors_reference_callback($matches) |
|
808 | { |
|
@@ 2546-2628 (lines=83) @@ | ||
2543 | return $this->hashPart($text, 'C'); |
|
2544 | } |
|
2545 | ||
2546 | function doAnchors($text) |
|
2547 | { |
|
2548 | # |
|
2549 | # Turn Markdown link shortcuts into XHTML <a> tags. |
|
2550 | # |
|
2551 | if ($this->in_anchor) { |
|
2552 | return $text; |
|
2553 | } |
|
2554 | $this->in_anchor = true; |
|
2555 | ||
2556 | # |
|
2557 | # First, handle reference-style links: [link text] [id] |
|
2558 | # |
|
2559 | $text = preg_replace_callback( |
|
2560 | '{ |
|
2561 | ( # wrap whole match in $1 |
|
2562 | \[ |
|
2563 | (' . $this->nested_brackets_re . ') # link text = $2 |
|
2564 | \] |
|
2565 | ||
2566 | [ ]? # one optional space |
|
2567 | (?:\n[ ]*)? # one optional newline followed by spaces |
|
2568 | ||
2569 | \[ |
|
2570 | (.*?) # id = $3 |
|
2571 | \] |
|
2572 | ) |
|
2573 | }xs', |
|
2574 | array(&$this, '_doAnchors_reference_callback'), |
|
2575 | $text |
|
2576 | ); |
|
2577 | ||
2578 | # |
|
2579 | # Next, inline-style links: [link text](url "optional title") |
|
2580 | # |
|
2581 | $text = preg_replace_callback( |
|
2582 | '{ |
|
2583 | ( # wrap whole match in $1 |
|
2584 | \[ |
|
2585 | (' . $this->nested_brackets_re . ') # link text = $2 |
|
2586 | \] |
|
2587 | \( # literal paren |
|
2588 | [ \n]* |
|
2589 | (?: |
|
2590 | <(.+?)> # href = $3 |
|
2591 | | |
|
2592 | (' . $this->nested_url_parenthesis_re . ') # href = $4 |
|
2593 | ) |
|
2594 | [ \n]* |
|
2595 | ( # $5 |
|
2596 | ([\'"]) # quote char = $6 |
|
2597 | (.*?) # Title = $7 |
|
2598 | \6 # matching quote |
|
2599 | [ \n]* # ignore any spaces/tabs between closing quote and ) |
|
2600 | )? # title is optional |
|
2601 | \) |
|
2602 | (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
2603 | ) |
|
2604 | }xs', |
|
2605 | array(&$this, '_doAnchors_inline_callback'), |
|
2606 | $text |
|
2607 | ); |
|
2608 | ||
2609 | # |
|
2610 | # Last, handle reference-style shortcuts: [link text] |
|
2611 | # These must come last in case you've also got [link text][1] |
|
2612 | # or [link text](/foo) |
|
2613 | # |
|
2614 | $text = preg_replace_callback( |
|
2615 | '{ |
|
2616 | ( # wrap whole match in $1 |
|
2617 | \[ |
|
2618 | ([^\[\]]+) # link text = $2; can\'t contain [ or ] |
|
2619 | \] |
|
2620 | ) |
|
2621 | }xs', |
|
2622 | array(&$this, '_doAnchors_reference_callback'), |
|
2623 | $text |
|
2624 | ); |
|
2625 | ||
2626 | $this->in_anchor = false; |
|
2627 | return $text; |
|
2628 | } |
|
2629 | ||
2630 | function _doAnchors_reference_callback($matches) |
|
2631 | { |