Jermolene / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.78k stars 1.16k forks source link

fix: always include self-referential transclusion #8257

Closed linonetwo closed 1 week ago

linonetwo commented 2 weeks ago

This will ignore current tiddler when collecting transclusions.

But this is different from the behavior of backlinks[] !


Update: restore old behavior: include itself when there is a self-referential transclusion, so it works the same as backlinks[]

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Jun 18, 2024 11:28am
kookma commented 2 weeks ago

This will ignore current tiddler when collecting transclusions.

But this is different from the behavior of backlinks[] !

I would recommend seeing the same behavior for all node filter operator! Different behavior makes it difficult to remember.

linonetwo commented 2 weeks ago

@kookma Have a try if you have time, I add more test so it have a higher chance that it works as expected.

kookma commented 2 weeks ago

I did some tests and all previous issues have gone!

The only odd behavior is both transcludes and backtranscludes retune the currentTiddler as a node! This is meaningless and confusing! So, I would recommend to solve this issue in the code!

That means if you create an empty tiddler with below scripts

<<list-links "[all[current]transcludes[]]">>

<<list-links "[all[current]backtranscludes[]]">>

Tiddlywiki will return

linonetwo commented 2 weeks ago

The behavior of links and backlinks is similar, but I will check it later, after I finish my burgerking.


Current behavior in this PR's preview site is the same as links[]

截屏2024-06-13 14 32 02
kookma commented 2 weeks ago

The behavior of links and backlinks is similar, but I will check it later, after I finish my burgerking.

I do not think so! For example, create a new tiddler with below script:

{{{ [all[current]links[]] }}}

It returns nothing!

pmario commented 2 weeks ago
{{{ [all[current]links[]] }}}

It returns nothing!

IMO wrong code. I think it should be: {{{ [all[current]backlinks[]join[, ]] }}}

If the current tiddler contains a link to itself, it has to report that link if backlinks[] is used. The same needs to be true for transcludes and backtranscludes

pmario commented 2 weeks ago

@kookma -- You are right - If this code is the only thing in a tiddler -> It should create empty lists.

<<list-links "[all[current]transcludes[]]">>

<<list-links "[all[current]backtranscludes[]]">>
linonetwo commented 2 weeks ago

Oh, why {{{ [all[current]backtranscludes[]] }}} won't output tiddler title, but <<list-links will...


It is same as <<list-links "[all[current]transclusssssdes[]]">>, the second part is ignored, and output the all[current] part. Maybe a bug of list-links macro?

This will output nothing <$list filter="[all[current]transcludes[]]" />

<<list-links "[all[current]links[]]">> works fine, so this must be my bug.

linonetwo commented 1 week ago

Added detailed rules to handle self-referencial cases, @kookma thank you for finding the test case.

Also outof professional ethics, I refactor links[] transcludes[] related wiki method to a file, so wiki.js won't be too long to edit. @Jermolene

linonetwo commented 1 week ago

Maybe it worth some time to look at linter related PRs!

Jermolene commented 1 week ago

Thanks @linonetwo

kookma commented 1 week ago

Thank you! All my previous tests are passed with latest release.