7
$\begingroup$

In a recent comment correspondence between Jack D'Aurizo, SimplyBeautifulArt, and myself, it was asked whether one can put links in a tag. A quick and naive test fails, as such: $$\text{Direct Link} \tag{http://www.google.com/}$$ $$\text{Replaced Text} \tag{[link](http://www.google.com/)}$$ $$\text{Number Link} \tag{[enter link description here][1]}$$

Where the third test is link notation where the link is stored at the bottom of the post in the format of "[1]: URL".

Jack proposed that by mashing together available $\LaTeX$ and Markdown libraries we might be able to make something work, and appears to have somewhat achieved this by using artificial spacing $\displaystyle\hspace{5cm} I(a)=\int_{0}^{+\infty}\frac{x^a}{e^x+1}\,dx\hspace{5cm}$ (Google)

Generated with the following code:

$\displaystyle\hspace{5cm} I(a)=\int_{0}^{+\infty}\frac{x^a}{e^x+1}\,dx\hspace{5cm}\$ \[$(\text{Google})$]($\text{http://www.google.com}$})

However, this is abuses in-line styles and isn't a true tag even if we can get it to work with individual-line equations (those wrapped in \$\$)

What are some known ways to get this to work?


Important Edit:

It appears that the intended way to do this is to use the command \href, but the SE devs disabled this to avoid malicious code being executed. However, MathJax has included a safe-mode for years to keep this from happening, which the SE devs seem to have completely neglected. See here for a documentation of this feature and here for an old feature request on this meta from 2014 asking for safe \href to be enabled

$\endgroup$
12
  • $\begingroup$ Actually MathJax has the \href macro to provide exactly this; however it is apparently disabled here, probably for security reasons. $\endgroup$
    – celtschk
    Feb 22, 2017 at 0:07
  • $\begingroup$ @celtschk Yeah, I was aware of \href; mixedmath addresses this in his post as well, but it seems completely disabled $\endgroup$ Feb 22, 2017 at 0:10
  • $\begingroup$ @celtschk this is relevant to your point meta.math.stackexchange.com/questions/12674/… $\endgroup$ Feb 22, 2017 at 0:15
  • $\begingroup$ I'm intrigued by the fact that I was downvoted. Someone apparently doesn't want this feature? $\endgroup$ Feb 22, 2017 at 2:37
  • $\begingroup$ I wasn't the downvoter, but I don't actually care if we have this feature or not. It seems totally acceptable to me to either link the whole equation, or to tag each line and explain each tag with a link. But I do think it's interesting that \href isn't allowed, and I do wish that I knew the reason. $\endgroup$
    – davidlowryduda Mod
    Feb 22, 2017 at 2:41
  • $\begingroup$ I requested this before, see here.. For some reason SE has not yet enabled this MathJax feature. That's a shame, since it would prove quite beneficial. It's very cumbersome not to be able to link to proofs in MathJax code. $\endgroup$ Feb 22, 2017 at 4:27
  • 1
    $\begingroup$ I had downvoted it.Somewhat complicated MJ constructs cause more issues than they solve. Better to keep things simple and straightforward. $\endgroup$
    – quid Mod
    Feb 22, 2017 at 14:20
  • 1
    $\begingroup$ There is a way to do it within MathJax, even with \href disabled, but I hesitate to give it because it allows unfiltered URL's and so would allow the type of security issues that the folks at SE have tried to avoid by disabling \href. (If they used MathJax's Safe extension, it would prevent the problem even with the technique I have in mind.) I'm not sure whether it is right or wrong to expose the technique. It might encourage the powers that be to implement Safe, but in the meantime, it would be a security concern. $\endgroup$ Feb 23, 2017 at 0:05
  • $\begingroup$ @DavideCervone I can respect that decision. It's unfortunate SE won't just use the Safe extension :/ $\endgroup$ Feb 23, 2017 at 0:22
  • $\begingroup$ @DavideCervone that being said, if you feel like sending a message to the SE devs about this in order to convince them to allow the Safe extension it would be great, even if you have moral qualms about sharing any existing techniques :) $\endgroup$ Feb 23, 2017 at 0:44
  • 1
    $\begingroup$ @BrevanEllefsen, we have brought it up with them more than once, but it is up to them, and it seems to be a low priority. The Safe extension was actually designed around the issues raised here, so I was disappointed that they didn't adopt it. $\endgroup$ Feb 23, 2017 at 15:49
  • $\begingroup$ @DavideCervone really??? How unfortunate :/ I'm generally impressed with the Devs' decisions, but the fact they would ignore such a fantastic feature shocks me. That being said, I appreciate all the work you do to create such a wonderful platform for expressing mathematical equations :) $\endgroup$ Feb 23, 2017 at 17:08

1 Answer 1

4
$\begingroup$

What if I try $$ 2 + 2 = 4 \tag{\href{http://davidlowryduda.com}{davidlowryduda.com}}$$

$\href{http://google.com}{google.com}$


Nope.

So the best I have is to use $$ 2 + 2 = 4, \tag{1}$$ (where the entire equation is clickable) or to use $$ 2 + 2 = 4, \tag{2}$$ where $(2)$ is shown at url. [Or equivalently, where (2) is proved at davidlowryduda.com, or whatnot].

$\endgroup$
7
  • $\begingroup$ Nope. And oddly, this breaks spacing on my renderer. Weird. I note that the \href command is parsed correctly, but does not seem to function meaningfully. $\endgroup$
    – davidlowryduda Mod
    Feb 22, 2017 at 0:04
  • $\begingroup$ Odd, isn't it? I tried the same thing earlier $\endgroup$ Feb 22, 2017 at 0:04
  • 2
    $\begingroup$ See here meta.math.stackexchange.com/questions/12674/… $\endgroup$ Feb 22, 2017 at 0:15
  • 1
    $\begingroup$ We have just discovered a way for writing answers twice as large as usual :D $\endgroup$ Feb 22, 2017 at 1:27
  • $\begingroup$ @JackD'Aurizio I'm not sure what you mean by that? $\endgroup$ Feb 22, 2017 at 2:38
  • $\begingroup$ @BrevanEllefsen: we have discovered that we may break formatting by inserting a href inside a tag. This is an issue that may give a way to write answers taking twice the horizontal space they usually deserve. $\endgroup$ Feb 22, 2017 at 4:16
  • 1
    $\begingroup$ This is unrelated to the \href itself, only to the fact that the context of the tag is excessively wide. See this post for details. $\endgroup$ Feb 22, 2017 at 23:45

You must log in to answer this question.

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