@@ 372-405 (lines=34) @@ | ||
369 | "doBlockQuotes" => 60, |
|
370 | ); |
|
371 | ||
372 | function stripLinkDefinitions($text) { |
|
373 | # |
|
374 | # Strips link definitions from text, stores the URLs and titles in |
|
375 | # hash references. |
|
376 | # |
|
377 | $less_than_tab = $this->tab_width - 1; |
|
378 | ||
379 | # Link defs are in the form: ^[id]: url "optional title" |
|
380 | $text = preg_replace_callback('{ |
|
381 | ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
382 | [ ]* |
|
383 | \n? # maybe *one* newline |
|
384 | [ ]* |
|
385 | (?: |
|
386 | <(.+?)> # url = $2 |
|
387 | | |
|
388 | (\S+?) # url = $3 |
|
389 | ) |
|
390 | [ ]* |
|
391 | \n? # maybe one newline |
|
392 | [ ]* |
|
393 | (?: |
|
394 | (?<=\s) # lookbehind for whitespace |
|
395 | ["(] |
|
396 | (.*?) # title = $4 |
|
397 | [")] |
|
398 | [ ]* |
|
399 | )? # title is optional |
|
400 | (?:\n+|\Z) |
|
401 | }xm', |
|
402 | array(&$this, '_stripLinkDefinitions_callback'), |
|
403 | $text); |
|
404 | return $text; |
|
405 | } |
|
406 | function _stripLinkDefinitions_callback($matches) { |
|
407 | $link_id = strtolower($matches[1]); |
|
408 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
@@ 1005-1031 (lines=27) @@ | ||
1002 | ||
1003 | ### Footnotes |
|
1004 | ||
1005 | function stripFootnotes($text) { |
|
1006 | # |
|
1007 | # Strips link definitions from text, stores the URLs and titles in |
|
1008 | # hash references. |
|
1009 | # |
|
1010 | $less_than_tab = $this->tab_width - 1; |
|
1011 | ||
1012 | # Link defs are in the form: [^id]: url "optional title" |
|
1013 | $text = preg_replace_callback('{ |
|
1014 | ^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1 |
|
1015 | [ ]* |
|
1016 | \n? # maybe *one* newline |
|
1017 | ( # text = $2 (no blank lines allowed) |
|
1018 | (?: |
|
1019 | .+ # actual text |
|
1020 | | |
|
1021 | \n # newlines but |
|
1022 | (?!\[\^.+?\]:\s)# negative lookahead for footnote marker. |
|
1023 | (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed |
|
1024 | # by non-indented content |
|
1025 | )* |
|
1026 | ) |
|
1027 | }xm', |
|
1028 | array(&$this, '_stripFootnotes_callback'), |
|
1029 | $text); |
|
1030 | return $text; |
|
1031 | } |
|
1032 | function _stripFootnotes_callback($matches) { |
|
1033 | $note_id = $this->fn_id_prefix . $matches[1]; |
|
1034 | $this->footnotes[$note_id] = $this->outdent($matches[2]); |
|
@@ 1146-1160 (lines=15) @@ | ||
1143 | ||
1144 | ### Abbreviations ### |
|
1145 | ||
1146 | function stripAbbreviations($text) { |
|
1147 | # |
|
1148 | # Strips abbreviations from text, stores titles in hash references. |
|
1149 | # |
|
1150 | $less_than_tab = $this->tab_width - 1; |
|
1151 | ||
1152 | # Link defs are in the form: [id]*: url "optional title" |
|
1153 | $text = preg_replace_callback('{ |
|
1154 | ^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
1155 | (.*) # text = $2 (no blank lines allowed) |
|
1156 | }xm', |
|
1157 | array(&$this, '_stripAbbreviations_callback'), |
|
1158 | $text); |
|
1159 | return $text; |
|
1160 | } |
|
1161 | function _stripAbbreviations_callback($matches) { |
|
1162 | $abbr_word = $matches[1]; |
|
1163 | $abbr_desc = $matches[2]; |