Last modified: 2012-11-06 14:44:22 UTC
I don't know if this is due to SMW 1.8 or MW 1.20, but when using "template=" in #ask queries, external links aren't getting parsed (though internal links still get handled fine). You can see the problem here, for example, in all the attempted "view" links: http://discoursedb.org/wiki/2011_Egyptian_protests_/_Hosni_Mubarak_should_step_down The relevant queries are here: http://discoursedb.org/w/index.php?title=Template:Position&action=edit ...and here's the template they call: http://discoursedb.org/w/index.php?title=Template:ItemQuery&action=edit
I think this is caused by " |link=subject" in the query, which advises SMW to avoid links in all parameters other than the subject. For URLs, this can only be done by escaping the URL so that MediaWiki won't autolink it. Unfortunately, this also prevents explicit linking. The change that caused this is https://bugzilla.wikimedia.org/show_bug.cgi?id=39392 Maybe this change needs to be augmented to get the desired behaviour. Is there any way to craft a string that will no be linked by MW by default, but will be linkable when put into [ ]?
That is indeed tricky. Might it work to add in a call like $parser->replaceExternalLinks() on the text? As far as I can tell, that function only handles URLs within brackets, not bare URLs.
I don't see how this would help. If we called replaceExternalText on our output, we could only ensure that it gets linked (make links right away). What we need to do is to ensure that it does not get linked, unless surrounded by [ ]. But since this processing happens after we returned the string, I don't see how we can influence it with replaceExternalLinks() in the case where we do not want a link. One option would be to have two outputformats: one to get the plain string, one to get the escaped (nolink) string. In theory, the format "-" should rather return the plain string than an escaped one, so that it can really be used like raw data. How should the format for escaping be called? Would "nolink" make sense?
Maybe you misunderstood I meant? What I mean is, in cases where URLs don't get linked (i.e., "link=subject" or "link=none"), you call replaceExternalLinks() after the other processing is done. That way, URLs in single brackets get linked, while URLs not in brackets stay unlinked.
But MW links all URLs, whether in brackets or not, after the page is built anyway. Unless replaceExternalLinks() protects link-like strings to avoid linking, this would still happen, wouldn't it? But as I understand you, replaceExternalLinks() adds more links rather than preventing links from being inserted.
I don't understand - right before displaying the query results on the screen, can't you call replaceExternalLinks() on that text, to take care of the URLs in brackets? Or is there some escaping of the URLs in the text so that that won't work?
To prevent autolinking in MW, we replace : with an HTML escape. But after this, the string is no longer a URL. As I understand, replaceExternalLinks() does not accomplish anything that MW would not do with the returned text anyway.
Ah - that's the part I didn't know about it. Still, I bet after the main parsing is done, you could replace it back, then call replaceExternalLinks(). There may be easier ways to do it, but I think this would work.
I agree with you that the current escaping is not feasible. We need to find a better solution. I am marking this as a duplicate of Bug 39392 now, since it is one discussion we need to have for both issues. *** This bug has been marked as a duplicate of bug 39392 ***