def pre_text(string, lang=None):
    """
    Encapsulate a string inside a Markdown <pre> container
    """
    s = "```{}```"
    if lang is not None:
        s = s.format(lang+"\n{}")
    return s.format(string.rstrip().strip("\n").replace("\t", ""))