| @@ 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 |
|
| @@ 278-308 (lines=31) @@ | ||
| 275 | * @param string $text |
|
| 276 | * @return string |
|
| 277 | */ |
|
| 278 | protected function stripLinkDefinitions($text) { |
|
| 279 | $less_than_tab = $this->tab_width - 1; |
|
| 280 | ||
| 281 | // Link defs are in the form: ^[id]: url "optional title" |
|
| 282 | $text = preg_replace_callback('{ |
|
| 283 | ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
| 284 | [ ]* |
|
| 285 | \n? # maybe *one* newline |
|
| 286 | [ ]* |
|
| 287 | (?: |
|
| 288 | <(.+?)> # url = $2 |
|
| 289 | | |
|
| 290 | (\S+?) # url = $3 |
|
| 291 | ) |
|
| 292 | [ ]* |
|
| 293 | \n? # maybe one newline |
|
| 294 | [ ]* |
|
| 295 | (?: |
|
| 296 | (?<=\s) # lookbehind for whitespace |
|
| 297 | ["(] |
|
| 298 | (.*?) # title = $4 |
|
| 299 | [")] |
|
| 300 | [ ]* |
|
| 301 | )? # title is optional |
|
| 302 | (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
| 303 | (?:\n+|\Z) |
|
| 304 | }xm', |
|
| 305 | array($this, '_stripLinkDefinitions_callback'), |
|
| 306 | $text); |
|
| 307 | return $text; |
|
| 308 | } |
|
| 309 | ||
| 310 | /** |
|
| 311 | * Strip link definition callback |
|
| @@ 1594-1616 (lines=23) @@ | ||
| 1591 | * @param string $text |
|
| 1592 | * @return string |
|
| 1593 | */ |
|
| 1594 | protected function stripFootnotes($text) { |
|
| 1595 | $less_than_tab = $this->tab_width - 1; |
|
| 1596 | ||
| 1597 | // Link defs are in the form: [^id]: url "optional title" |
|
| 1598 | $text = preg_replace_callback('{ |
|
| 1599 | ^[ ]{0,' . $less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1 |
|
| 1600 | [ ]* |
|
| 1601 | \n? # maybe *one* newline |
|
| 1602 | ( # text = $2 (no blank lines allowed) |
|
| 1603 | (?: |
|
| 1604 | .+ # actual text |
|
| 1605 | | |
|
| 1606 | \n # newlines but |
|
| 1607 | (?!\[.+?\][ ]?:\s)# negative lookahead for footnote or link definition marker. |
|
| 1608 | (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed |
|
| 1609 | # by non-indented content |
|
| 1610 | )* |
|
| 1611 | ) |
|
| 1612 | }xm', |
|
| 1613 | array($this, '_stripFootnotes_callback'), |
|
| 1614 | $text); |
|
| 1615 | return $text; |
|
| 1616 | } |
|
| 1617 | ||
| 1618 | /** |
|
| 1619 | * Callback for stripping footnotes |
|
| @@ 1779-1790 (lines=12) @@ | ||
| 1776 | * @param string $text |
|
| 1777 | * @return string |
|
| 1778 | */ |
|
| 1779 | protected function stripAbbreviations($text) { |
|
| 1780 | $less_than_tab = $this->tab_width - 1; |
|
| 1781 | ||
| 1782 | // Link defs are in the form: [id]*: url "optional title" |
|
| 1783 | $text = preg_replace_callback('{ |
|
| 1784 | ^[ ]{0,' . $less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
| 1785 | (.*) # text = $2 (no blank lines allowed) |
|
| 1786 | }xm', |
|
| 1787 | array($this, '_stripAbbreviations_callback'), |
|
| 1788 | $text); |
|
| 1789 | return $text; |
|
| 1790 | } |
|
| 1791 | ||
| 1792 | /** |
|
| 1793 | * Callback for stripping abbreviations |
|