'Turn the text content of a header into a slug for use in an ID'

def slugify(self, text):

    non_safe = [c for c in text if (c in self.non_url_safe)]
    if non_safe:
        for c in non_safe:
            text = text.replace(c, '')
    text = u'_'.join(text.split())
    return text
