import re
from prompt_toolkit.clipboard import pyperclip
def main(header_level: int = 2):
txt_data = pyperclip.pyperclip.paste()
print(re.sub("\n[^(> \* )]", "\n- ", txt_data))
notes = txt_data.split("> * ")
txt_data = "---\n\n".join(notes)
if "open in [pagenote.cn]" in txt_data:
txt_data, _ = txt_data.split("open in [pagenote.cn]")
if header_level == 2:
txt_data = txt_data.replace("## [", "# [")
txt_data = txt_data.replace("\n", "\n\n", 1)
txt_data = txt_data + "---\n"
pyperclip.pyperclip.copy(txt_data)
print(txt_data)
if __name__ == "__main__":
main()