Commits

Chris Chambers committed 27b10a1

Allow updates in lists

Comments (0)

Files changed (2)

         return izip_longest(fillvalue='', *([iter(fn(*args, **kwargs))] * 2))
     return grouper
 
-itersections = pairer(r'([\s\S]+?)'.join([r'^[ ]{,3}(?:\*[ ]?){3,}\s*\n'] * 2))
+itersections = pairer(r'([\s\S]+?)'.join([r'^[ ]{,3}(?:\*[ ]?){3,}\s*?\n'] * 2))
 
 matchupdate = re.compile(
-    r'''^(?:\s*\n)?             # zero or more empty lines
-    (?P<level>\#{1,6})[ \t]*    # one or more number signs
-    update\b                    # "update" (case insensitive)
-    (?P<metadata>[^\n]+)\n+     # date, time, and time zone
-    (?P<body>.+)$               # the update's body
+    r'''^(?:\s*\n)?                    # zero or more empty lines
+    (?P<list>(\*\s+)|(\d+\.\s+)|\s*)?  # optionaly include a list or indent
+    (?P<level>\#{1,6})[ \t]*           # one or more number signs
+    update\b                           # "update" (case insensitive)
+    (?P<metadata>[^\n]+)\n+            # date, time, and time zone
+    (?P<body>.+)$                      # the update's body
     ''',
     re.DOTALL | re.IGNORECASE | re.VERBOSE).match
 
 
         source = self._pluckhandcraftedexcerpt()
 
+        updates = []
+        intersperced = ""
+        MANGO_PLACEHOLDER = "MangoUpdatePlaceholderxxz"
+
         for nonsection, section in itersections(source):
-            self.html += self._convert(nonsection) + '\n'
-
+            intersperced += nonsection
+            
             match = matchupdate(section)
             if match:
+                intersperced += match.group('list') or ''
+                intersperced += MANGO_PLACEHOLDER + '\n'
                 update = renderupdate(self, match)
                 if update:
-                    self.html += update
+                    updates.append(update)
                     continue
+ 
+            if section:
+                intersperced += section
+                self._excerpt += self._convert(section) + '\n'
 
-            if section:
-                excerpt = self._convert(section) + '\n'
-                self._excerpt += excerpt
-                self.html += excerpt
+        self.html += self._convert(intersperced)
+
+        # We will only sometimes have it wrapped in <p> tags, rely on the <div> for formatting
+        self.html = self.html.replace('<p>' + MANGO_PLACEHOLDER + '</p>', MANGO_PLACEHOLDER)
+        for s in updates:
+            self.html = self.html.replace(MANGO_PLACEHOLDER, s, 1)
 
         self._excerpt = mark_safe(replace(self._excerpt.rstrip('\n')))
 

static/default.css

           header time                           { display: block; font: normal 2em/1.125em Georgia, serif; color: rgb(163, 175, 187); }
         .update                                 { margin: 1.5em -32px 0; background: #dee; padding: 1.5em 32px; }
             .update h4                          { padding: 0; font-weight: bold; font-size: 1em; line-height: 1.5em; }
+        li .update                              { padding-top: 0}
+        li .update h1                           { padding-top: 0}
+        li .update h2                           { padding-top: 0}
+        li .update h3                           { padding-top: 0}
+        li .update h4                           { padding-top: 0}
+        li .update h5                           { padding-top: 0}
+        li .update h6                           { padding-top: 0}
         .metadata                               { margin: 2em 0 0; font-size: 0.75em; font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif; text-shadow: 0 1px 0 #fff; overflow: hidden; }
           .metadata ::-moz-selection            { background: transparent; }
           .metadata ::selection                 { background: transparent; }