The reason this particular link breaks markdown so much is because of the unescaped ")". This is effectively ending the URL parsing.
The standard markdown for links looks like:
[display text](url)
The expectation is that the url does not contain an unescaped or unencoded ")", since this is used to represent the end of link markdown (with one exception).
Under normal circumstances the ) could be escaped with a slash \)
. In comments, chat, and in the preview display of posts escaping the parenthesis is enough.
The following markdown will work in all of the above mentioned locations:
[VariablesToExport](https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7.2&viewFallbackFrom=powershell-6#:%7E:text=MyCmdlet%22%2C%20%22Test%2DMyCmdlet%22\)-,VariablesToExport,-Type%3A%20String)
However, that will not fully work in this case, because the tilde character (~) gets converted to %7E on the server side which will cause the scroll-to-text fragment link not to function in the rendered post. e.g. (This will not work) VariablesToExport
Really the only option, currently, to have a working text fragment link in a post is a standard anchor element (<a>
) e.g.
VariablesToExport
Markdown:
<a href="https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7.2&viewFallbackFrom=powershell-6#:~:text=MyCmdlet%22%2C%20%22Test%2DMyCmdlet%22)-,VariablesToExport,-Type%3A%20String">VariablesToExport</a>
As Makyen mentioned, it's arguably an implementation error on the Chrome/Chromium side treating the ~ (an unreserved character) as distinct from the encoded %7E, but as it stands the only way to have functional text fragment links in Stack Exchange questions and answers is to use an anchor element above.
It's also important to note that scroll-to-text fragment links are currently not widely supported. Even when they are rendered correctly, they will not work for everyone. It is still a good idea to use more widely supported links instead of the scroll-to-text fragment when possible and to describe where on the page the link is pointing when using them.
Ctrl + K
is used to create preformatted text. Did you meanCtrl + L
?CTRL + K
in most apps except SO 🤷♂️) @Justin:%7E:text=
as a valid alternate for:~:text=
. Even the IETF RFC3986 section 2.4 says 'For example, the octet corresponding to the tilde ("~") character is often encoded as "%7E" by older URI processing implementations; the "%7E" can be replaced by "~" without changing its interpretation.' So, technically, this looks like a bug in Chromium's implementation. At a minimum, people will likely point fingers back and forth as to responsibility.