'Iterate over html stash and restore "safe" html.'

def run(self, text):

    for i in range(self.markdown.htmlStash.html_counter):
        (html, safe) = self.markdown.htmlStash.rawHtmlBlocks[i]
        if (self.markdown.safeMode and (not safe)):
            if (str(self.markdown.safeMode).lower() == 'escape'):
                html = self.escape(html)
            elif (str(self.markdown.safeMode).lower() == 'remove'):
                html = ''
            else:
                html = markdown.HTML_REMOVED_TEXT
        if (safe or (not self.markdown.safeMode)):
            text = text.replace(('<p>%s</p>' % (markdown.preprocessors.HTML_PLACEHOLDER % i)), (html + '\n'))
        text = text.replace((markdown.preprocessors.HTML_PLACEHOLDER % i), html)
    return text
