Skip to content

Commit

Permalink
Squash multiple whitespaces
Browse files Browse the repository at this point in the history
Multiple whitespace combinations (spaces, tabs, newlines)
together must be converted to a single space. This is really
important as user might pass an invalid text file with newlines
in it for example.
We currently do not support newlines, nor am I planning
to add it as it just increases confusion. Best way to retain
compatibility would be to squash all whitespaces together.
  • Loading branch information
Mithil467 committed Apr 5, 2020
1 parent 53fcfd0 commit b16e60f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mitype/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def __init__(self):

# Start the parser
self.text = mitype.commandline.main()
self.ogtext = self.text

self.tokens = self.text.split()

# Convert multiple spaces, tabs, newlines to single space
self.text = " ".join(self.tokens)
self.ogtext = self.text

self.current_word = ""
self.current_string = ""
Expand Down Expand Up @@ -316,4 +318,4 @@ def Resize(self, win):
def size_error(self, win):
sys.stdout.write("Window too small to print given text")
curses.endwin()
sys.exit(-1)
sys.exit(-1)

0 comments on commit b16e60f

Please sign in to comment.