<$wikify> needs <$text> to honour tilde-based wikilink suppression

123 views
Skip to first unread message

David Nebauer

unread,
Jan 20, 2019, 8:12:28 AM1/20/19
to TiddlyWiki
In playing about with listing tiddlers I discovered that passing a value like "~WikiLink" to <$wikify> resulted in it being rendered as a wikilink despite the tilde. However, adding a <$text> widget caused <$wikify> to behave as I expected.

Here is an example:

<$set name="testVar" value="WikiLink ~NoWikiLink">

  <!-- I expect <$wikify> to honour the tilde, but it does not -->

  <$wikify name="testOutput1" text=<<testVar>> output="html">
    <<testOutput1>>
  </$wikify>

  <!-- I expect <$text> to have no effect, but it results in correct behaviour from <$wikify> -->

  <$wikify name="testOutput2" text="<$text text=<<testVar>>/>" output="html">
    <<testOutput2>>
  </$wikify>

</$set>

This resulted in the following output:

    WikiLink NoWikiLink


I don't understand why the <$wikify> widget does not honour the tilde.


I don't understand why adding a <$text> widget causes the <$wikify> widget to behave as expected.


I'm sure this makes sense to someone with intimate knowledge of how these widgets operate, but it is counterintuitive to newbies who expect <$wikify> to render wikitext, and <$text> to do the opposite, as described in TextWidget help.


Is there a better solution than the <$text> one I stumbled across?

Jeremy Ruston

unread,
Jan 20, 2019, 9:39:28 AM1/20/19
to tiddl...@googlegroups.com
I think that the problem here may be the use of double angle brackets to render <<testOutput1>> and <<testOutput2>> which causes the content of those variables to be wikified. In this case, you've already wikified the content of the variable, so you'll be wikifying it twice.

A modified version of your example with the addition of a couple of text widgets to render the variables as raw text lets you see what's going on:

<$set name="testVar" value="WikiLink ~NoWikiLink">

  <!-- I expect <$wikify> to honour the tilde, but it does not -->

  <$wikify name="testOutput1" text=<<testVar>> output="html">
<$text text=<<testOutput1>>/>
    <<testOutput1>>
  </$wikify>

  <!-- I expect <$text> to have no effect, but it results in correct behaviour from <$wikify> -->

  <$wikify name="testOutput2" text="<$text text=<<testVar>>/>" output="html">

<$text text=<<testOutput2>>/>
    <<testOutput2>>
  </$wikify>

</$set>

The output is:

<p><a class="tc-tiddlylink tc-tiddlylink-missing" href="#WikiLink">WikiLink</a> NoWikiLink</p>

WikiLink NoWikiLink

<p>WikiLink ~NoWikiLink</p>

WikiLink NoWikiLink

You can see how the displayed HTML is rendered as the output immediately following it.

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/d7b6c1ce-b05b-48cc-99af-999e347b50b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Nebauer

unread,
Jan 20, 2019, 3:54:00 PM1/20/19
to TiddlyWiki
Here is the actual use case where I concatenate a number of tiddlers describing plugins. For each tiddler I am using the concatenated content of a tiddler field as a heading, prefixing it with a '! ' heading token.

<$list filter="[tag[InstalledPlugin]sort[title]]">
  <$setvars pluginNames="[input[][][, ]]" _input={{!!plugin.names}}>
    <$wikify name="pluginsHeading" text="""! <$text text=<<pluginNames>>/>""" output="html">
      <<pluginsHeading>>
    </$wikify>
  </$setvars>
  <$transclude mode="block" tiddler=<<currentTiddler>>/>
</$list>

Here is where I needed the to use <$text> to ensure tildes in the field content are honoured.
Can the above snippet be simplified?

David Nebauer

unread,
Jan 21, 2019, 8:30:43 AM1/21/19
to TiddlyWiki
There does not appear to be a universal rule such as: "to prevent double wikification, always use a <$text> widget when loading a $<wikify> widget from a variable."

To show what I mean, consider this variation of Jeremy's test rig where I set the variable to a heading string:

<$set name="testVar" value="! My Heading">

  <$wikify name="testOutput1" text=<<testVar>> output="html">
    <$text text=<<testOutput1>>/>
    <<testOutput1>>
  </$wikify>

  <$wikify name="testOutput2" text="<$text text=<<testVar>>/>" output="html">
    <$text text=<<testOutput2>>/>
    <<testOutput2>>
  </$wikify>

