def slug(s, remove_whitespace=True, lowercase=True):
res = '<STR_LIT>'.join(c for c in unicodedata.normalize('<STR_LIT>', s)<EOL>if unicodedata.category(c) != '<STR_LIT>')<EOL>if lowercase:<EOL><INDENT>res = res.lower()<EOL><DEDENT>for c in string.punctuation:<EOL><INDENT>res = res.replace(c, '<STR_LIT>')<EOL><DEDENT>res = re.sub('<STR_LIT>', '<STR_LIT>' if remove_whitespace else '<STR_LIT:U+0020>', res)<EOL>res = res.encode('<STR_LIT:ascii>', '<STR_LIT:ignore>').decode('<STR_LIT:ascii>')<EOL>assert re.match('<STR_LIT>', res)<EOL>return res<EOL>
Condensed version of s, containing only lowercase alphanumeric characters.

    >>> str(slug('A B. \u00e4C'))
    'abac'