formatting macro breaks backlinks: alternatives?

93 views
Skip to first unread message

Linda Moss

unread,
Feb 18, 2019, 1:40:38 PM2/18/19
to TiddlyWiki
Hi!

There's a certain kind of link I wanted formatted a certain way, so I created a macro:

<<myMacro "link to format">>

which applied the necessary formatting.

But of course, this broke all my backlinks. So I changed it to:

<<myMacro [[link to format]]>>

but because the link is an argument to a macro, it is still unrecognized, and my backlinks are still broken.

Is there a way to apply formatting to a certain kind of link (without putting the formatting inline every single time) and still have the backlinks work?


Thanks!

PS: I also went down a rabbit trail of trying to regain the backlinks by way of a macro calling a list filtered with "[!is[system]regexp:text[$term$]]", because the text of these links is unlikely to appear anywhere other than the title of the linked tiddler and places intentionally referencing that title. However, most of these links would need to be escaped, and I couldn't figure out how to get escaperegexp[] to work inside the filter to escape $term$ before it was searched.

Now, starting fresh, I might name all the tiddlers that would be receiving such a link so as to prevent the need for escaperegexp[], but as it stands, there are over a thousand of them, (and they follow a specific naming convention that other things are based).

PMario

unread,
Feb 18, 2019, 6:47:13 PM2/18/19
to TiddlyWiki
Hi Linda,

How does you macro look like?

-mario

TonyM

unread,
Feb 18, 2019, 9:31:10 PM2/18/19
to TiddlyWiki
Linda,

Is it too much for you to put 

<<myMacro [[link to format]]>> [[link to format]] in your tiddler?

Or you may be able to keep [[link to format]] in your tiddler only inside a html div with a display none style, which will still act as a link and generate backlinks?

Regards
Tony

TonyM

unread,
Feb 18, 2019, 9:36:45 PM2/18/19
to TiddlyWiki
For Example, "tested"

<<myMacro [[link to format]]>> <span style="display:none;">[[link to format]]</span>

Info > References on [[Link to format]]
shows when the above span is used.

Regards
Tony

TonyM

unread,
Feb 18, 2019, 10:10:35 PM2/18/19
to TiddlyWiki
And also,

You could make an edit toolbar button such that you highlight tiddlername and it replaces it with;

<<myMacro [[tiddlername]]>> <span style="display:none;">[[tiddlername]]</span>

Regards
Tony

Jeremy Ruston

unread,
Feb 19, 2019, 7:10:09 AM2/19/19
to tiddl...@googlegroups.com
Hi Linda

The mechanism for tracking links for backlinks, missing and orphan tiddlers is pretty simplistic for performance reasons. It parses each tiddler and looks for direct links within it. Computed links that are only resolved at render time will not be detected. To track computed links we'd have to render every tiddler to find them, and rendering is slow.

One possible JavaScirpt approach to fixing this might be to make a plugin that replaces the link detection code in wiki.getTiddlerLinks() and detects invocations of "myMacro" instead or as well as looking for invocations of the link widget.

Best wishes

Jeremy


--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/97d844c4-5b36-44bf-872c-0d294fc62d70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Linda Moss

unread,
Feb 19, 2019, 10:27:07 AM2/19/19
to TiddlyWiki
@PMario --

Enter code here...
\define mySource(source:"")
@@.my-custom-source-header
!!!! $source$
@@

\end

(originally with double-brackets around the $source$) And then the CSS file applies block-level formatting to make the entire line slightly colored and slightly darker than the background, in order to create a visual break which makes it easier for me to read, and set the bottom border of the heading to slightly darker than that.

I think I'm making this more complicated than it needs to be, and I should just add a link below the header rather than linking the header. (Not sure why it hadn't occurred to me to separate them before. But @Jeremy, I'll definitely keep that hack in mind, in case the redundancy really starts to bother me. :)

Thanks everyone!

PMario

unread,
Feb 19, 2019, 12:24:00 PM2/19/19
to TiddlyWiki


On Tuesday, February 19, 2019 at 1:10:09 PM UTC+1, Jeremy Ruston wrote:
....

One possible JavaScirpt approach to fixing this might be to make a plugin that replaces the link detection code in wiki.getTiddlerLinks() and detects invocations of "myMacro" instead or as well as looking for invocations of the link widget.

That's exactly, what the alias-backlink handling in the uni-link plugin does. ...

It also replaces standard links like: [[standard link]] with an <<uni-link>> macro ...... BUT the backlink detection here is also a bit hacky. :/ And at the moment, It can't handle backlinks as described in the OP.

I'll need to think about it. ...

have fun!
mario

PMario

unread,
Feb 20, 2019, 10:47:45 AM2/20/19
to tiddl...@googlegroups.com
Hi,


eg:

!!!!.x [[link to]]

 - where x will be the new class, instead of .my-custom-source-header which is much more complicated to write.
 - and x would work with every header, if you want to

just a thought

have fun!
mario
Reply all
Reply to author
Forward
0 new messages