Hello Martin,
Here is my approach:
I've tweaked the toc macro to populate the "list" field of a tiddler (TOC-export) with each tiddler instead of displaying its title.
As I use an action widget, I have encapsulated the call of this macro inside a button, in the TOC-Export tiddler. Clicking the button populate the list field of the TOC-export tiddler with all tiddlers in the TableOfContents, in their order of appearance (however, if a tiddler appears several times in the TOC, it will be present only once in the list field).
Finally, in the advance search, I can use the
[list[TOC-export]] filter to export the result in static HTML.
Here is the content of my TOC-export tiddler:
\define current() [[$(currentTiddler)$]]
\define toc-export(rootTag,tag,sort:"")
<$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$]""">
<$action-listops $tiddler="TOC-export" $field="list" $subfilter="+[append<current>]"/>
<$list filter="""[all[current]] -[[$rootTag$]]""">
<$macrocall $name="toc-export" tag=<<currentTiddler>> rootTag="""$rootTag$""" sort="""$sort$"""/>
</$list>
</$list>
\end
<$button>
<<toc-export rootTag:"TableOfContents" tag:"TableOfContents">>
Export
</$button>
There may be an easier way to pass the current tiddler to the action-listops widget, but using directly the <<currentTiddler>> variable results in each word of the current title being added independently into the list.
The call of the toc-export macro has both the rootTag and the tag parameter because I used the toc-body macro as a model, instead of the toc macro which only calls the toc-body macro to hide the rootTag parameter to the user.