Browse Source

Remove multiple spaces.

Stefano Cossu 2 years ago
parent
commit
f4c2da8165
1 changed files with 7 additions and 1 deletions
  1. 7 1
      transliterator/trans.py

+ 7 - 1
transliterator/trans.py

@@ -1,8 +1,13 @@
 import logging
+import re
 
 from transliterator.tables import load_table
 
 
+# Match multiple spaces.
+MULTI_WS_RE = re.compile(r"\s{2,}")
+
+
 logger = logging.getLogger(__name__)
 
 
@@ -67,11 +72,12 @@ def transliterate(src, script, lang, s2r=True):
             dest_ls.append(src[i])
             i += 1
 
-    breakpoint()
     if langsec_dir.get("capitalize", False):
         dest_ls[0] = dest_ls[0].capitalize()
 
     logger.info(f"Output list: {dest_ls}")
     dest = "".join(dest_ls)
 
+    dest = re.sub(MULTI_WS_RE, ' ', dest)
+
     return dest