</$set>

It results in this output:


<h1 class="">My Heading</h1>

My Heading

<p>! My Heading</p>

! My Heading



In this case the outcome is the opposite of the experience with tildes and wikitext: using the <$text> widget results in the "wrong" result.

Is there a universal technique to ensure any variable value will be rendered "correctly," or is it necessary to experiment with your input to determine whether to use <$text> with it or not?

David.

Thomas Elmiger

unread,
Jan 21, 2019, 4:05:39 PM1/21/19
to TiddlyWiki
Hi David

My wiki was not able to recognise a $setvars widget from your code two post above ...

But I also have good news for you. I cannot guarantee that this covers any case you throw at it, but it does cover wikilinks, the part of your first example that is sensitive for double wikification:

<$set name="testVar" value="WikiLink ~NoWikiLink">

  <!-- I expect <$wikify> to honour the tilde, ... -->


  <$wikify name="testOutput1" text=<
<testVar>
> output="html">
<$set name="tv-wikilinks" value="no">
    <
<testOutput1>>
</$set>
  </$wikify>

</$set>

<$set name="testVar" value="! Wiki Title – WikiTitle – ~WikiTitle">

 
<!-- I expect <$wikify> to honour the tilde, ... -->


  <$wikify name="testOutput1" text=<
<testVar>
> output="html">
<$set name="tv-wikilinks" value="no">
    <
<testOutput1>>
</$set>
  </$wikify>

</$set>

Is this what you are looking for?

Good luck!
Thomas

Jeremy Ruston

unread,
Jan 21, 2019, 4:12:02 PM1/21/19
to tiddl...@googlegroups.com
Hi David

The first wikify widget in the example below generates a string of HTML code "<h1 class="">My Heading</h1>” which you can see when it is directly displayed by the text widget. When you use the double angle bracket syntax to render it, that HTML string gets wikified a second time, and the <h1> HTML tag is rendered into the equivalent wikitext.

In the case of the second wikify widget, you’re wikifying a text widget that renders the plain text of the variable. Thus, the result stored in the testOutput2 variable is the plain text of the original testVar. Then, when you render it with double angle brackets, it is wikified again, but in inline mode, and so the “!” isn’t recognised as a heading because it is block level.

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.

Jeremy Ruston

unread,
Jan 21, 2019, 4:15:58 PM1/21/19
to tiddl...@googlegroups.com
Hi David

Can you show the output you’re trying to obtain and show the fields you’re using of the tiddlers tagged InstalledPlugins?

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.

David Nebauer

unread,
Jan 22, 2019, 6:59:23 AM1/22/19
to TiddlyWiki
Thanks, Thomas. That is another interesting workaround. It is certainly much more self-descriptive than my solution, so it would be easier to figure out what I did when I revisit this tiddler in six months and can't remember why I needed a workaround in the first place!

FYI, <$setvar> is from an excellent tobibeer plugin called setvars that, "sets multiple, complex variables based on attributes, filters, or conditionals." You only need it occasionally, but when you have a problem that fits its solution space it does the job superbly. The plugin also has a wide range of documented examples which are invaluable. In case you can't tell, I'm a huge fan!

David.

David Nebauer

unread,
Jan 22, 2019, 7:25:56 AM1/22/19
to TiddlyWiki
Hi Jeremy,

You're reinforcing my point that when using a <<variable>> with <$wikify> there are too many interactions going on for anyone other than a guru to understand, none of which are documented anywhere. And it appears you have to use different methods to render a heading or suppress wikilinks in <$wikify> via a <<variable>>, i.e., there is no single method that works for both scenarios. Everyday users like me dealing with this just have to experiment with various combinations of elements until we blunder into a solution, and/or call out for help on this list.

Thank you for your patient explanations of what has been happening with my tiddlyscript attempts. I'm sure it will benefit other users grappling with similar problems.

David.

Jeremy Ruston

