Browse Source

Quote Preparser adds empty line at end of quote block. #298

Rafał Pitoń 11 years ago
parent
commit
ced0e39cd4
1 changed files with 15 additions and 0 deletions
  1. 15 0
      misago/markdown/extensions/quotes.py

+ 15 - 0
misago/markdown/extensions/quotes.py

@@ -20,9 +20,23 @@ class QuoteTitlesPreprocessor(markdown.preprocessors.Preprocessor):
     def __init__(self, md):
     def __init__(self, md):
         markdown.preprocessors.Preprocessor.__init__(self, md)
         markdown.preprocessors.Preprocessor.__init__(self, md)
 
 
+    def find_quote_depth(self, line):
+        depth = 0
+        try:
+            while line[0] == '>':
+                depth += 1
+                line = line[1:].strip()
+        except IndexError:
+            pass
+        return depth
+
     def run(self, lines):
     def run(self, lines):
         clean = []
         clean = []
+        quote_dept = 0
         for l, line in enumerate(lines):
         for l, line in enumerate(lines):
+            if quote_dept > self.find_quote_depth(line):
+                clean.append("")
+            quote_dept = self.find_quote_depth(line)
             try:
             try:
                 if line.strip():
                 if line.strip():
                     at_match = QUOTE_AUTHOR_RE.match(line.strip())
                     at_match = QUOTE_AUTHOR_RE.match(line.strip())
@@ -38,6 +52,7 @@ class QuoteTitlesPreprocessor(markdown.preprocessors.Preprocessor):
                     clean.append(line)
                     clean.append(line)
             except IndexError:
             except IndexError:
                 clean.append(line)
                 clean.append(line)
+        print clean
         return clean
         return clean