MCPcopy Index your code
hub / github.com/Python-Markdown/markdown / unique

Function unique

markdown/extensions/toc.py:56–65  ·  view source on GitHub ↗

Ensure id is unique in set of ids. Append '_1', '_2'... if not

(id: str, ids: MutableSet[str])

Source from the content-addressed store, hash-verified

54
55
56def unique(id: str, ids: MutableSet[str]) -> str:
57 """ Ensure id is unique in set of ids. Append '_1', '_2'... if not """
58 while id in ids or not id:
59 m = IDCOUNT_RE.match(id)
60 if m:
61 id = '%s_%d' % (m.group(1), int(m.group(2))+1)
62 else:
63 id = '%s_%d' % (id, 1)
64 ids.add(id)
65 return id
66
67
68@deprecated('Use `render_inner_html` and `striptags` instead.')

Callers 2

testTOCUniqueFuncMethod · 0.90
runMethod · 0.85

Calls

no outgoing calls

Tested by 1

testTOCUniqueFuncMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…