And Hah!!! Thank you sir - I'd have never thought about jQuery there;
And the tweak needed? Add the Namespace!!
config.macros.SVG =
{ handler: function (place, macroName, params, wikifier, paramString,
tiddler)
{ var svg = params[0]
var svgObject = document.createElement('object');
svgObject.setAttribute('type', 'image/svg+xml');
svgObject.setAttribute('data', 'data:image/svg+xml,'+ '<svg
width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/
svg">'+svg +'</svg>');
jQuery(place).append(svgObject);
}
};
And then <<SVG "<circle r='50' cx='50' cy='50' fill='green'/>">>
Gives you a green circle. There was some confusion on the original
blog about what SVG this would handle properly, but even simple svg
objects gives a bit more flexibility in TiddlyWiki, and I'd rather
lose some functionality and be able to stick with clean xml than
overreach for something that someone has to learn a specialized system
to work with (He said, like xml/svg is simple - <G>.)
Thanks again - I've been piddling with this off and on for awhile, and
knew I was missing something stupid and simple.
Jonnan
On Jul 29, 12:10 pm, "Mark S." <[email protected]> wrote:
> I think you're making great progress. Embedding SVG would allow TW to
> be used for parts diagrams, games, maps ... lots of cool stuff.
>
> In your code, try replacing:
>
> $(place).appendChild(svgObject);
>
> with :
>
> jQuery(place).append(svgObject);
>
> And replace your macro with:
>
> <<SVG "<circle r='50' cx='50' cy='50' fill='green'/>">>
>
> Ok. Now you should get a working embedded "something".
> Unfortunately, as you will see, the code doesn't render as SVG -- it
> renders as embedded XML, and complains that it doesn't have a style
> sheet. Can't help but think that one more little tweak might be the
> ticket.
>
> -- Mark
>
> On Jul 29, 5:11 am, Jonnan <[email protected]> wrote:
>
> > I feel like I must be both reinventing the wheel, and the most
> > retarded caveman ever to do it,but to expand the functionality of
> > TiddlyWiki for writing stories, I have been trying to get a macro to
> > interpret/add inline svg graphics to tiddlywiki.
>
> > I have found all sorts of things where people have gone well beyond
> > the simple thing I want - science graphs, interactive charts, and so
> > on, and I've found a code snippet (http://softwareas.com/inline-svg)
> > for doing inline svg that, going by the reactions of seemingly
> > competent people that posted at the time, seems to obviously just be
> > something anyone even slightly competent could cut and paste into a
> > macro and at least get a simple graphic to work.
>
> > I'm at the "It's so obvious a child could see it - Go find me a
> > child!" point - I no longer care if I look like a blithering idiot, I
> > would just like to know what obvious thing I'm missing that makes
> > turning this:
> > <<SVG "<circle r=\"50\" cx=\"50\" cy=\"50\" fill=\"green\"/>">>
>
> > config.macros.SVG =
> > { handler: function (place, macroName, params, wikifier, paramString,
> > tiddler)
> > { var svg = params[0]
> > var svgObject = document.createElement('object');
> > svgObject.setAttribute('type', 'image/svg+xml');
> > svgObject.setAttribute('data', 'data:image/svg+xml,'+ '<svg>'+svg
> > +'</svg>');
> > $(place).appendChild(svgObject);
> > }
> > }
>
> > into a functional macro so much harder than it seems like it should
> > be?
>
> > I'm almost certain the actual error is on the last line (at least the
> > macro doesn't deliver an error when it's commented out), but I have
> > tried pointers, functions 'this', 'here', 'place', and a dozen other
> > things to get it to actually output the svg into the file as an
> > object, and I'm obviously missing something.
>
> > With apologies for the order of frustration and a side of being a
> > whiny ***** - <G>. I don't know javascript/DOM, but this looks like it
> > should be so bloody simple?
>
> > Thanks again - Jonnan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---