Skip to content

Commit 04880a0

Browse files
committed
fix: escape id of toc
1 parent 85eb54f commit 04880a0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/mistune/toc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple
22

33
from .core import BlockState
4-
from .util import striptags
4+
from .util import striptags, escape
55

66
if TYPE_CHECKING:
77
from .markdown import Markdown
@@ -89,7 +89,7 @@ def render_toc_ul(toc: Iterable[Tuple[int, str, str]]) -> str:
8989
s = ""
9090
levels: List[int] = []
9191
for level, k, text in toc:
92-
item = '<a href="#{}">{}</a>'.format(k, text)
92+
item = '<a href="#{}">{}</a>'.format(escape(k), text)
9393
if not levels:
9494
s += "<li>" + item
9595
levels.append(level)

0 commit comments

Comments
 (0)