unread,
Jan 22, 2019, 7:33:28 AM1/22/19
to tiddl...@googlegroups.com
You're reinforcing my point that when using a <<variable>> with <$wikify> there are too many interactions going on for anyone other than a guru to understand, none of which are documented anywhere. And it appears you have to use different methods to render a heading or suppress wikilinks in <$wikify> via a <<variable>>, i.e., there is no single method that works for both scenarios. Everyday users like me dealing with this just have to experiment with various combinations of elements until we blunder into a solution, and/or call out for help on this list.

The behaviours of everything that I’ve explained in this thread are documented. The trouble, as others have noted, is that the documentation can be hard at first because there is so much of it and there are so many interdependencies. The behaviour of the wikify widget, for example, is precisely described; it’s just that the description is too terse for most people, and needs more examples.

The reason why I asked what you were trying to achieve is because I’m puzzled by the use of the wikify widget. The wikify widget was added recently as a way to achieve certain relatively advanced effects that weren’t otherwise achievable, and getting ones head around it is undeniably confusing because it introduces multiple levels of wikification.

But, it’s quite rare that it is needed, and I’m not convinced that you need it at all for what you’re trying to do here, hence my question.

Thank you for your patient explanations of what has been happening with my tiddlyscript attempts. I'm sure it will benefit other users grappling with similar problems.

I do see a lot of unnecessary usage of the wikify widget and recognise that it is confusing to many people.

Best wishes

Jeremy.




David.

On Tuesday, 22 January 2019 06:42:02 UTC+9:30, Jeremy Ruston wrote:
Hi David

The first wikify widget in the example below generates a string of HTML code "<h1 class="">My Heading</h1>” which you can see when it is directly displayed by the text widget. When you use the double angle bracket syntax to render it, that HTML string gets wikified a second time, and the <h1> HTML tag is rendered into the equivalent wikitext.

In the case of the second wikify widget, you’re wikifying a text widget that renders the plain text of the variable. Thus, the result stored in the testOutput2 variable is the plain text of the original testVar. Then, when you render it with double angle brackets, it is wikified again, but in inline mode, and so the “!” isn’t recognised as a heading because it is block level.

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.

David Nebauer

unread,
Jan 22, 2019, 7:39:39 AM1/22/19
to TiddlyWiki
Hi Jeremy,

The first thing I do when I delve into an app I am going to both devote significant effort to and customise heavily, is document those customisations so I can rebuild the same environment from scratch. In the case of tiddlywiki I'm naturally documenting my customisations in tiddlywiki! These include the non-offical plugins I'm installing. For each plugin I create a tiddler decribing the plugin source, why I installed it, any configuration, and any other plugins it is dependent on. These tiddlers are tagged 'InstalledPlugin' and each has a field called 'plugin.names'. This field contains the name of the plugin(s) document in that tiddler, e.g., '[[Setvars]' and '[[Date Picker]] [[Moment]]'. The tiddlerscript is designed to concatenate all these plugin-describing tiddlers into a single tiddler, with each individual source tiddler represented by a heading consisting of the plugin names from the field joined by commas, and followed by the wikified content of the tiddler itself, e.g.,

---------------------------------------------

Plugin A, Plugin B

My wikified description of these plugins.

Plugin C

My wikified description of this plugin.

---------------------------------------------

I hope that made the purpose of my tiddlyscript clearer.

David.

Jeremy Ruston

unread,
Jan 22, 2019, 11:58:54 AM1/22/19
to tiddl...@googlegroups.com
Hi David

Great, that makes sense. One approach would be something like this:

<$list filter="[tag[InstalledPlugin]sort[title]]">

! <$list filter="[enlist{!!plugin.names}]" variable="name"><$text text=<<name>>/>, </$list>

{{!!text}}

</$list>

The problem is that it will include a trailing comma after the final plugin name. Fixing that makes things a bit more complicated:

<$list filter="[tag[InstalledPlugin]sort[title]]">

! <$list filter="[enlist{!!plugin.names}]" variable="name"><$text text=<<name>>/><$list filter="[enlist{!!plugin.names}last[]] -[<name>]">, </$list></$list>

{{!!text}}

</$list>

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.

David Nebauer

unread,
Jan 22, 2019, 4:30:51 PM1/22/19
to TiddlyWiki
Hi Jeremy. That works perfectly. Now I just have to unpack it and figure out how it works!

Thanks very much for your help with this. I figured there was a more elegant solution, but never would have figured that one out on my own.

David.
Reply all
Reply to author
Forward
0 new messages