--- html.original.php 2014-03-13 11:16:37.000000000 +1300
+++ html.php 2014-03-13 11:13:34.000000000 +1300
@@ -758,9 +758,28 @@ function html_li_index($item){
*
* @author Andreas Gohr
*/
+// In order to alter the TOC when a user changes a tab, we
+// need some way to uniquely identify what titles lurk in
+// what tabs. Dokuwiki automagically labels headers with
+// tags - so if I use the same information here
+// they should match (and be unique etc)
+// - jmt12
+// At some stage the traditional 'link' attribute was (some-
+// times) replaced with information in 'hid'
+// - jmt12 2014MAR13
function html_li_default($item)
{
- return '';
+ $link = $item['link'];
+ if (isset($item['hid']) && !empty($item['hid']))
+ {
+ $link = $item['hid'];
+ }
+ $hash_pos = strpos($link, '#');
+ if ($hash_pos !== false)
+ {
+ $link = substr($link, $hash_pos + 1);
+ }
+ return '';
}
/**
@@ -784,7 +803,24 @@ function html_buildlist($data,$class,$fu
$ret = '';
foreach ($data as $item){
- if( $item['level'] > $level ){
+ // A reset closes all TOC items, all the way back to the top
+ if ($item['title'] == '#')
+ {
+ //close last item
+ $ret .= "\n";
+ while( $level > 0 && $open > 0 ){
+ //close higher lists
+ $ret .= "\n\n";
+ $level--;
+ $open--;
+ }
+ // open a dummy item list, although we don't output a list item
+ $ret .= "\n\n- ";
+ $level++;
+ $open++;
+ // skip to next item
+ continue;
+ }elseif( $item['level'] > $level ){
//open new list
for($i=0; $i<($item['level'] - $level); $i++){
if ($i) $ret .= "
- \n";