32

SO cuts off URLs after an asterisk, which isn't correct. Here is an example URL:

https://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes

Please note that *-attributes is a valid part of the URL.

Originally, the full URL looks like this:

https://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes
9

3 Answers 3

16

This looks like an issue with the markdown parser. I'm not sure SO has any say over that.

However, maybe you can submit an issue. Just make sure to check if it hasn't been submitted before.

8
  • 3
    OK, I will. But AFAIK one can "overwrite" some of the markdown functionalities, SO has some SO-related tricks. So if they won't solve this, I think SO still can do this on its own. Will accept as soon as SO will let me do this. Commented Mar 23, 2016 at 15:14
  • The correct link to submit issue on markdown: github.com/adam-p/markdown-here/issues/new but I wanted to do this, I clicked "preview" and... on Github it works fine (AFAIK they use markdown too). Right now I am unable to test "pure" markdown, but or Github modified something, or indeed this is a SO specific issue. Commented Mar 23, 2016 at 15:27
  • I believe this is "pure" markdown: dillinger.io - and no, there are no issues there with URLs Commented Mar 23, 2016 at 15:32
  • 9
    @konrad_firm so if you don't buy the explanation why have you accepted the answer? Commented Mar 23, 2016 at 20:29
  • I'm not complaining ;-)
    – Cerbrus
    Commented Mar 24, 2016 at 7:17
  • @MartinSmith Well, first I accepted the answer then I made my investigation. But the primary reason I don't want to undo my acceptance is this: I knew SO uses markdown, yet I did not even think this could be related to markdown :) This was the moment I thought it's time to leave my office and get some sleep. And I'm grateful to Martin for this :) Commented Mar 24, 2016 at 7:34
  • @Cerbrus my explanation above ^ :) Commented Mar 24, 2016 at 7:34
  • An upstream bug is still a bug in your own product Commented Mar 26, 2016 at 22:41
34

As a workaround you can use a backslash (\) to escape the asterisk (*) where it might be interpreted as markdown:

https://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-\*-attributes

https://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes

Though a better solution would be to use an explicit link with descriptive text:

[3.2.5.9 Embedding custom non-visible data with the data-\* attributes][1]
  [1]: https://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes

3.2.5.9 Embedding custom non-visible data with the data-* attributes

6
  • 8
    I think this is the correct way, not a workaround. * has special meaning in markdown, and if you don't want that meaning you should escape it. And no need to repeat the URL, you can use https://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-\*-attributes directly.
    – Oriol
    Commented Mar 23, 2016 at 21:56
  • @Oriol Ah, I didn't think of that. I've updated my answer with your more direct solution.
    – Ross Ridge
    Commented Mar 24, 2016 at 0:32
  • @Oriol then why it works fine on dillinger.io ? I understand this is a "pure" markdown implementation. Commented Mar 24, 2016 at 7:35
  • 3
    @Oriol if linkifying urls in the text is a markdown feature then the markdown parser should support bare * in urls.
    – jfs
    Commented Mar 24, 2016 at 9:28
  • 1
    @J.F.Sebastian That's if you assume nobody ever wants to apply formatting to a URL. That is of course a false assumption. Treating unescaped markdown characters in URLs as markdown is the only way to allow that behavior, while still allowing those characters to be in the URL through the various methods described in this answer.
    – Servy
    Commented Mar 25, 2016 at 14:17
  • @Servy: incorrect. I don't assume that. In a rare case, when you want to format different parts of an url differently, you could use the explicit []() syntax. Parts inside [] are not linkified based on their content -- they are as a whole link to whatever is inside ().
    – jfs
    Commented Mar 26, 2016 at 18:53
28

You can always percent encode troublesome characters. Try it with %2A in place of the *.

3
  • 5
    And asterisk is on the list of reserved characters, so that's the preferred way to express the URL anyway.
    – Ben Voigt
    Commented Mar 25, 2016 at 2:30
  • 1
    I think this is what SE did some time ago, but it was not correct (see Percent-encoding of asterisks (*) in links). A URL with the path /foo*bar is not equivalent to a URL with the path /foo%2Abar, because it’s a reserved character.
    – unor
    Commented Mar 29, 2016 at 14:16
  • This answer is wrong. You can't "always percent encode troublesome characters" if they are reserved, and * is reserved. @BenVoigt's comment is arguably correct but it's pretty misleading. It may be better to use %2A than * if you are choosing a URL, but if you're linking someone else's URL, you have to use the one they chose. (Of course, both may work in some cases. But there's no guarantee.)
    – benrg
    Commented Aug 26 at 0:32

You must log in to answer this question.

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