[MediaWiki-l] Making article wikitext appear as an SVG image file in another page

tharpenator at gmail.com tharpenator at gmail.com
Sun Dec 20 16:00:17 UTC 2015


Adam, maybe an easier way to do this would be using Extension:NamespaceHTML -- it allows HTML tags to be used, but only in a namespace of your choice. This namespace would be only editable by a trusted group. But the results could be transincluded into other namespaces, but general users still can't use raw HTML themselves. 

Using the tag function #{{tag:html| you can even have Mediawiki variables inside the formatted HTML, but the HTML, itself, will not be editable by general users. Seems an easy way to go than writing a whole new extension. 

Chris 

Sent from my iPad

> On Dec 19, 2015, at 8:00 PM, Adam Nielsen <a.nielsen at shikadi.net> wrote:
> 
> Hi all,
> 
> I'd like to write an extension that allows wiki pages to contain SVG
> code (which can be edited like any other page - templates can be used,
> version history is kept, etc.)  I would then like to be able to embed
> these pages inside others, so the SVG code is then rendered as an
> image elsewhere on the wiki.
> 
> I am a little unsure on the best way to do this, so I'd appreciate any
> pointers.
> 
> I think it is best not to repurpose the File: namespace for this,
> because that will avoid having to deal with the difference between
> wikitext, files, and figuring out where template replacements should
> happen, so I guess a new SVG: namespace would be best.
> 
> The problem is then how to embed these images in other pages.  I would
> like to keep to existing syntax as closely as possible, so something
> like [[SVG:Example]] would display the image, just like
> [[File:Example.png]] would.
> 
> I tried using the LinkBegin hook, replacing the wikitext with an <img>
> tag that links to the ?action=raw version of the SVG: page.  This does
> work, but I lose all the standard MW image formatting methods, like
> being able to specify the image size or add a caption, so this isn't
> ideal.
> 
> In an attempt to maintain access to this formatting code, I tried
> hooking ImageBeforeProduceHTML instead, and using wikicode like
> [[File:SVG:Example]].  This will show the image, but the hook runs
> before all the formatting takes place so I still lose access to the MW
> image formatting code.
> 
> It seems like it would be better to hook in at a lower level, so the
> existing [[File:blah]] code runs per normal, providing resizing/caption
> support per normal.  I'm not sure how best to do this though.
> 
> One method that comes to mind is hooking ImageBeforeProduceHTML, then
> writing the processed wikitext to a temporary .svg file, and returning
> that in the ImageBeforeProduceHTML $file parameter.  However I am not
> sure how to do this, and guessing it may not work anyway as the
> final HTML code would probably have an <img> link pointing to the
> temporary file, which by then would have been deleted.
> 
> But in theory this idea would also allow thumbnails to be generated for
> browsers that don't support SVG, giving the best user experience.
> 
> Can anyone point me in the right direction for how this kind of
> extension could be implemented?  It looks like the most reliable way
> is going to be an extension that can somehow make the processed wikitext
> from an article appear to MW as if it's an image file just like any
> other.
> 
> Thanks,
> Adam.
> 
> 
> 
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l



More information about the MediaWiki-l mailing list