How to Compare shadows tiddlers content with tiddler!

I would like to Compare a shadows tiddlers content with the current tiddler value?

The following shows the content of the $:/DefaultTiddlers shadow (original value)

<$view tiddler="$:/core" subtiddler="$:/DefaultTiddlers"/>

returns: GettingStarted

This means we need to know tiddler which is the shadowsource

The Shadow Source can be identified, from the tiddler name

{{{[[$:/DefaultTiddlers]shadowsource[]] }}} 

returns: $:/core

Thus given the tiddler $:/DefaultTiddlers

><$view tiddler={{{[[$:/DefaultTiddlers]shadowsource[]] }}}  subtiddler="$:/DefaultTiddlers"/>

Returns its original content GettingStarted

The following returns Its current content

<$view tiddler="$:/DefaultTiddlers"/>
OR
{{$:/DefaultTiddlers}}

eg returns [[!Top actions]] Home !FIFO [[Today]]

But how do we capture the original content from;

<$view tiddler={{{[[$:/DefaultTiddlers]shadowsource[]] }}} subtiddler="$:/DefaultTiddlers"/>

such we can put it in a variable and ask for a comparison; like

<$diff-text source=<<original>> dest={{$:/DefaultTiddlers}}/>

We need to take two steps;

  1. Place the view widget subtiddler in a macro
  2. Wikify the macro before use
\define original() <$view tiddler={{{[[$:/DefaultTiddlers]shadowsource[]] }}} subtiddler="$:/DefaultTiddlers"/>

<$wikify name=original text="<<original>>">
   <$diff-text source=<<original>> dest={{$:/DefaultTiddlers}}/>
</$wikify>

This is why I ask can we not have another way to ask for the macro to be wikifield without using the wikify widget?

which makes this far more complex;

eg;

\define original() <$view tiddler={{{[[$:/DefaultTiddlers]shadowsource[]] }}} subtiddler="$:/DefaultTiddlers"/>

<$diff-text source=((original)) dest={{$:/DefaultTiddlers}}/>`
1 Like

Use the $set widget and the subtiddler attribute to assign the value of a shadow tiddlers text field to a variable.

Also useful for comparing tiddlers are the compareTiddlerText and compareTiddlers macros: https://tiddlywiki.com/#%24%3A%2Fcore%2Fmacros%2Fdiff

I believe they aren’t meant to be user facing macros but are useful and very straight forward to use.

4 Likes

Hm, I’m trying this for an overwritten $:/core/ui/EditorToolbar/italic but it doesn’t work for the text field:

<$set
  name=txt
  tiddler="$:/core"
  subtiddler="$:/core/ui/EditorToolbar/italic"
  field=text
>
<<txt>>
</$set>

It does work for e.g the tags field. Am I doing something wrong? How do I access the shadows text content?

Thanks!

Hi @twMat,

This code works on tiddlywiki.com:

<$set
  name=txt
  tiddler="$:/core"
  subtiddler="$:/core/ui/EditorToolbar/italic"
  field=text
>
<$text text=<<txt>>>
</$set>

I guess the simple variable reference <<txt>> your code uses wikifies the content of txt variable, and the result is empty (it’s only an <$action-sendmessage> widget).

Fred

@twMat because you touched this thread I revisited it with a new perspective,
Add this to @tw-FRed’s suggestion

The following retrieves the text field
<$view tiddler={{{ [[$:/DefaultTiddlers]shadowsource[]] }}} subtiddler="$:/DefaultTiddlers"/>

  • The field parameter should also work to extract the shows fields value as well.

To get a value and set a variable;

<$set name=original tiddler={{{ [[$:/DefaultTiddlers]shadowsource[]] }}}  subtiddler="$:/DefaultTiddlers">
original=<<original>>
</$set>
  • text is by default
  • The above field=“fieldname” parameters to retrieve any shadow field value.

I think an operator that allows get:shadow[fieldname] or has:shadow[fieldname]

Would fill a gap

2 Likes