This was such a pain to fix you have no idea - because there was a variation using H1 in a Book TOC that made it even worse.
Fixed for the next build. There's a lot of edits, so I recommend waiting, but in
vault/special_functions_postbit.php, find:
Code:
function table_of_contents(&$parser, $text, &$add_values, $toc_title = false, $shortstop = 0)
Replace with:
Code:
function table_of_contents(&$parser, $text, &$add_values, $toc_title = false, $shortstop = 0, $recurse = false)
Find:
Code:
$parser->edit_heading += count($vault->parser['toc_addlinks']);
$parser->edit_heading += count($add_values);
Replace with:
Code:
if (!empty($vault->parser['toc_addlinks']))
{
$addcount = count($vault->parser['toc_addlinks']);
$parser->edit_heading += count($vault->parser['toc_addlinks']);
}
if (!empty($add_values))
{
$parser->edit_heading += count($add_values);
}
Find:
Code:
$headline_list[] = $info;
if ($info['start_here'])
{
$last_key = $key;
$last_level = $info['level'];
unset($info['start_here']);
}
Replace with:
Code:
if ($info['start_here'])
{
if ($recurse === 0)
{
$base_level = $info['level'];
}
else if ($info['baseLevel'])
{
$base_level = $info['baseLevel'];
}
$last_key = $key;
if (is_numeric($info['setLevel']))
{
$last_level = $info['setLevel'];
if ($info['setLevel'] > 0)
{
$last_level--;
}
}
else if (!isset($info['setLevel']))
{
$last_level = $info['level'];
}
unset($info['start_here']);
}
$headline_list[] = $info;
Find:
Code:
$info['pos'] = $hpos;
if ($last_level)
{
$info['level'] += $last_level;
}
Add after:
Code:
if ($hix == $headline_count - 1 AND empty($vault->parser['toc_addlinks']))
{
special_toc_shortstop($info, $base_level, $recurse);
}
Find:
Code:
foreach ($vault->parser['toc_addlinks'] AS $key => $info)
{
if (isset($last_level))
{
$info['level'] += $last_level;
}
Add after:
Code:
if ($key == $addcount - 1)
{
special_toc_shortstop($info, $base_level, $recurse);
}
Find:
Code:
$headline_list = array_merge($headline_list, $temp_list);
Replace with:
Code:
$headline_list = $temp_list;
Find:
Code:
function construct_tocbits($list, $offset = 0, $depth = 1, $depthmark = '')
Add before:
Code:
function special_toc_shortstop(&$info, $base, $recurse)
{
$info['start_here'] = true;
if ($recurse === 0 OR $recurse === 1)
{
if (is_numeric($base))
{
$info['setLevel'] = $base + 1;
$info['baseLevel'] = $base;
}
else if ($recurse === 0)
{
$info['setLevel'] = 1;
}
else
{
$info['setLevel'] = false;
}
}
}
Find:
Code:
if ($list["$hix"]['level'] > $last)
Add before:
Code:
if (is_numeric($list[$hix - 1]['setLevel']))
{
if (isset($list[$hix - 1]['baseLevel']))
{
// use the base level if available
$list["$hix"]['level'] = $list[$hix - 1]['setLevel'];
}
else
{
// set the h1 equal to highest level from first block
$last = $list[$hix - 1]['setLevel'];
}
}
Find:
Code:
if ($depth2 < $depth)
Replace with:
Code:
if ($depth2 < $depth AND $depth != 1)
In
vault/special_class_postbit.php, find:
Code:
$oldsections = $vault->postbit['sections'];
foreach ($this->post['broken'] AS $i => $messagebit)
{
if (empty($vault->parser['toc_addlinks']))
{
$vault->parser['toc_addlinks'] = array();
}
$pre = count($vault->parser['toc_addlinks']);
$this->post['broken']["$i"] = table_of_contents(
$this->bbcode_parser,
$messagebit,
$headline_list,
$toc_title,
1
);
$vault->parser['toc_addlinks'] = $headline_list;
$headline_list = array();
$this->bbcode_parser->edit_heading -= count($vault->parser['toc_addlinks']) - $pre;
}
$headline_list = $vault->parser['toc_addlinks'];
Replace with:
Code:
$oldsections = $vault->postbit['sections'];
$brokencount = count($this->post['broken']);
if (!empty($headline_list))
{
$temper = true;
}
foreach ($this->post['broken'] AS $i => $messagebit)
{
if ($i == 0)
{
$q = 0;
}
else if ($i == $brokencount - 1)
{
$q = 2;
}
else
{
$q = 1;
}
$this->post['broken']["$i"] = table_of_contents(
$this->bbcode_parser,
$messagebit,
$headline_list,
$toc_title,
1,
$q
);
$this->bbcode_parser->edit_heading -= count($headline_list);
}