@@ 206-239 (lines=34) @@ | ||
203 | ); |
|
204 | ||
205 | ||
206 | function stripLinkDefinitions($text) { |
|
207 | # |
|
208 | # Strips link definitions from text, stores the URLs and titles in |
|
209 | # hash references. |
|
210 | # |
|
211 | $less_than_tab = $this->tab_width - 1; |
|
212 | ||
213 | # Link defs are in the form: ^[id]: url "optional title" |
|
214 | $text = preg_replace_callback('{ |
|
215 | ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
216 | [ ]* |
|
217 | \n? # maybe *one* newline |
|
218 | [ ]* |
|
219 | (?: |
|
220 | <(.+?)> # url = $2 |
|
221 | | |
|
222 | (\S+?) # url = $3 |
|
223 | ) |
|
224 | [ ]* |
|
225 | \n? # maybe one newline |
|
226 | [ ]* |
|
227 | (?: |
|
228 | (?<=\s) # lookbehind for whitespace |
|
229 | ["(] |
|
230 | (.*?) # title = $4 |
|
231 | [")] |
|
232 | [ ]* |
|
233 | )? # title is optional |
|
234 | (?:\n+|\Z) |
|
235 | }xm', |
|
236 | array(&$this, '_stripLinkDefinitions_callback'), |
|
237 | $text); |
|
238 | return $text; |
|
239 | } |
|
240 | function _stripLinkDefinitions_callback($matches) { |
|
241 | $link_id = strtolower($matches[1]); |
|
242 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
|
@@ 1699-1733 (lines=35) @@ | ||
1696 | } |
|
1697 | ||
1698 | ||
1699 | function stripLinkDefinitions($text) { |
|
1700 | # |
|
1701 | # Strips link definitions from text, stores the URLs and titles in |
|
1702 | # hash references. |
|
1703 | # |
|
1704 | $less_than_tab = $this->tab_width - 1; |
|
1705 | ||
1706 | # Link defs are in the form: ^[id]: url "optional title" |
|
1707 | $text = preg_replace_callback('{ |
|
1708 | ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
1709 | [ ]* |
|
1710 | \n? # maybe *one* newline |
|
1711 | [ ]* |
|
1712 | (?: |
|
1713 | <(.+?)> # url = $2 |
|
1714 | | |
|
1715 | (\S+?) # url = $3 |
|
1716 | ) |
|
1717 | [ ]* |
|
1718 | \n? # maybe one newline |
|
1719 | [ ]* |
|
1720 | (?: |
|
1721 | (?<=\s) # lookbehind for whitespace |
|
1722 | ["(] |
|
1723 | (.*?) # title = $4 |
|
1724 | [")] |
|
1725 | [ ]* |
|
1726 | )? # title is optional |
|
1727 | (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
1728 | (?:\n+|\Z) |
|
1729 | }xm', |
|
1730 | array(&$this, '_stripLinkDefinitions_callback'), |
|
1731 | $text); |
|
1732 | return $text; |
|
1733 | } |
|
1734 | function _stripLinkDefinitions_callback($matches) { |
|
1735 | $link_id = strtolower($matches[1]); |
|
1736 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
|
@@ 2768-2806 (lines=39) @@ | ||
2765 | } |
|
2766 | ||
2767 | ||
2768 | function doFencedCodeBlocks($text) { |
|
2769 | # |
|
2770 | # Adding the fenced code block syntax to regular Markdown: |
|
2771 | # |
|
2772 | # ~~~ |
|
2773 | # Code block |
|
2774 | # ~~~ |
|
2775 | # |
|
2776 | $less_than_tab = $this->tab_width; |
|
2777 | ||
2778 | $text = preg_replace_callback('{ |
|
2779 | (?:\n|\A) |
|
2780 | # 1: Opening marker |
|
2781 | ( |
|
2782 | (?:~{3,}|`{3,}) # 3 or more tildes/backticks. |
|
2783 | ) |
|
2784 | [ ]* |
|
2785 | (?: |
|
2786 | \.?([-_:a-zA-Z0-9]+) # 2: standalone class name |
|
2787 | | |
|
2788 | '.$this->id_class_attr_catch_re.' # 3: Extra attributes |
|
2789 | )? |
|
2790 | [ ]* \n # Whitespace and newline following marker. |
|
2791 | ||
2792 | # 4: Content |
|
2793 | ( |
|
2794 | (?> |
|
2795 | (?!\1 [ ]* \n) # Not a closing marker. |
|
2796 | .*\n+ |
|
2797 | )+ |
|
2798 | ) |
|
2799 | ||
2800 | # Closing marker. |
|
2801 | \1 [ ]* (?= \n ) |
|
2802 | }xm', |
|
2803 | array(&$this, '_doFencedCodeBlocks_callback'), $text); |
|
2804 | ||
2805 | return $text; |
|
2806 | } |
|
2807 | function _doFencedCodeBlocks_callback($matches) { |
|
2808 | $classname =& $matches[2]; |
|
2809 | $attrs =& $matches[3]; |
|
@@ 2893-2919 (lines=27) @@ | ||
2890 | ||
2891 | ### Footnotes |
|
2892 | ||
2893 | function stripFootnotes($text) { |
|
2894 | # |
|
2895 | # Strips link definitions from text, stores the URLs and titles in |
|
2896 | # hash references. |
|
2897 | # |
|
2898 | $less_than_tab = $this->tab_width - 1; |
|
2899 | ||
2900 | # Link defs are in the form: [^id]: url "optional title" |
|
2901 | $text = preg_replace_callback('{ |
|
2902 | ^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1 |
|
2903 | [ ]* |
|
2904 | \n? # maybe *one* newline |
|
2905 | ( # text = $2 (no blank lines allowed) |
|
2906 | (?: |
|
2907 | .+ # actual text |
|
2908 | | |
|
2909 | \n # newlines but |
|
2910 | (?!\[\^.+?\]:\s)# negative lookahead for footnote marker. |
|
2911 | (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed |
|
2912 | # by non-indented content |
|
2913 | )* |
|
2914 | ) |
|
2915 | }xm', |
|
2916 | array(&$this, '_stripFootnotes_callback'), |
|
2917 | $text); |
|
2918 | return $text; |
|
2919 | } |
|
2920 | function _stripFootnotes_callback($matches) { |
|
2921 | $note_id = $this->fn_id_prefix . $matches[1]; |
|
2922 | $this->footnotes[$note_id] = $this->outdent($matches[2]); |
|
@@ 3048-3062 (lines=15) @@ | ||
3045 | ||
3046 | ### Abbreviations ### |
|
3047 | ||
3048 | function stripAbbreviations($text) { |
|
3049 | # |
|
3050 | # Strips abbreviations from text, stores titles in hash references. |
|
3051 | # |
|
3052 | $less_than_tab = $this->tab_width - 1; |
|
3053 | ||
3054 | # Link defs are in the form: [id]*: url "optional title" |
|
3055 | $text = preg_replace_callback('{ |
|
3056 | ^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
3057 | (.*) # text = $2 (no blank lines allowed) |
|
3058 | }xm', |
|
3059 | array(&$this, '_stripAbbreviations_callback'), |
|
3060 | $text); |
|
3061 | return $text; |
|
3062 | } |
|
3063 | function _stripAbbreviations_callback($matches) { |
|
3064 | $abbr_word = $matches[1]; |
|
3065 | $abbr_desc = $matches[2]; |