inside your post.
Author: Yskin
Author URI: http://yskin.net/
Thanks to Table of Contents Generator(http://fucoder.com/code/toc-generator/).
License
=============================================================================
Copyright (C) 2006 yskin (email: yskins@gmail.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class TableOfContents {
var $toc;
var $stack;
var $start;
var $pos;
function toc_filter($content) {
// Return original content if no toc tag was found
if ( strpos($content, '') === false ) return $content;
// 类的对象将被重用,所以*必须*在filter里初始化!否则影响两次执行filter的页面,比如feed。
$this->toc = '';
$this->stack = array();
$this->start = 0;
$this->pos = 0;
$regex = '|