def hash_codeblocks(text, hashes):
def sub(match):<EOL><INDENT>block = match.group(<NUM_LIT:1>).rstrip('<STR_LIT:\n>')<EOL>block = re.sub(r'<STR_LIT>', '<STR_LIT>', block)<EOL>block = escape(block)<EOL>block = '<STR_LIT>'.format(block)<EOL>hashed = hash_text(block, '<STR_LIT>')<EOL>hashes[hashed] = block<EOL>return '<STR_LIT>' + hashed + '<STR_LIT>'<EOL><DEDENT>return re_codeblock.sub(sub, text)<EOL>
Hashes codeblocks (<pre> elements).

    Codeblocks are strictly defined to be (non-list) lines that are
    indented at least 4 spaces from the newline. Exactly 4 spaces will
    be stripped from the beginning of the line -- any leading
    whitespace after that is preserved.

    Codeblock lines that are separated only by blank lines will be
    included in the same codeblock (as will the intermediate newlines).

    Certain HTML entities (&, <, >, ", ') will always be escaped inside
    code blocks.

    Markdown defines code blocks to be <pre><code>, not just <pre>.
    Certain highlighting packages (like highlight.js) are designed
    to accomodate (and even look) for this type of conversion.