On Saturday, June 20, 2020 at 5:04:11 AM UTC-7, Saq Imtiaz wrote:
>
> @Rachel there are several ways to do this and a lot depends on things like 
> whether you expect to add more top level tiddlers under Contents (like a #6 
> after 1-5), and whether the hierarchy only goes one level deep or further.
> Assuming the structure of the Contents tiddler is fixed and only goes down 
> one level, the following filter will identify your tiddlers:
>

Here's a little macro that will "walk" a TOC tree of any depth and return a 
flat list of tiddler titles, in the order they occur in the TOC:
\define toc-list(here,exclude,max,level:"1")
<$list filter="""[tag[$here$]] $exclude$ -[[$here$]]""">
   <$text text="[["/><<currentTiddler>><$text text="]]"/><br>
   <$reveal default="$level$" type="nomatch" text="$max$">
      <$macrocall $name="toc-list" here=<<currentTiddler>> max="$max$" 
exclude="""$exclude$ -[[$here$]]""" level={{{ [[$level$]add[1]] }}}/>
   </$reveal>
</$list>
\end 

To see the list, starting with a top-level of tiddlers tagged with 
"Contents", simply write:
<<toc-list here:"Contents">>
* The "exclude" param is automatically calculated internally to prevent 
infinite recursion if there are any circular references.  It can also be 
provided as an explicit input parameter in the macro call to prevent 
specific branches of the tree from being traversed.
* The "max" param is optional and limits the depth of traversal.  It works 
with the "level" param which is calculated internally to track how deep the 
traversal has gone.

Thus, if you want to get a list that excludes tiddler tagged as "Task", you 
could write:
<<toc-list here:"Contents" exclude:"Task">>

and if you want to limit the depth to 3, you could write:
<<toc-list here:"Contents" max:"3">>

Of course, this is only the first step in the process of exporting the 
tiddlers, but it does produce a list in the correct order.  The remaining 
task is to use this result as input to an export process.

For example, you could produce this list in a tiddler, and then -- as Saq 
has already suggested, simply copy/paste the result into the 
$:/AdvancedSearch Filter input field.  Then press the "export" button and 
choose "static HTML".

It should also be possible to automate those steps so you can just press a 
button and get the desired output with one click.  I'll fiddle about a bit 
and see if I can provide a simple bit of button/action syntax that does 
this.  Right now I'm not feeling very well, so it will have to wait a bit 
for me to get some rest.

-e


-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1c8d7fa5-fc53-42c3-9645-84770369641eo%40googlegroups.com.

Reply via email to