protected function _makeFootnotes($matches)
    {
        // <li id="fn:1">
        //   ...
        //   <a href="#fnref:block" rev="footnote">&#8617;</a></p>
        // </li>
        // => <fn name="1">...</fn>
        // remove footnote link
        $fns = preg_replace('@\s*(&#160;\s*)?<a href="#fnref:[^"]+" rev="footnote"[^>]*>&#8617;</a>\s*@s', '', $matches[1]);
        // remove empty paragraph
        $fns = preg_replace('@<p>\s*</p>@s', '', $fns);
        // <li id="fn:1">...</li> -> <footnote nr="1">...</footnote>
        $fns = str_replace('<li id="fn:', '<fn name="', $fns);

        $fns = '<footnotes>' . $fns . '</footnotes>';

        return preg_replace('#</li>\s*(?=(?:<fn|</footnotes>))#s', '</fn>$1', $fns);
    }
protected function _makeFootnotes($matches)
    {
        // <li id="fn:1">
        //   ...
        //   <a href="#fnref:block" rev="footnote">&#8617;</a></p>
        // </li>
        // => <fn name="1">...</fn>
        // remove footnote link
        $fns = preg_replace('@\s*(&#160;\s*)?<a href="#fnref:[^"]+" rev="footnote"[^>]*>&#8617;</a>\s*@s', '', $matches[1]);
        // remove empty paragraph
        $fns = preg_replace('@<p>\s*</p>@s', '', $fns);
        // <li id="fn:1">...</li> -> <footnote nr="1">...</footnote>
        $fns = str_replace('<li id="fn:', '<fn name="', $fns);

        $fns = '<footnotes>' . $fns . '</footnotes>';

        return preg_replace('#</li>\s*(?=(?:<fn|</footnotes>))#s', '</fn>$1', $fns);
    }
protected function _makeFootnotes ( $ matches ) { // <li id="fn:1"> //   ... //   <a href="#fnref:block" rev="footnote">&#8617;</a></p> // </li> // => <fn name="1">...</fn> // remove footnote link $ fns = preg_replace ( '@\s*(&#160;\s*)?<a href="#fnref:[^"]+" rev="footnote"[^>]*>&#8617;</a>\s*@s' , '' , $ matches [ 1 ] ) ; // remove empty paragraph $ fns = preg_replace ( '@<p>\s*</p>@s' , '' , $ fns ) ; // <li id="fn:1">...</li> -> <footnote nr="1">...</footnote> $ fns = str_replace ( '<li id="fn:' , '<fn name="' , $ fns ) ; $ fns = '<footnotes>' . $ fns . '</footnotes>' ; return preg_replace ( '#</li>\s*(?=(?:<fn|</footnotes>))#s' , '</fn>$1' , $ fns ) ; }
replace HTML representation of footnotes with something more easily parsable

@note this is a callback to be used in parseString()

@param array $matches
@return string
replace HTML representation of footnotes with something more easily parsable