| @@ 280-311 (lines=32) @@ | ||
| 277 | * @param string $text |
|
| 278 | * @return string |
|
| 279 | */ |
|
| 280 | protected function stripLinkDefinitions($text) { |
|
| 281 | ||
| 282 | $less_than_tab = $this->tab_width - 1; |
|
| 283 | ||
| 284 | // Link defs are in the form: ^[id]: url "optional title" |
|
| 285 | $text = preg_replace_callback('{ |
|
| 286 | ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 287 | [ ]* |
|
| 288 | \n? # maybe *one* newline |
|
| 289 | [ ]* |
|
| 290 | (?: |
|
| 291 | <(.+?)> # url = $2 |
|
| 292 | | |
|
| 293 | (\S+?) # url = $3 |
|
| 294 | ) |
|
| 295 | [ ]* |
|
| 296 | \n? # maybe one newline |
|
| 297 | [ ]* |
|
| 298 | (?: |
|
| 299 | (?<=\s) # lookbehind for whitespace |
|
| 300 | ["(] |
|
| 301 | (.*?) # title = $4 |
|
| 302 | [")] |
|
| 303 | [ ]* |
|
| 304 | )? # title is optional |
|
| 305 | (?:\n+|\Z) |
|
| 306 | }xm', |
|
| 307 | array($this, '_stripLinkDefinitions_callback'), |
|
| 308 | $text |
|
| 309 | ); |
|
| 310 | return $text; |
|
| 311 | } |
|
| 312 | ||
| 313 | /** |
|
| 314 | * The callback to strip link definitions |
|
| @@ 293-323 (lines=31) @@ | ||
| 290 | * @param string $text |
|
| 291 | * @return string |
|
| 292 | */ |
|
| 293 | protected function stripLinkDefinitions($text) { |
|
| 294 | $less_than_tab = $this->tab_width - 1; |
|
| 295 | ||
| 296 | // Link defs are in the form: ^[id]: url "optional title" |
|
| 297 | $text = preg_replace_callback('{ |
|
| 298 | ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 299 | [ ]* |
|
| 300 | \n? # maybe *one* newline |
|
| 301 | [ ]* |
|
| 302 | (?: |
|
| 303 | <(.+?)> # url = $2 |
|
| 304 | | |
|
| 305 | (\S+?) # url = $3 |
|
| 306 | ) |
|
| 307 | [ ]* |
|
| 308 | \n? # maybe one newline |
|
| 309 | [ ]* |
|
| 310 | (?: |
|
| 311 | (?<=\s) # lookbehind for whitespace |
|
| 312 | ["(] |
|
| 313 | (.*?) # title = $4 |
|
| 314 | [")] |
|
| 315 | [ ]* |
|
| 316 | )? # title is optional |
|
| 317 | (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
| 318 | (?:\n+|\Z) |
|
| 319 | }xm', |
|
| 320 | array($this, '_stripLinkDefinitions_callback'), |
|
| 321 | $text); |
|
| 322 | return $text; |
|
| 323 | } |
|
| 324 | ||
| 325 | /** |
|
| 326 | * Strip link definition callback |
|
| @@ 1624-1646 (lines=23) @@ | ||
| 1621 | * @param string $text |
|
| 1622 | * @return string |
|
| 1623 | */ |
|
| 1624 | protected function stripFootnotes($text) { |
|
| 1625 | $less_than_tab = $this->tab_width - 1; |
|
| 1626 | ||
| 1627 | // Link defs are in the form: [^id]: url "optional title" |
|
| 1628 | $text = preg_replace_callback('{ |
|
| 1629 | ^[ ]{0,' . $less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1 |
|
| 1630 | [ ]* |
|
| 1631 | \n? # maybe *one* newline |
|
| 1632 | ( # text = $2 (no blank lines allowed) |
|
| 1633 | (?: |
|
| 1634 | .+ # actual text |
|
| 1635 | | |
|
| 1636 | \n # newlines but |
|
| 1637 | (?!\[.+?\][ ]?:\s)# negative lookahead for footnote or link definition marker. |
|
| 1638 | (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed |
|
| 1639 | # by non-indented content |
|
| 1640 | )* |
|
| 1641 | ) |
|
| 1642 | }xm', |
|
| 1643 | array($this, '_stripFootnotes_callback'), |
|
| 1644 | $text); |
|
| 1645 | return $text; |
|
| 1646 | } |
|
| 1647 | ||
| 1648 | /** |
|
| 1649 | * Callback for stripping footnotes |
|
| @@ 1844-1855 (lines=12) @@ | ||
| 1841 | * @param string $text |
|
| 1842 | * @return string |
|
| 1843 | */ |
|
| 1844 | protected function stripAbbreviations($text) { |
|
| 1845 | $less_than_tab = $this->tab_width - 1; |
|
| 1846 | ||
| 1847 | // Link defs are in the form: [id]*: url "optional title" |
|
| 1848 | $text = preg_replace_callback('{ |
|
| 1849 | ^[ ]{0,' . $less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
| 1850 | (.*) # text = $2 (no blank lines allowed) |
|
| 1851 | }xm', |
|
| 1852 | array($this, '_stripAbbreviations_callback'), |
|
| 1853 | $text); |
|
| 1854 | return $text; |
|
| 1855 | } |
|
| 1856 | ||
| 1857 | /** |
|
| 1858 | * Callback for stripping abbreviations |
|