Special linking problem

65 views
Skip to first unread message

David Gifford

unread,
May 15, 2019, 2:23:28 PM5/15/19
to TiddlyWiki
Hi all

This is going to be hard for me to explain. So bear with me.

1. I am creating a long tiddler to be exported as static html.
2. The tiddler will use anchor id's so the user can navigate to sections of the tiddler.
3. I am using a list filter that transcludes the tiddlers based on a tag, and sorted by the contents of their 'id' field. Before the transcluded tiddler text is the tiddler title, wrapped in a header 1 class, with an anchor id pulled from the id field.

<$list filter="[tag[entry]sort[id]]"><hr><h1 id={{!!id}}><$view field="title"/></h1><hr><$transclude mode="block"/></$list>


4. The id fields contain the anchor id (e.g., #00.02) so the id's are added to the h1 (I use h1 because the CSS I use tells the printer to insert a page break at h1)

5. Up to now, I have been hand creating links to the id's into a table of contents.

<a href="##00.02">XXX</a>


So far, so good. Now here is the problem:

6. I want to replace my hand-crafted toc with an automated one, that contains links to the anchor id's.

I tried this:

<$list filter="[regexp:id[00.]sort[id]]"><a href="{{!!id}}"><$view field="title"/></a><br></$list>


But the problem is the <a href="{{!!id}}"> part. I need it to have two hashtags, because for links to anchors within a tiddler to work, the links have to have two hashtags. I tried the link widget too, and I can't get that to work, either.

So my question is: is there a way to replace <a href="{{!!id}}"> with something that adds a # before the id, so that the #00.02 becomes ##00.02?

Thanks for any help you can give.

Dave

Mark S.

unread,
May 15, 2019, 4:51:08 PM5/15/19
to TiddlyWiki
Possibly:

<$list filter="[regexp:id[00.]sort[id]]"><$list filter="[all[current]get[id]addprefix[#]]" variable=hashed><a href=<<hashed>>><$view field="title"/></a><br></$list></$list>

David Gifford

unread,
May 15, 2019, 7:04:31 PM5/15/19
to TiddlyWiki
Thanks Mark, that works splendidly!
Reply all
Reply to author
Forward
0 new messages