def mark_code_blocks(txt, keyword='>>>', split='\n', tag='```', lang='python'):
    """

    Enclose code blocks in formatting tags. Default settings are consistent with
    markdown-styled code blocks for Python code.

    Args:
        txt: String to search for code blocks.
        keyword(optional, string): String that a code block must start with.
        split(optional, string): String that a code block must end with.
        tag(optional, string): String to enclose code block with.
        lang(optional, string) : String that determines what programming
            language is used in all code blocks. Set this to '' to disable
            syntax highlighting in markdown.

    Returns:
        string: A copy of the input with code formatting tags inserted (if any
        code blocks were found).

    """
    import re
    blocks = re.split('^%s' % split, txt, flags=re.M)
    out_blocks = []
    for block in blocks:
        lines = block.split(keyword)
        match = re.findall('(\\s*)(%s[\\w\\W]+)' % keyword, keyword.join(
            lines[1:]), re.M)
        if match:
            before_code = lines[0]
            indent = match[0][0]
            indented_tag = '%s%s' % (indent, tag)
            code = '%s%s' % (indent, match[0][1])
            out_blocks.append('%s%s%s\n%s%s' % (before_code, indented_tag,
                lang, code, indented_tag))
        else:
            out_blocks.append(block)
    return split.join(out_blocks)
