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

[BUG] TiddlyWiki 5.3.4 Prerelease: Transcluding Text References #8250

Closed kookma closed 2 weeks ago

kookma commented 2 weeks ago

Describe the bug

The transcludes filter operator causes a RSOD when a tiddler contains transcluding text references like {{!!title}} or {{!!created}}

Expected behavior

The transclude filter operator shall handle correctly the {{!!any-field}}

To Reproduce

  1. Go to https://tiddlywiki.com/prerelease/
  2. Create a new tiddler
  3. Put below script as text and save
    
    {{!!created}}
    ....

<$list filter="[all[current]transcludes[]]">

</$list>

5. See error:  Uncaught Linked List only accepts string values, not undefined

NOTE: The below code works fine

{{New Tiddler!!created}}

<$list filter="[all[current]transcludes[]]">

</$list>



### Screenshots

![image](https://github.com/Jermolene/TiddlyWiki5/assets/830394/82173062-c238-49dc-9f1b-0237d888d35d)

### TiddlyWiki Configuration

- Version 5.3.4p
- [Saving mechanism [e.g. Node.js, TiddlyDesktop, TiddlyHost etc]](https://tiddlywiki.com/prerelease/)
- Windows 11
- Edge 125

### Additional context

_No response_
saqimtiaz commented 2 weeks ago

@linonetwo could you please have a look? I suspect we need handling for text references in the traversal of the parse tree.

kookma commented 2 weeks ago

Another bug

I suggest that the transcludes filter operator should works like link. The current implementation is problematic. It should not recognize soft transclusions like

<$tiddler tiddler="One">
<$transclude $tiddler />
</$tiddler>

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

Strangely the below does not work

<$tiddler tiddler="One">
<$transclude $tiddler=<<currentTiddler>> />
</$tiddler>

<<list-links "[all[current]transcludes[]]">>
kookma commented 2 weeks ago

I propose only these forms shall be recognized:

{{mtTid}}
{{myTid||yourtemplate}}
{{myTid!!thatfield}}
{{myTid##thatindex}}

This {{!!myfield}} does not make sense, if it refers to host tiddler, then we do not need it If it refers to another tiddler, then some script is needed like <$tiddler tiddler=... or <$list filter="..." > ....

linonetwo commented 2 weeks ago

Thanks for testing, I should ignore the case where target tiddler is empty.

kookma commented 2 weeks ago

@linonetwo The below returns One, but it should not! Do you think this is an error with <$transclude $tiddler />

<$tiddler tiddler="One">
<$transclude $tiddler />
</$tiddler>

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

This one returns nothing

<$tiddler tiddler="One">
<$transclude />
</$tiddler>

<<list-links "[all[current]transcludes[]]">>
Jermolene commented 2 weeks ago

Thank you @kookma I really appreciate the work you're putting into testing this, very helpful!

kookma commented 2 weeks ago

The below returns One, but it should not! Do you think this is an error with <$transclude $tiddler />

<$tiddler tiddler="One">
<$transclude $tiddler />
</$tiddler>

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

This bug also exists with backtranscludes operator. So, if in tiddler One you put <<list-links "[all[current]backtranscludes[]]">> where the above code in in Tiddler Test, you get Text as backtransclude, but you should not get such answer!

linonetwo commented 2 weeks ago

@kookma Comparing with backlinks operator, and tagging operator, maybe we still need to include the tiddler itself. Maybe it will be useful someday? And user can always -[<currentTiddler>] from it.

kookma commented 2 weeks ago

@kookma Comparing with backlinks operator, and tagging operator, maybe we still need to include the tiddler itself. Maybe it will be useful someday? And user can always -[<currentTiddler>] from it.

Well, from bidirectional note taking point of view, refereeing to itself makes no sense to me! but let's what other says.