Let me first explain what I am trying to accomplish. I am trying to have TW generate a stylesheet that prefixes a label with an SVG icon. The stylesheet turns this:
.label::before { content: url(<<iconuri circle>>); }
into its final form, which looks like this:
.label::before { content: url('data:image/svg+xml;utf8,<svg class="icon" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="45"></circle></svg>'); }
My problems is that I’m using parameterized SVG icons, similar to Core Icons. For example, the “circle” svg tiddler I’m using for testing purposes looks like this:
\parameters (class:"icon")
<svg class=<<class>> viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle r="45" cx="50" cy="50" /></svg>
After a few days of fiddling, I managed to get an iconuri
macro that is close to what I need,
\define iconuri(tiddler)
<$wikify name="svg_icon" text={{$tiddler$}} mode="inline" output="html"><$text text={{{ [['data:image/svg+xml;utf8,]] [<svg_icon>] [[']] +[join[]] }}} /></$wikify>
\end
What <<iconuri circle>>
generates is this:
'data:image/svg+xml;utf8,<svg class="circle" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="45"></circle></svg>'
It’s very close to the output I need, which is:
'data:image/svg+xml;utf8,<svg class="icon" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="45"></circle></svg>'
At first glance, it seems as if WikifyWidget does not work with parameterized tiddlers. For some strange reason instead of using the default parameter value of icon
, Wikify has replaced the class
parameter with the tiddler’s title, circle
. Now I’m stuck, I do not know how to get wikify to stop doing this.
As a stop gap, is there a way to pass the correct parameter value into WikifyWidget?