def header_link(title):
"""Return a github-style link target for a title.
>>> header_link('Hello there!')
'hello-there'
"""
# This doesn't do the-title-1, the-title-2 etc. with multiple titles
# with same text, but usually this doesn't matter.
result = ''
for character in title:
if character in string.whitespace:
result += '-'
elif character in string.punctuation:
pass
else:
result += character.lower()
return result
评论列表
文章目录