Example #1
0
def tex_escape(string):
    # do matching quotes
    string = re.sub(r'(")([^"]*)(")', r"``\2''", string)
    # any straggling quotes
    string = re.sub(r'"', "''", string)
    string = string.replace("\n", "\\\\\n")
    # The rest
    return mark_safe("".join(latex_equivalents.get(ord(c), c) for c in string))
Example #2
0
File: utils.py Project: Shidash/btb
def tex_escape(string):
    # do matching quotes
    string = re.sub(r'(")([^"]*)(")', r"``\2''", string)
    # any straggling quotes
    string = re.sub(r'"', "''", string)
    lines = [line if line != "" else u"~" for line in string.split("\n")]
    string = u"\\\\\n".join(lines)
    # The rest
    return mark_safe("".join(latex_equivalents.get(ord(c), c) for c in string))
Example #3
0
def tex_escape(string):
    # do matching quotes
    string = re.sub(r'(")([^"]*)(")', r"``\2''", string)
    # any straggling quotes
    string = re.sub(r'"', "''", string)
    lines = [line if line != "" else u"~" for line in re.split("\r?\n", string)]
    string = u"\\\\\n".join(lines)
    # The rest
    return mark_safe("".join(latex_equivalents.get(ord(c), c) for c in string))