def slug(text, separator="<STR_LIT:_>", permitted_chars=SLUG_CHARS):
text = six.text_type(text or "<STR_LIT>")<EOL>text = normalize("<STR_LIT>", text.strip()).encode("<STR_LIT:ascii>", "<STR_LIT:ignore>").decode("<STR_LIT:ascii>")<EOL>text = REGEXP_WORD_BOUNDARY.sub("<STR_LIT>" + re.escape(separator), text)<EOL>allowed_chars = list(permitted_chars) + [separator]<EOL>text = "<STR_LIT>".join(char for char in text if char in allowed_chars).lower()<EOL>text = (<EOL>REGEXP_SEPARATOR<EOL>if separator == "<STR_LIT:_>"<EOL>else re.compile("<STR_LIT:(>" + re.escape(separator) + "<STR_LIT>")<EOL>).sub(separator, text)<EOL>return text.strip(separator)<EOL>
Generate a slug for the `text`.

    >>> slug(' ÁLVARO  justen% ')
    'alvaro_justen'
    >>> slug(' ÁLVARO  justen% ', separator='-')
    'alvaro-justen'