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 <jonnan.w...@gmail.com> 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 TiddlyWiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to