return $t ;
}
- function internalParse( $text, $linestart, $args = array() )
+ // set isMain=false if you call from a template etc. and don't want to do stuff
+ // like TOC insertion for that content
+ function internalParse( $text, $linestart, $args = array(), $isMain=true )
{
$fname = "Parser::internalParse";
wfProfileIn( $fname );
$text = $this->replaceExternalLinks( $text );
$text = $this->doTokenizedParser ( $text );
$text = $this->doTableStuff ( $text ) ;
- $text = $this->formatHeadings( $text );
+ $text = $this->formatHeadings( $text, $isMain );
$sk =& $this->mOptions->getSkin();
$text = $sk->transformContent( $text );
# Run full parser on the included text
$text = $this->strip( $text, $this->mStripState );
- $text = $this->internalParse( $text, (bool)$newline, $assocArgs );
+ $text = $this->internalParse( $text, (bool)$newline, $assocArgs, false );
if(!empty($newline)) $text = "\n".$text;
# Add the result to the strip state for re-inclusion after
*
*/
- /* private */ function formatHeadings( $text )
+ /* private */ function formatHeadings( $text, $isMain=true )
{
global $wgInputEncoding,$wgRequest,$wgOut;
# from the wikisource is stored in the title object.
# This TOC is now fetched and inserted here if it exists.
$collapsedtoc=$wgOut->getToc();
- if ($collapsedtoc && !$i) {
+ if ($collapsedtoc && !$i && $isMain) {
$full = $full.$collapsedtoc;
- }
- $wgOut->setToc("");
+ }
if( !empty( $head[$i] ) ) {
$full .= $head[$i];