fix to_files

This commit is contained in:
Emil Ahlbäck
2023-06-18 14:54:04 +02:00
parent bac7af55ab
commit 57a8700825

View File

@@ -1,6 +1,5 @@
import re import re
def parse_chat(chat): # -> List[Tuple[str, str]]: def parse_chat(chat): # -> List[Tuple[str, str]]:
# Split the chat into sections by the "*CODEBLOCKSBELOW*" token # Split the chat into sections by the "*CODEBLOCKSBELOW*" token
split_chat = chat.split("*CODEBLOCKSBELOW*") split_chat = chat.split("*CODEBLOCKSBELOW*")
@@ -15,7 +14,7 @@ def parse_chat(chat): # -> List[Tuple[str, str]]:
code_blocks = split_chat[1] if is_token_found else chat code_blocks = split_chat[1] if is_token_found else chat
# Get all ``` blocks and preceding filenames # Get all ``` blocks and preceding filenames
regex = r"\[(.*?)\]\s*```.*?\n(.*?)```" regex = r"(\S+?)\n```\S+\n(.+?)```"
matches = re.finditer(regex, code_blocks, re.DOTALL) matches = re.finditer(regex, code_blocks, re.DOTALL)
files = [] files = []