How to avoid (or define) the target attribute in external links?

65 views
Skip to first unread message

Michaelsy

unread,
Jul 4, 2020, 6:09:46 AM7/4/20
to TiddlyWiki
When I create an external link in the wikitext, for example:

[ext [Open file|../20200703224247/index.html]]

then the target attribute in the HTML-link is set to "_blank". How can I avoid this? I would prefer not to have a target attribute for external links, system-wide.

Thanks in advance!

Mat

unread,
Jul 4, 2020, 6:17:20 AM7/4/20
to TiddlyWiki
One way would be to create a macro based around the html tag. Of course, then you wouldn't user the [ext[]] syntax, but the macro instead.

<:-)

Eric Shulman

unread,
Jul 4, 2020, 6:44:01 AM7/4/20
to TiddlyWiki
If there was no target="..." for external links, then clicking such a link would immediately
exit the TiddlyWiki you are viewing (unless you had unsaved changes).  This would discard
whatever context existed (e.g. currently opened tiddlers, search keywords,
and any $:/state/... tiddlers).  I suppose there might be a use-case where that would be
appropriate, but in general it seems like it shouldn't do this by default.

I suppose it could be useful to extend the "[ext[...]]" syntax to permit specification of
a target, i.e., "[ext target=... [...]]".  If this was added, then you could write
"[ext target=_self [...]]" to force a link to open in the same tab/window.

However, if you really want an external link to open in the same tab/window,
then you can already use standard HTML syntax, which is simple enough:
<a href="../20200703224247/index.html">Open file</a>

Perhaps if you explain your use-case a bit more, it might shed some light
on why you want this behavior in the first place.

-e

TW Tones

unread,
Jul 4, 2020, 6:48:42 AM7/4/20
to TiddlyWiki
Michaelsy,

May I ask what you are trying to achieve ? Many would consider the target of _blank is "without a target attribute".  

Do you mean you want to open it in the current tab? If so _top works and will break out of an iframe.

Regards
Tony

Michaelsy

unread,
Jul 4, 2020, 8:04:50 AM7/4/20
to TiddlyWiki
Ok, my use case: I use TiddlyWiki as a replacement for an HTML editor with which I always create a single (more less independent) HTLM page. I.e. one TiddlyWiki file = one single HTML page. (At least I am currently checking if this is a reasonable way for me).

This page is a part of a scrapbook, which basically consists of many thousands of archived web pages. Within these many pages, there are some (50?) pages created by myself, where I store notes and my own documentation on the respective topic.

(The Scrapbook is built with the Firefox add-on "ScrapBook X" (see: https://github.com/danny0838/firefox-scrapbook/wiki) )

The navigation within the scrapbook is mainly done by a sidebar (including search functions and some kind of tagging) and links on my own HTML pages.

Therefore the external links in question are actually internal links.

And in this use case there is practically no such thing as a context that could be discarded. And if that should be the case later (if I use TiddlyWiki more extensively), I can always have the link opened by an hotkey in another tab.

TW Tones

unread,
Jul 4, 2020, 8:41:40 AM7/4/20
to TiddlyWiki
Michaelsy,

Thanks for sharing. I will consider your case example at length tomorrow. The first thing that comes to mind is using a template and a single tiddler for each html page.

Regards
Tony

Michaelsy

unread,
Jul 5, 2020, 2:35:10 AM7/5/20
to tiddl...@googlegroups.com
Thank you very much for your answers! Further suggestions with other approaches are still welcome. (I still like to learn more.)


Am Samstag, 4. Juli 2020 12:44:01 UTC+2 schrieb Eric Shulman:
However, if you really want an external link to open in the same tab/window,
then you can already use standard HTML syntax, which is simple enough:
<a href="../20200703224247/index.html">Open file</a>

I had already tried that before I asked my question here. But that failed because I tried something similar to this one:
<a href="../20200703224247/index.html">OpenFile</a>

As I've realized in the meantime, the CamelCase recognition has worked here and a wiki link inside the HTML was generated, which was not necessarily to be expected.

There is probably no way to explicitly mark HTML code as such? But (meanwhile) I know the (two?) options to turn off CamelCase. One way:
<a href="../20200703224247/index.html">~OpenFile</a>

Reply all
Reply to author
Forward
0 new messages