def _hash_html_blocks(self, text, raw=False):
if '<STR_LIT:<>' not in text:<EOL><INDENT>return text<EOL><DEDENT>hash_html_block_sub = _curry(self._hash_html_block_sub, raw=raw)<EOL>text = self._strict_tag_block_re.sub(hash_html_block_sub, text)<EOL>text = self._liberal_tag_block_re.sub(hash_html_block_sub, text)<EOL>if "<STR_LIT>" in text:<EOL><INDENT>_hr_tag_re = _hr_tag_re_from_tab_width(self.tab_width)<EOL>text = _hr_tag_re.sub(hash_html_block_sub, text)<EOL><DEDENT>if "<STR_LIT>" in text:<EOL><INDENT>start = <NUM_LIT:0><EOL>while True:<EOL><INDENT>try:<EOL><INDENT>start_idx = text.index("<STR_LIT>", start)<EOL><DEDENT>except ValueError:<EOL><INDENT>break<EOL><DEDENT>try:<EOL><INDENT>end_idx = text.index("<STR_LIT>", start_idx) + <NUM_LIT:3><EOL><DEDENT>except ValueError:<EOL><INDENT>break<EOL><DEDENT>start = end_idx<EOL>if start_idx:<EOL><INDENT>for i in range(self.tab_width - <NUM_LIT:1>):<EOL><INDENT>if text[start_idx - <NUM_LIT:1>] != '<STR_LIT:U+0020>':<EOL><INDENT>break<EOL><DEDENT>start_idx -= <NUM_LIT:1><EOL>if start_idx == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if start_idx == <NUM_LIT:0>:<EOL><INDENT>pass<EOL><DEDENT>elif start_idx == <NUM_LIT:1> and text[<NUM_LIT:0>] == '<STR_LIT:\n>':<EOL><INDENT>start_idx = <NUM_LIT:0>  <EOL><DEDENT>elif text[start_idx-<NUM_LIT:2>:start_idx] == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>while end_idx < len(text):<EOL><INDENT>if text[end_idx] not in '<STR_LIT>':<EOL><INDENT>break<EOL><DEDENT>end_idx += <NUM_LIT:1><EOL><DEDENT>if text[end_idx:end_idx+<NUM_LIT:2>] not in ('<STR_LIT>', '<STR_LIT:\n>', '<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>html = text[start_idx:end_idx]<EOL>if raw and self.safe_mode:<EOL><INDENT>html = self._sanitize_html(html)<EOL><DEDENT>key = _hash_text(html)<EOL>self.html_blocks[key] = html<EOL>text = text[:start_idx] + "<STR_LIT>" + key + "<STR_LIT>" + text[end_idx:]<EOL><DEDENT><DEDENT>if "<STR_LIT>" in self.extras:<EOL><INDENT>_xml_oneliner_re = _xml_oneliner_re_from_tab_width(self.tab_width)<EOL>text = _xml_oneliner_re.sub(hash_html_block_sub, text)<EOL><DEDENT>return text<EOL>
Hashify HTML blocks

        We only want to do this for block-level HTML tags, such as headers,
        lists, and tables. That's because we still want to wrap <p>s around
        "paragraphs" that are wrapped in non-block-level tags, such as anchors,
        phrase emphasis, and spans. The list of tags we're looking for is
        hard-coded.

        @param raw {boolean} indicates if these are raw HTML blocks in
            the original source. It makes a difference in "safe" mode.