[tor-commits] [stem/master] Consolidate manual newlines

atagar at torproject.org atagar at torproject.org
Sun Dec 6 21:57:12 UTC 2015


commit e078c7881265c2b5a84d22d02572625d887f3aee
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Dec 1 09:52:57 2015 -0800

    Consolidate manual newlines
    
    When we have a man entry that's 'pretty\n\n\nflowers' we want to treat all
    those newlines as a single one. Previously we replaced each with two new
    newlines, making it...
    
      'pretty\n\n\n\n\n\nflowers'
    
    Unsure why the tests passed on my netbook but oh well. *shrug*
---
 stem/manual.py |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/stem/manual.py b/stem/manual.py
index 975ac1a..60ffc25 100644
--- a/stem/manual.py
+++ b/stem/manual.py
@@ -519,4 +519,13 @@ def _join_lines(lines):
   Simple join, except we want empty lines to still provide a newline.
   """
 
-  return ''.join([line if line else '\n\n' for line in lines])
+  result = []
+
+  for line in lines:
+    if not line:
+      if result and result[-1] != '\n\n':
+        result.append('\n\n')
+    else:
+      result.append(line)
+
+  return ''.join(result)





More information about the tor-commits mailing list