1+ from collections .abc import Callable
12import re
2- from typing import Callable , List , Optional , Set
33
44from markdown_it import MarkdownIt
55from markdown_it .rules_core import StateCore
@@ -10,7 +10,7 @@ def anchors_plugin(
1010 md : MarkdownIt ,
1111 min_level : int = 1 ,
1212 max_level : int = 2 ,
13- slug_func : Optional [ Callable [[str ], str ]] = None ,
13+ slug_func : Callable [[str ], str ] | None = None ,
1414 permalink : bool = False ,
1515 permalinkSymbol : str = "ΒΆ" ,
1616 permalinkBefore : bool = False ,
@@ -58,15 +58,15 @@ def anchors_plugin(
5858
5959
6060def _make_anchors_func (
61- selected_levels : List [int ],
61+ selected_levels : list [int ],
6262 slug_func : Callable [[str ], str ],
6363 permalink : bool ,
6464 permalinkSymbol : str ,
6565 permalinkBefore : bool ,
6666 permalinkSpace : bool ,
6767) -> Callable [[StateCore ], None ]:
6868 def _anchor_func (state : StateCore ) -> None :
69- slugs : Set [str ] = set ()
69+ slugs : set [str ] = set ()
7070 for idx , token in enumerate (state .tokens ):
7171 if token .type != "heading_open" :
7272 continue
@@ -119,7 +119,7 @@ def slugify(title: str) -> str:
119119 return re .sub (r"[^\w\u4e00-\u9fff\- ]" , "" , title .strip ().lower ().replace (" " , "-" ))
120120
121121
122- def unique_slug (slug : str , slugs : Set [str ]) -> str :
122+ def unique_slug (slug : str , slugs : set [str ]) -> str :
123123 uniq = slug
124124 i = 1
125125 while uniq in slugs :
0 commit comments