diff --git a/core/wiki/macros/toc.tid b/core/wiki/macros/toc.tid
index 982eb37b8..86dcedc44 100644
--- a/core/wiki/macros/toc.tid
+++ b/core/wiki/macros/toc.tid
@@ -1,21 +1,31 @@
title: $:/core/macros/toc
tags: $:/tags/Macro
-\define toc(tag,sort:"")
+\define toc-body(rootTag,tag,sort:"")
-<$list filter="[tag[$tag$]$sort$]">
+<$list filter="""[tag[$tag$]$sort$]""">
-
<$list filter="[is[current]toc-link[no]]" emptyMessage="<$link><$view field='caption'><$view field='title'/>$view>$link>">
<$view field="caption">
<$view field="title"/>
$view>
$list>
-<$macrocall $name="toc" tag=<> sort="$sort$"/>
+
+<$list filter="""[all[current]] -[[$rootTag$]]""">
+
+<$macrocall $name="toc-body" rootTag="""$rootTag$""" tag=<> sort="$sort$"/>
+
+$list>
+
$list>
\end
+\define toc(tag,sort:"")
+<>
+\end
+
\define toc-linked-expandable-body(tag,sort:"")
<$set name="toc-state" value=<>>