Some Cards Generate Multiple Results

If the entire name is contained within the name of another card, then linking the former card will return a result with both cards. An example can be seen with Circle of Protection: Art, which returns a list of both the specified card, as well as Circle of Protection: Artifacts.

Some Characters Produce Invalid Links

Certain characters being included in a card name (the ones I have discovered are detailed below). return invalid results.

The Apostrophe

Changed to %27 per HTML URL Encoding, which is then dropped by Gatherer altogether when the query is built. See: Ranger's Guile, which becomes a query for "rangers guile", and thus returns no results.

The Ampersand

Also generates an invalid result. See: R&D's Secret Lair[1]... Currently, only two cards contain an ampersand character, and both of those cards also contain an apostrophe, so if the apostrophe issue can be fixed, then those two cards will still result in broken links unless the ampersand issue is also corrected.

Most Other Characters Seem To Work OK

I have sampled other cards with special characters in the name, and discovered no other issues so far. Examples:

Kongming, "Sleeping Dragon"

Question Elemental?

B.F.M. (Big Furry Monster)

Alive (Alive/Well) (This one does return two results, however; one for each half of the split card, as opposed to linking to the card itself, which should work like this instead: Alive (Alive/Well)

It looks to me like the apostrophe is problematic for Gatherer's query engine because they are most likely not correctly escaping the character in their SQL strings.

Is This Within Our Means To Fix?

These issues seem to be a problem with Wizards of the Coast's API, and may not even be something that we can fix on our end, but if there is something that can be done about it, what might that be?

The only sure way (presently) to generate a link to the exact card intended seems to be using a traditional link to the card's multiverse-ID-based page, for example:

[Ranger's Guile](http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=370803)

Notes

[1] Interestingly enough, the symbol that you see in this link was typed in the editor as "&", but seems to be automatically changed, appending "and;" to the "&". Might there be a way to have this kind of thing formatted to show just the ampersand and not the encoded version? If the link actually uses an "&", it would produce a query of simply "r" (cutting off the ampersand itself and all following characters). But if the link uses the concatenated "&" + "amp;" that the auto-linker changes this to, Gatherer produces "rampds secret lair" as the query, which is also invalid.

share
    
A question about the apostrophe was already asked and deffered.meta.boardgames.stackexchange.com/questions/1029/… –  Colin D Apr 30 at 13:56
    
Thank you for linking me there, which also linked me to this version of essentially the same question: meta.boardgames.stackexchange.com/questions/794/… –  callahan09 Apr 30 at 15:12
1  
The consensus seems to be that this is Wizards' bug and there's nothing we can do about it. But we do have the option to use magiccards.info instead, which I think is a vastly superior alternative. Queries there solve all issues referenced in my question: only cards with the exact name will be returned, and it can handle all characters without error. It is also a faster-loading website, which is nice, however it does have the drawback of being down more often than Gatherer, though it is still infrequent. Any reason we can't switch the API to magiccards.info for a better experience? –  callahan09 Apr 30 at 15:13

3 Answers 3

We can fix the apostrophes! Pretty trivially!

I messed around some based on previous research we've done here on Meta. In fact, it turns out that it can be improved pretty trivially!

Right now, if I do Sphinx's Revelation, I get this:

http://www.wizards.com/magic/autocard.asp?name=Sphinx's Revelation
http://www.wizards.com/magic/autocard.asp?name=Sphinx%27s%20Revelation

Instead, we should have it convert to this:

http://gatherer.wizards.com/Pages/Search/Default.aspx?name=+[Sphinx's Revelation]
http://gatherer.wizards.com/Pages/Search/Default.aspx?name=%20%5BSphinx%27s%20Revelation%5D

Check it out, it also fixes the Sun Titan problem:

This is actually the search format used by WotC's own Gatherer search browser plugin.

share
    
Looks great to me! Thanks for finding this. Hopefully we can get the API implemented as such and we'll be good to go. –  callahan09 May 2 at 19:49
1  
I tried implementing your suggestion as a user script; alas, it seems to break for Circle of Protection: Art and Alive (Alive/Well), which turn into gatherer.wizards.com/Pages/Search/… and gatherer.wizards.com/Pages/Search/… respectively. :-( –  Ilmari Karonen May 11 at 21:35
    
...um, that should be gatherer.wizards.com/Pages/Search/… of course; I was experimenting with different search strings to see if I could find one that worked, and accidentally copied the wrong one. Alas, none of the variants I tried seem to work for that card. –  Ilmari Karonen May 18 at 17:26
    
Update: It seems that linking to http://gatherer.wizards.com/Pages/Card/Details.aspx?name=Card+Name+Here works perfectly for all the cards mentioned here, except for Alive/Well -- and for that card, either gatherer.wizards.com/Pages/Card/Details.aspx?name=Alive or gatherer.wizards.com/Pages/Card/Details.aspx?name=Well alone does the trick. –  Ilmari Karonen May 22 at 22:13
    
@IlmariKaronen Hmm... I guess now the big question is: would making people type [mtg:Alive]/[mtg:Well] be a big imposition? –  Alex P May 22 at 22:32

A few more cards with unusual characters in their names, mostly from Unglued / Unhinged, just for testing to see if these sissues would be fixed by linking directly to http://gatherer.wizards.com/Pages/Card/Details.aspx?name=Card+Name.

These work fine already (and also with the fix):

These are currently broken, but would be fixed by the suggested change:

Links to split cards with a slash in the name, like Trial / Error and Alive / Well, sort of work now, but would break with the suggested fix; linking to the individual halves, as in Trial / Error or Alive / Well, would work with the fix, though.


Ps. Another problem I've noticed, affecting both my solution and the one proposed by Alex P, is that some people have apparently taken to working around the apostrophe problem by just dropping the 's from card names, e.g. writing Pharika Mender instead of Pharika's Mender. Currently, the mangled card names produce working links — but if the auto-linking feature is changed as proposed in this thread, they'll stop working, even as the correct card names will start to work.

This is not a major issue if this change is done in the SE codebase, since we can just go and edit any such links to make them work again. However, it kind of an obstacle to my plans to include this as a client-side fix in the SOUP user script, since there seems to be no way to write such links that would work both for users with and without the script. :-(

(Also, wouldn't it be really nice if we could actually have these links working in the post preview...)

Testing a card name with < funny > characters, Nested [mtg:card links]

share

I have written an improved reimplementation of the mtg.js script that currently handles the pop-up window creation for [mtg:...] card links. This reimplementation includes the following features:

  • A client-side Markdown extension to parse [mtg:...] links in the edit preview window. (Based on the SE [tag:...] link parser, seems to closely match the server-side implementation.)

  • A delegated click event handler (to open the popup window) that works also in preview and for posts loaded via AJAX.

  • Scrollable and resizeable pop-up windows (because a lot of card pages are taller than 890 pixels).

  • A customizable link URL, defaulting to http://gatherer.wizards.com/Pages/Card/Details.aspx?name=... as proposed in my earlier post.

  • A client-side hotfix to make any server-side generated MtG card links use the new URL, and to fix the double-escaping bug described in the question above.

  • May be used as a drop-in replacement for the existing mtg.js script, or installed as a Greasemonkey / Tampermonkey user script in the browser for immediate testing. (Note: Scrollable popup windows may not work for all card links when installed as a user script.)

I've released the code into the public domain, and would be very happy if the SE devs were to use it as a replacement of the existing mtg.js script.

(I'd be even happier if they also fixed the server-side code to use the new URL and to get rid of the double-escaping bug, which would allow the hotfix portion of the client-side code to be removed.)

Update: As of June 26, a version of this improved MtG card link script is now included in the Stack Overflow Unofficial Patch v1.16. Users with SOUP installed should get the improved card links automatically.

share

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .