Skip to content

Commit

Permalink
unescape before calling slugify for compat w/ 3rd parties
Browse files Browse the repository at this point in the history
  • Loading branch information
waylan committed Feb 12, 2024
1 parent dbbd038 commit a561789
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions markdown/extensions/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

def slugify(value: str, separator: str, unicode: bool = False) -> str:
""" Slugify a string, to make it URL friendly. """
# First convert HTML entities to Unicode characters
value = html.unescape(value)
if not unicode:
# Replace Extended Latin characters with ASCII, i.e. `žlutý` => `zluty`
value = unicodedata.normalize('NFKD', value)
Expand Down Expand Up @@ -380,7 +378,7 @@ def run(self, doc: etree.Element) -> None:

# Do not override pre-existing ids
if "id" not in el.attrib:
el.attrib["id"] = unique(self.slugify(text, self.sep), used_ids)
el.attrib["id"] = unique(self.slugify(html.unescape(text), self.sep), used_ids)

if 'data-toc-label' in el.attrib:
text = unescape(el.attrib['data-toc-label'])
Expand Down

0 comments on commit a561789

Please sign in to comment.