-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backslashes in popup break page. #1907
Comments
Minimal example to reproduce:
Users can fix this on their side by escaping their backslashes. For example:
I'm not sure if we should change the behavior on the Folium side. On the one hand, that would make it easier for users. On the other hand it would be a breaking change for users who already escape their backslashes. In the end, I'd opt for making the change, making Folium better going forward. I'm thinking we should unify the parsing between Popup, Tooltip and perhaps other classes that render user text. |
I would go about it, @Conengmo, by introducing this unified string-like All classes which require rendering text will optionally start accepting instances of this class. Nothing changes for users who are already escaping backslashes at their end. Then, over the next couple of minor release cycles, we deprecate anything apart from Finally, only I'd be happy to work with you on this if you find the idea plausible. I'm yet to take a deep dive in |
@achieveordie That looks like a promising approach. Two questions/thoughts:
|
Hey @hansthen, thanks for getting back.
While
I agree with your opinion on the name since it is only a placeholder. I suppose a more generic |
I'd prefer it if the |
Sorry, I missed your reply. I'll start working on it and let you know when it is done. |
@achieveordie I took a look at python-visualization/branca#170 and I have to say it's quite impressive. I do mean that as a compliment, but I'll also say that I think it's a bit overkill for what we need here. One of my main concerns is keeping Folium maintainable, so the less code the better. In this case I don't think we need to escape more than backticks and backslashes, so a full framework for text escaping is not necessary I think. What I have in mind is adding a function like the existing Hope this doesn't deter you from helping out with Folium, I do appreciate your input. |
Thanks for taking a look at it, @Conengmo. I can understand your "Maintainability over Comprehensivity" approach, especially in cases where a feature might not be extensively used. Coming back to the implementation, are you suggesting we should limit ourselves to creating a function similar to Consider the initial example where the original string is: I probably misunderstood what you meant, so I just wanted to clarify before reworking on it. |
Yes you are right, we can't really infer whether the string needs to be escaped or not from whether there are only single or also double backslashes in it. Let's keep it simple and just escape, no matter the content of the string.
Yes, that seems correct to me.
Thanks! |
Describe the bug
It seems if a backslash followed by a number is included in the text of a popup, the map will fail to generate. Once the map is generated, if an attempt to load the map is map, no map is displayed and the following error is present in the browser console.
In my case, it caught me off guard as I only recently had a path come up that caused the issue. Hope the report helps others..
To Reproduce
( i tried to simplify my code, I didn't actual test this)
Expected behavior
Normal map with a pop up.
Environment (please complete the following information):
Possible solutions
Check all strings and escape any backslashes(\) before adding as a popup
The text was updated successfully, but these errors were encountered: