Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion folium/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def __init__(
super().__init__()
self._name = "Tooltip"

self.text = str(text)
self.text = escape_backticks(str(text))

kwargs.update({"sticky": sticky})
self.options = remove_empty(**kwargs)
Expand Down
20 changes: 19 additions & 1 deletion tests/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pytest

from folium import GeoJson, Map, TileLayer
from folium.map import Class, CustomPane, Icon, LayerControl, Marker, Popup
from folium.map import Class, CustomPane, Icon, LayerControl, Marker, Popup, Tooltip
from folium.utilities import JsCode, normalize

tmpl = """
Expand Down Expand Up @@ -255,6 +255,24 @@ def test_popup_backslashes():
assert normalize(rendered) == normalize(expected)


def test_tooltip_backslashes_and_backticks():
m = Map()
marker = Marker([0, 0]).add_to(m)
tooltip = Tooltip("C:\\path\\20190221 `tick`").add_to(marker)
rendered = tooltip._template.module.script(this=tooltip, kwargs={})
expected = rf"""
{marker.get_name()}.bindTooltip(
`<div>
C:\\path\\20190221 \`tick\`
</div>`,
{{
"sticky": true,
}}
);
"""
assert normalize(rendered) == normalize(expected)


def test_icon_valid_marker_colors():
assert len(Icon.color_options) == 19
with warnings.catch_warnings():
Expand Down
Loading