protected function stripFootnotes($text)
{
#
# Strips link definitions from text, stores the URLs and titles in
# hash references.
#
$less_than_tab = $this->tab_width - 1;
# Link defs are in the form: [^id]: url "optional title"
$text = preg_replace_callback('{
^[ ]{0,' . $less_than_tab . '}\\[\\^(.+?)\\][ ]?: # note_id = $1
[ ]*
\\n? # maybe *one* newline
( # text = $2 (no blank lines allowed)
(?:
.+ # actual text
|
\\n # newlines but
(?!\\[.+?\\][ ]?:\\s)# negative lookahead for footnote or link definition marker.
(?!\\n+[ ]{0,3}\\S)# ensure line is not blank and followed
# by non-indented content
)*
)
}xm', array($this, '_stripFootnotes_callback'), $text);
return $text;
}