Anonymous avatar Anonymous committed 0c17d0a

don't add space before closing quote
strip spaces at end of line
don't add newlines just before eof

Comments (0)

Files changed (1)

         quote_stack = []
         self.edited_text = u''
         for i, token in enumerate(self._tokens[:-1]):
+            next_token = self._tokens[i + 1]
             # if we have a paragraph break, insert that and go on to
             # next token
             if token.is_para:
-                self.edited_text += u'\n\n'
+                if not next_token.is_eof:
+                    self.edited_text = self.edited_text.rstrip() + u'\n\n'
             # skip non-printing tokens
             if token.non_printing:
             # now figure out how many spaces should follow it
             append_space = ' '
-            next_token = self._tokens[i + 1]
             if (token.is_open or
                 token.is_currency_symbol or
                 next_token.is_nonspacing_punc or
                     append_space = ''
+            elif (next_token.is_quote and
+                  quote_stack and
+                  quote_stack[-1] == next_token.str):
+                # no space before close quote
+                append_space = ''
             elif token.str == '.':
-                append_space = '  '
+                if not next_token.is_eof:
+                    append_space = '  '
             elif token.is_quote:
                 if quote_stack and quote_stack[-1] == token.str:
                     # space after close quote
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.