INNER CODE UNIT · Python
vp_slugify
awesome-android-root/awesome-android-root · scripts/check_links.py:24
def vp_slugify(text):
s = unicodedata.normalize('NFKD', text)
s = R_COMBINING.sub('', s)
s = R_CONTROL.sub('', s)
s = R_SPECIAL.sub('-', s)
s = R_MULTI.sub('-', s)
s = R_LEAD.sub('', s)
s = R_DIGIT.sub(r'_\1', s)
return s.lower()
def heading_ids(text):
"""Map anchor id -> True for every heading (incl. custom {#id} ids)."""
ids = {}
counts = {}
for m in re.finditer(r'^(#{1,6})\s+(.+?)\s*$', text, re.M):
raw = m.group(2).strip()
cm = re.match(r'^(.*?)\s*\{#([\w\-]+)\}\s*$', raw)