Generating HTML attribute strings from wikitext?

92 views
Skip to first unread message

Evan Balster

unread,
May 30, 2015, 5:29:37 PM5/30/15
to tiddl...@googlegroups.com
Hello, all --


Is there a simple way to use plaintext data from wikitext, which can then be fed into HTML (or SVG) attributes?  If not, could I lobby for one?

The gulf of execution here looks like this:

<!-- One of a series of thin SVGs used to compare characters' lifespans -->
<svg width="12px" height="500px" style="background-color: #FFFFFF;">
<$set>
<path d={{||_GenealogyLifespanPath}}>  contrary to what the docs suggest, this is a text reference and not a transclusion, and silently fails.
</$set>
</svg>

I understand why rendering WikiText to attribute strings could be a massive headache for widgets, but I suspect that reasoning doesn't apply to HTML.


Context:

After using TiddlyWiki classic as a notetaking format for a few years, I upgraded to TW5 a few months ago and have been going nuts with the automation features.  I have a somewhat complex story wiki, and it has been very helpful for eliminating information redundancy through transclusion, generating chronologies and character lists, et cetera.  My latest pursuit is finding a way to generate visual timelines and genealogies, and SVG generation seems to be the best approach.

The lack of wikitext parsing in attribute string macros has tripped me up many times before, and in this case the need to perform indirect transclusions (ideally with the conditional logic and default values I use elsewhere!) is making what I want to do very difficult.  I'm also lamenting the apparent impossibility of using <$list> to generate SVG paths.

As a general bit of TW5 feedback, it took me a long time to grasp the complex relationship between macros, widgets and transclusions -- and as you can imagine, I'm still learning.  :)

Richard Smith

unread,
May 30, 2015, 9:59:49 PM5/30/15
to tiddl...@googlegroups.com
Hi Evan,

It's not really an answer to your question but if you want something that will work now, you might try this;

define a macro;

\define insertsvg(path)
<svg height="210" width="400">
  <path d="$path$" />
</svg>
\end

and call it using the macrocall syntax

<$macrocall $name="insertsvg" path={{myPath}}/>

seems to produce the desired result - 

but doesn't really answer your question.

Regards,
Richard

Evan Balster

unread,
May 30, 2015, 10:07:47 PM5/30/15
to tiddl...@googlegroups.com
Hey, Richard --

Unfortunately "myPath" is not parsed for WikiText features in your example.  The "text" field is pulled directly into the attribute with no further processing.  (I use the text widget here for simplicity, but the behavior appears to be the same with any HTML attribute.)

 Inline image 1

Inline image 2

Regards,
Evan

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/S-5vLIqWxWk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/58cbcad1-b8a2-4981-a58f-38b7567754e9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Richard Smith

unread,
May 31, 2015, 3:36:11 AM5/31/15
to tiddl...@googlegroups.com
Hi Evan,

I understand now - you want to be able to compose the svg 'path' using a filter and so wish to transclude the output of the filter into an attribute. After some playing just now, I would concur that this doesn't seem possible on the face of things.

Jed or someone else who has the serious filter-fu may know of newer solutions, but I think (may be wrong) this limitation is what caused Matabele to write the $makelist widget which sets the value of a field according to a filter output - you can then refer to this value by transclusion.

You should be able to find Matabele's widget by searching the forum - I'm not sure if it is up to date etc.

Regards,
Richard

ETA: I just dug out the widget and I guess you have to tie it to a button for it to run, which means that you'd have to click at least one button to update everything, which might mean it's still not a great solution for you

Evan Balster

unread,
May 31, 2015, 11:36:59 AM5/31/15
to tiddlywiki
Hey Richard --

A solution through a mechanism like that is possible, but is both roundabout (filters are made for producing lists of different items, not formatting data for output) and extremely limited (I don't know of any way to make a filter that interleaves fields from a list of tiddlers -- in my case, dates of birth and death).

Generally my feeling is that aggressively extending filter syntax is a poor stand-in for wikitext capabilities here.  Plaintext rendering is already possible for stylesheets through an exceptional mechanism in the renderer...  A functional solution could be as simple as a JS macro that calls into the rendering engine:  <<wiki-render {{||_GenealogyPath}} text/plain>>  --  but since that might (??) threaten the integrity of the widget tree's refresh logic if used as a widget attribute, it probably makes more sense to just facilitate typed transclusion in HTML syntax...

For what it's worth, I managed to hack my way around my immediate problem by using fat SVG lines instead of SVG paths.  (See result)  However, my question stands as this solution required some compromises and it's likely I'll want to do path generation in the future.

Regards,
Evan

On Sun, May 31, 2015 at 2:36 AM, Richard Smith <richardwil...@gmail.com> wrote:
Hi Evan,

I understand now - you want to be able to compose the svg 'path' using a filter and so wish to transclude the output of the filter into an attribute. After some playing just now, I would concur that this doesn't seem possible on the face of things.

Jed or someone else who has the serious filter-fu may know of newer solutions, but I think (may be wrong) this limitation is what caused Matabele to write the $makelist widget which sets the value of a field according to a filter output - you can then refer to this value by transclusion.

You should be able to find Matabele's widget by searching the forum - I'm not sure if it is up to date etc.

Regards,
Richard

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/S-5vLIqWxWk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
Reply all
Reply to author
Forward
0 new messages