@ -519,7 +519,15 @@ function get_posts($posts, $page = 1, $perpage = 0)
// Get the contents and convert it to HTML
// Get the contents and convert it to HTML
$post -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$post -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$toc = explode ( '<!--toc-->' , $post -> body );
$toc = explode ( '<!--toc-->' , $post -> body );
if ( isset ( $toc [ '1' ])) {
if ( isset ( $toc [ '1' ])) {
$state = config ( 'toc.state' );
if ( $state !== 'open' ) {
$state = 'close' ;
}
$label = config ( 'toc.label' );
if ( empty ( $label )) {
$label = 'Table of Contents' ;
}
$load = <<< EOF
$load = <<< EOF
< script >
< script >
document . addEventListener ( " DOMContentLoaded " , function () {
document . addEventListener ( " DOMContentLoaded " , function () {
@ -533,7 +541,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
});
});
</ script >
</ script >
EOF ;
EOF ;
$post -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.post-' . $post -> date . '" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents </span></summary><div class="inner"><div class="toc" id="toc.post-' . $post -> date . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
$post -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.post-' . $post -> date . '" style="display:none;" ><details ' . $state . ' ><summary title="TOC"><span class="details">' . $label . ' </span></summary><div class="inner"><div class="toc" id="toc.post-' . $post -> date . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
}
}
// Convert image tags to figures
// Convert image tags to figures
@ -601,7 +609,15 @@ function get_pages($pages, $page = 1, $perpage = 0)
$post -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$post -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$toc = explode ( '<!--toc-->' , $post -> body );
$toc = explode ( '<!--toc-->' , $post -> body );
if ( isset ( $toc [ '1' ])) {
if ( isset ( $toc [ '1' ])) {
$state = config ( 'toc.state' );
if ( $state !== 'open' ) {
$state = 'close' ;
}
$label = config ( 'toc.label' );
if ( empty ( $label )) {
$label = 'Table of Contents' ;
}
$load = <<< EOF
$load = <<< EOF
< script >
< script >
document . addEventListener ( " DOMContentLoaded " , function () {
document . addEventListener ( " DOMContentLoaded " , function () {
@ -615,7 +631,7 @@ function get_pages($pages, $page = 1, $perpage = 0)
});
});
</ script >
</ script >
EOF ;
EOF ;
$post -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-' . $post -> slug . '" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents </span></summary><div class="inner"><div class="toc" id="toc.page-' . $post -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
$post -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-' . $post -> slug . '" style="display:none;" ><details ' . $state . ' ><summary title="TOC"><span class="details">' . $label . ' </span></summary><div class="inner"><div class="toc" id="toc.page-' . $post -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
}
}
if ( config ( 'views.counter' ) == 'true' ) {
if ( config ( 'views.counter' ) == 'true' ) {
@ -690,6 +706,14 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
$toc = explode ( '<!--toc-->' , $post -> body );
$toc = explode ( '<!--toc-->' , $post -> body );
if ( isset ( $toc [ '1' ])) {
if ( isset ( $toc [ '1' ])) {
$state = config ( 'toc.state' );
if ( $state !== 'open' ) {
$state = 'close' ;
}
$label = config ( 'toc.label' );
if ( empty ( $label )) {
$label = 'Table of Contents' ;
}
$load = <<< EOF
$load = <<< EOF
< script >
< script >
document . addEventListener ( " DOMContentLoaded " , function () {
document . addEventListener ( " DOMContentLoaded " , function () {
@ -703,7 +727,7 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
});
});
</ script >
</ script >
EOF ;
EOF ;
$post -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.subpage-' . $post -> slug . '" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents </span></summary><div class="inner"><div class="toc" id="toc.subpage-' . $post -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
$post -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.subpage-' . $post -> slug . '" style="display:none;" ><details ' . $state . ' ><summary title="TOC"><span class="details">' . $label . ' </span></summary><div class="inner"><div class="toc" id="toc.subpage-' . $post -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
}
}
if ( config ( 'views.counter' ) == 'true' ) {
if ( config ( 'views.counter' ) == 'true' ) {
@ -984,7 +1008,15 @@ function read_category_info($category)
$desc -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$desc -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$toc = explode ( '<!--toc-->' , $desc -> body );
$toc = explode ( '<!--toc-->' , $desc -> body );
if ( isset ( $toc [ '1' ])) {
if ( isset ( $toc [ '1' ])) {
$state = config ( 'toc.state' );
if ( $state !== 'open' ) {
$state = 'close' ;
}
$label = config ( 'toc.label' );
if ( empty ( $label )) {
$label = 'Table of Contents' ;
}
$load = <<< EOF
$load = <<< EOF
< script >
< script >
document . addEventListener ( " DOMContentLoaded " , function () {
document . addEventListener ( " DOMContentLoaded " , function () {
@ -998,7 +1030,7 @@ function read_category_info($category)
});
});
</ script >
</ script >
EOF ;
EOF ;
$desc -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.taxonomy-' . $desc -> slug . '" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents </span></summary><div class="inner"><div class="toc" id="toc.taxonomy-' . $desc -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
$desc -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.taxonomy-' . $desc -> slug . '" style="display:none;" ><details ' . $state . ' ><summary title="TOC"><span class="details">' . $label . ' </span></summary><div class="inner"><div class="toc" id="toc.taxonomy-' . $desc -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
}
}
$desc -> description = get_content_tag ( " d " , $content , get_description ( $desc -> body ));
$desc -> description = get_content_tag ( " d " , $content , get_description ( $desc -> body ));
@ -1230,6 +1262,14 @@ function get_author($name)
$toc = explode ( '<!--toc-->' , $author -> about );
$toc = explode ( '<!--toc-->' , $author -> about );
if ( isset ( $toc [ '1' ])) {
if ( isset ( $toc [ '1' ])) {
$state = config ( 'toc.state' );
if ( $state !== 'open' ) {
$state = 'close' ;
}
$label = config ( 'toc.label' );
if ( empty ( $label )) {
$label = 'Table of Contents' ;
}
$load = <<< EOF
$load = <<< EOF
< script >
< script >
document . addEventListener ( " DOMContentLoaded " , function () {
document . addEventListener ( " DOMContentLoaded " , function () {
@ -1243,7 +1283,7 @@ function get_author($name)
});
});
</ script >
</ script >
EOF ;
EOF ;
$author -> about = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.profile-' . $author -> slug . '" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents </span></summary><div class="inner"><div class="toc" id="toc.profile-' . $author -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
$author -> about = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.profile-' . $author -> slug . '" style="display:none;" ><details ' . $state . ' ><summary title="TOC"><span class="details">' . $label . ' </span></summary><div class="inner"><div class="toc" id="toc.profile-' . $author -> slug . '"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
}
}
$author -> body = $author -> about ;
$author -> body = $author -> about ;
@ -1296,7 +1336,15 @@ function get_frontpage()
// Get the contents and convert it to HTML
// Get the contents and convert it to HTML
$front -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$front -> body = MarkdownExtra :: defaultTransform ( remove_html_comments ( $content ));
$toc = explode ( '<!--toc-->' , $front -> body );
$toc = explode ( '<!--toc-->' , $front -> body );
if ( isset ( $toc [ '1' ])) {
if ( isset ( $toc [ '1' ])) {
$state = config ( 'toc.state' );
if ( $state !== 'open' ) {
$state = 'close' ;
}
$label = config ( 'toc.label' );
if ( empty ( $label )) {
$label = 'Table of Contents' ;
}
$load = <<< EOF
$load = <<< EOF
< script >
< script >
document . addEventListener ( " DOMContentLoaded " , function () {
document . addEventListener ( " DOMContentLoaded " , function () {
@ -1310,7 +1358,7 @@ function get_frontpage()
});
});
</ script >
</ script >
EOF ;
EOF ;
$front -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-front" style="display:none;" ><details><summary title="TOC"><span class="details">Table of Contents </span></summary><div class="inner"><div class="toc" id="toc.page-front"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
$front -> body = $toc [ '0' ] . $load . '<div class="toc-wrapper" id="toc-wrapper.page-front" style="display:none;" ><details ' . $state . ' ><summary title="TOC"><span class="details">' . $label . ' </span></summary><div class="inner"><div class="toc" id="toc.page-front"></div></div></details></div><script src="' . site_url () . 'system/resources/js/toc.js"></script>' . $toc [ '1' ];
}
}
} else {
} else {
$front -> title = 'Welcome' ;
$front -> title = 'Welcome' ;