示例#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))
示例#2
0
文件: utils.py 项目: 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))
示例#3
0
文件: utils.py 项目: yourcelf/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 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))