5
$\begingroup$

For a question about physics, I accidentally came along the "operators" tag. Why is the LaTeX code visible below this tag and not what it is supposed to show? I can't see a mistake in the code. Or am I wrong?

$\endgroup$
3
$\begingroup$

I believe that the tag wiki excerpt (the thing that pops up when you hover over a tag or try to add it to a question) is supposed to contain plain text only. Or if I'm wrong about that, at least it is a very limited set of allowed markup, like only links. The point is, I don't think MathJax is supported in tag wiki excerpts, and this one should be edited to remove the math markup. This is not about an error in the code.

I'm not sure whether it would make sense to allow MathJax in tag wiki excerpts, but that's a matter for a separate discussion. (Honestly, I don't think that feature is likely to be implemented.)

$\endgroup$
  • $\begingroup$ Actually, it seems that MathJax in tag wiki excerpts works everywhere except on the tags page. Based on that, I'd say that it probably should work there too. $\endgroup$ – Ilmari Karonen Jan 28 '18 at 3:44
  • $\begingroup$ From this post it seems that MathJax works in tag excerpts since 2012: LaTeX in tag wikis. (At least on Mathematics, but treating this in the same way on all sites that have MathJax enabled seems like logical thing to do.) $\endgroup$ – Martin Jun 1 '18 at 23:59
1
$\begingroup$

The MathJax code in excerpts does get parsed on the tag page:

Screenshot

on the tag wiki page:

Screenshot

and in the hover popups on question pages (and elsewhere):

Screenshot

Based on that, I'd say that the fact that it doesn't get parsed on the tags page is probably a bug, and should be fixed.


In fact, it even works in the hover popups on the tags page:

Screenshot

The actual bug seems to be a missing MathJax.Hub.Typeset() call in the AJAX code that loads the tag list (taken from the tags page HTML source):

var request = null;
function finished(txt) {
    if (request) { request.abort(); }
    request = $.ajax({
        type: "POST",
        url: "/filter/tags-for-index",
        data: { filter: txt, tab: 'Popular' },
        dataType: "html",
        success: function (result) {
            var domelement = $(result);
            $("#tags_list").html(domelement);

            if (txt == "") {
                $(".pager").show();
            } else
            {
                $(".pager").hide();
            }

        }
    });
}

Adding the following lines after the $("#tags_list").html(domelement); statement should fix it:

if (window.MathJax) {
    MathJax.Hub.Queue(['Typeset', MathJax.Hub, "tags_list"]);
}
$\endgroup$
  • $\begingroup$ Interesting observation, but I actually don't think so. Whether MathJax is enabled is (closer to being) a property of the browser window the text is displayed in, not a property of where you enter it. So e.g. since questions need MathJax enabled, a popup on a question page will be parsed for math markup as well, even if it's not really supposed to contain that markup. Similarly with tag wiki pages (because the full tag wiki can contain math) and the tag page (because there are question excerpts and titles). The fact that it happens to work doesn't mean it's supposed to be allowed. $\endgroup$ – David Z Jan 28 '18 at 4:14
  • $\begingroup$ I mean, if we wanted to decide (or SE wants to decide) that MathJax should be enabled in tag wiki excerpts, that's a reasonable position to take. It's just that I don't think the fact that it happens to work in certain places (as you've pointed out) should be taken as evidence that it's supposed to work that way. $\endgroup$ – David Z Jan 28 '18 at 4:16
  • $\begingroup$ @DavidZ: Actually, for content loaded via AJAX (which includes both the popups and the tags list), whether or not MathJax works basically comes down to whether a) whether it has been deliberately disabled or not, and b) whether the AJAX loading code properly calls MathJax.Hub.Typeset() after adding the content to the page. Looks like, in this, the tag list code is missing that call. $\endgroup$ – Ilmari Karonen Jan 28 '18 at 4:34
  • $\begingroup$ Sure, I'm saying I don't think it should have that call. Or actually, what I'm saying here is that I don't think we can conclude it was meant to have that call. $\endgroup$ – David Z Jan 28 '18 at 4:56

You must log in to answer this question.

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