Meta: Port several things common to various Python scripts to a new website module

This commit is contained in:
Eryn Wells 2024-11-17 14:49:33 -08:00
parent a30903c8cf
commit 9ce6362402
6 changed files with 70 additions and 34 deletions

View file

@ -0,0 +1,12 @@
#!/usr/bin/env python3
# Eryn Wells <eryn@erynwells.me>
import re
def slugify(s: str) -> str:
'''Process a string into something suitable to be a page slug.'''
s = s.strip().lower()
s = re.sub(r'\s+', '-', s)
s = re.sub(r'[‘’“”"\'()]', '', s)
return s