-----BEGIN PGP SIGNED MESSAGE-----
Moin,
my graph extension (see http://bloodgate.com/perl/graph) returns either HTML, or SVG. However, mediawiki treats the returned text as wikitext, e.g. it parses it, attempts transform it into HTML and the sanitizes it.
The latter step should be done for security reasons - after all, my extension processes user input and I wouldn't trust it completely to always return well-formed HTML.
However, I would like to somehow annouce that my extension already returns HTML. At the moment the returned text cannot contain leading spaces or empty line because these will be turned into "<p>" or "<pre>", completely destroying the output.
- From the comment in the example extension (where I based mine on) I read that the extension should return HTML, but it seems the returned text will be treated as wikitext and not just HTML. Is it possible to change this?
(I have the feeling that I already asked that, but couldn't find it again :)
Another, related problem is SVG output, this too is treated first as wikitext, then as HTML, and in this process the output is destroyed. Now it would be possible to handle SVG output like <math> does, e.g. producing an external file and the referencing it. However, I would prefer to generate inline SVG. For this to work the output must be passed unaltered, because the HTML sanitizer seems to not like SVG at all (not surprise :)
Has anybody done something in this regard?
The code for my extension is inlined below, you can find the complete package at my site mentioned above.
If this isn't the right place to ask this question, please kindly redirect me.
Best wishes,
Tels
<?php # Graph WikiMedia extension
# (c) by Tels http://bloodgate.com 2004-2005
# Takes text between <graph> </graph> tags, and runs it through the # external script "graphcnv", which generates an ASCII, HTML or SVG # graph from it.
$wgExtensionFunctions[] = "wfGraphExtension";
function wfGraphExtension() { global $wgParser;
# register the extension with the WikiText parser # the second parameter is the callback function for processing the text between the tags
$wgParser->setHook( "graph", "renderGraph" ); }
# for Special::Version:
$wgExtensionCredits[parserhook][] = array( 'name' => 'graph extension', 'author' => 'Tels', 'url' => 'http://wwww.bloodgate.com/perl/graph/', 'version' => 'v0.13 using Graph::Easy v' . `perl -MGraph::Easy -e 'print $Graph::Easy::VERSION'`, );
# The callback function for converting the input text to HTML output function renderGraph( $input ) { global $wgInputEncoding;
if( !is_executable( "graph/graphcnv" ) ) { return "<strong class='error'><code>graph/graphcnv</code> is not executable</strong>"; }
$cmd = "graph/graphcnv ". escapeshellarg($input)." ". escapeshellarg($wgInputEncoding); $output = `$cmd`;
if (strlen($output) == 0) { return "<strong class='error'>Couldn't execute <code>graph/graphcnv</code></strong>"; }
return $output; } ?>
- -- Signed on Thu Nov 17 11:52:40 2005 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email.
"Some spammers have this warped idea that their freedom of speech is guaranteed all the way into my hard drive, but it is my firm belief that their rights end at my firewall." -- Nigel Featherston
wikitech-l@lists.wikimedia.org