Create a gist now

Instantly share code, notes, and snippets.

Embed
Xonsh: "c" - creates pretty part of the URL
import unicodedata
def cData_(x):
s = unicodedata.normalize('NFKD', x).encode('ascii', 'ignore').lower().decode('ascii')
newS = ''.join(map(lambda x: x if x.isalnum() else '-', s))
oldS = None
while oldS != newS:
oldS = newS
newS = newS.replace('--', '-')
if newS:
if newS[-1] == '-':
newS = newS[:-1]
print(newS)
return None
aliases['c'] = lambda a,b: cData_(' '.join(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment