gstaff commited on
Commit
d134f26
·
1 Parent(s): 51b226c

Fix multiline FlavorText field parsing.

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -124,12 +124,12 @@ Color: ['W']
124
  print(f'ASSISTANT REPLY:\n{assistant_reply}')
125
  new_card_text = assistant_reply.split('```')
126
  if len(new_card_text) > 1:
127
- new_card_text = new_card_text[1].strip()
128
  else:
129
  new_card_text = assistant_reply.split('\n\n')
130
  if len(new_card_text) < 2:
131
  return assistant_reply, card_text, None
132
- new_card_text = new_card_text[1].strip()
133
  return assistant_reply, new_card_text, None
134
 
135
 
@@ -202,7 +202,7 @@ def format_html(text, image_data):
202
  line = line.replace('(', '(<i>').replace(')', '</i>)')
203
  text_lines.append(f"<p>{line}</p>")
204
  template = template.replace("{card_text}", "\n".join(text_lines))
205
- pattern = re.compile(r'Flavor.?Text: (.*?)\n^.+:', re.MULTILINE | re.DOTALL)
206
  flavor_text = pattern.findall(text)
207
  if flavor_text:
208
  flavor_text = flavor_text[0]
 
124
  print(f'ASSISTANT REPLY:\n{assistant_reply}')
125
  new_card_text = assistant_reply.split('```')
126
  if len(new_card_text) > 1:
127
+ new_card_text = new_card_text[1].strip() + '\n'
128
  else:
129
  new_card_text = assistant_reply.split('\n\n')
130
  if len(new_card_text) < 2:
131
  return assistant_reply, card_text, None
132
+ new_card_text = new_card_text[1].strip() + '\n'
133
  return assistant_reply, new_card_text, None
134
 
135
 
 
202
  line = line.replace('(', '(<i>').replace(')', '</i>)')
203
  text_lines.append(f"<p>{line}</p>")
204
  template = template.replace("{card_text}", "\n".join(text_lines))
205
+ pattern = re.compile(r'Flavor.?Text: (.*?)\n^.*$', re.MULTILINE | re.DOTALL)
206
  flavor_text = pattern.findall(text)
207
  if flavor_text:
208
  flavor_text = flavor_text[0]