9

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.

7
  • A question about the apostrophe was already asked and deffered.meta.boardgames.stackexchange.com/questions/1029/…
    – Colin D
    Apr 30, 2014 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, 2014 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, 2014 at 15:13
  • 1
    @MichaelStum Card names with apostrophes appear to be broken again (see the revisions in this question).
    – murgatroid99 Mod
    Sep 7, 2016 at 18:11
  • 1
    Never mind. False alarm. The card name was written incorrectly.
    – murgatroid99 Mod
    Sep 7, 2016 at 18:17
  • @murgatroid99 Apostrophes, the biggest enemies in the English language :) I wish Wizards had a real public API, Sep 8, 2016 at 16:58
  • @MichaelStum Actually, now there is a real breakage. It looks like the current auto links don't work for any card in this list. You can see an example in this chat message. And I'm sure of the spelling this time.
    – murgatroid99 Mod
    Sep 9, 2016 at 23:51

4 Answers 4

10

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.

5
5

I just pushed an improvement to the Autocard feature. Note that existing posts won't be retroactively corrected, but any edit will update it.

There are a few edge cases (e.g., linking directly to the Alive/Well part of Alive // Well) because the Wizards website is a bit ambigous when to display search results, and I want to go directly to the card whenever possible (e.g., Black Lotus) without adding special logic for individual cards. Ghazbán Ogress works if written as Ghazban Ogress (no accent on the a), while El-Hajjâj works as written (with the accent).

1
  • Cool! Now how about getting the links to work in the editor preview too? (Feel free to steal my code if it's of any use; it's all CC-Zero.) Aug 21, 2016 at 21:19
4

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.

2

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]

You must log in to answer this question.

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