Everything in TW is built from tiddlers. It’s tiddlers all the way down. There is no shame in using tiddlers to build a checklist. A solution based on parsing the text of a tiddler is going to be a bit fragile or limited. Tags are the most natural way to build hierarchical structures – like sublists.
So pull a couple definitions out of the toc macros and roll your own. Tag with $:/tags/Macro:
\define toc-body-checkbox(tag,sort:"",itemClassFilter,exclude,path)
\whitespace trim
<ol class="tc-toc">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]""">
<$let item=<<currentTiddler>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
<$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]">
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
<li class=<<toc-item-class>>>
<$list filter="[all[current]toc-link[no]]" emptyMessage="<$checkbox tag='done'/> <$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}><<toc-caption>></$link>">
<<toc-caption>>
</$list>
<$macrocall $name="toc-body-checkbox" tag=<<item>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<excluded>> path=<<path>>/>
</li>
</$set>
</$set>
</$let>
</$list>
</ol>
\end
\define toc-checkbox(tag,sort:"",itemClassFilter:"", exclude)
\whitespace trim
<$let __tag__={{{ [<__tag__>is[blank]then<currentTiddler>else<__tag__>] }}} >
<$macrocall $name="toc-body-checkbox" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>>/>
</$let>
\end
That looks like a lot of code, but I actually only changed a few places.
Invoke like
<div class="tc-table-of-contents">
<<toc-checkbox "Contents" >>
</div>
And, voila! – you have your checklist with subtasks:
(There’s anomalies because of the nature of the data).
But if you want completed tasks to disappear, you can also invoke like:
<div class="tc-table-of-contents">
<<toc-checkbox "Contents" exclude:"[tag[done]]">>
</div>