text annotations with with hrefs containing encoded characters such as '#' break links
See original GitHub issueThe solution that was adopted in #2471 to enable support for encoded hrefs seems to break for characters like #
and :
. This seems to be because JavaScript’s encodeURI
and decodeURI
do not encode/decode these characters. Perhaps more nuanced used of encodeURIComponent
and decodeURIComponent
needs to be used?
Here’s a minimal working example in Python, which is trying to link to a Twitter query for #food lang:en
, in which the #
and :
characters need to be encoded:
import plotly.io as pio
fig = {"data": [{"type": "bar", "x": ['<a href="http://twitter.com/search? q=%23food%20lang%3Aen">query</a>'], "y": [1]}]}
pio.show(fig)
The generated link ends up being scrambled because the hash and colon escape sequences are not decoded, but are then encoded again, resulting in the following Twitter search: %23food lang%3Aen
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Cross Site Scripting Prevention - OWASP Cheat Sheet Series
Here are some examples of encoded values for specific characters. ... <a href="http://www.owasp.org?test=$varUnsafe">link</a >. Encode all characters with ...
Read more >Links in HTML documents - W3C
The following HTML excerpt contains two links, one whose destination anchor is an ... Since links may point to documents encoded with different...
Read more >How to use ampersands in HTML: to encode or not to encode?
An explanation of when to use encoded ampersands (&) in HTML and Javascript and when not to encode them.
Read more >[CONFSERVER-52420] Links containing certain encoded special ...
This ticket stems from CONFSERVER-45966 . In that ticket, if you enter a link that contains url-encoded characters such as %25 or %2f,...
Read more >Google fonts URL break HTML5 Validation on w3.org
URL encode the | (pipe characters) in the href attribute ( %7C ): <link rel="stylesheet" type="text/css" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, it should work in your terminal too.
For JupyterLab (on Binder), you can run:
Thanks a lot for your help!!! It works perfectly !