import os,re
import win32clipboard as wc
import win32con

# 获取剪切板内容
def getCopy():
    wc.OpenClipboard()
    t = wc.GetClipboardData(win32con.CF_UNICODETEXT)
    wc.CloseClipboard()
    return t

# 写入剪切板内容
def setCopy(str):
    wc.OpenClipboard()
    wc.EmptyClipboard()
    wc.SetClipboardData(win32con.CF_UNICODETEXT, str)
    wc.CloseClipboard()


data = getCopy()
# print(modified_data)
modified_data = re.sub(r"\((\d)\)",lambda x: "\\textcircled{"+x.group(1)+"}",data)
# print(modified_data)
modified_data = re.sub(r"\$\\textcircled\{\\scriptsize\{(\d)\}\}",lambda x: "\\textcircled{"+x.group(1)+"}$",modified_data)
modified_data = re.sub(r"\\textcircled\{\\scriptsize\{(\d)\}\}",lambda x: "\\textcircled{"+x.group(1)+"}",modified_data)


setCopy(modified_data)

with open("临时文件/outputfile.txt","w",encoding = "utf8") as f:
    f.write(modified_data)