Mark7549 commited on
Commit
7eeaa6b
·
1 Parent(s): 8e13e1c

improved spacing around punctuation in dictionary function

Browse files
Files changed (1) hide show
  1. lsj_dict.py +2 -1
lsj_dict.py CHANGED
@@ -147,7 +147,8 @@ def format_text(data):
147
  # Change <tr> tags to bold
148
  text = text.replace("<tr>", "<span class='tr'> ").replace("</tr>", "</span>")
149
 
150
- text = re.sub(r"\s+,\s+", ", ", text)
 
151
 
152
  # .replace(",", ", ").replace(";", "; ").replace(":", ": ").replace("(", " (").replace(")", ") ").replace("[", " [").replace("]", "] ").replace(" ,", ", ").replace(" ; ", "; ").replace(" : ", ": ").replace(" ." , ". ")
153
 
 
147
  # Change <tr> tags to bold
148
  text = text.replace("<tr>", "<span class='tr'> ").replace("</tr>", "</span>")
149
 
150
+ pattern = r"\s+([,;:.()\"\'\[\]])\s+"
151
+ text = re.sub(pattern, r"\1 ", text)
152
 
153
  # .replace(",", ", ").replace(";", "; ").replace(":", ": ").replace("(", " (").replace(")", ") ").replace("[", " [").replace("]", "] ").replace(" ,", ", ").replace(" ; ", "; ").replace(" : ", ": ").replace(" ." , ". ")
154