Nicer structure on main.
[static.git] / parse.py
index 93e48a0..e1296c6 100755 (executable)
--- a/parse.py
+++ b/parse.py
@@ -83,7 +83,7 @@ for tag in root:
         podrozdzial_n = 0
     elif tag.tag == 'h3':
         tytul = tag.text
-        tytul = re.sub('^[0-9\. ]+', '', tytul)
+        tytul = re.sub('^[0-9\. ]+', '', tytul).strip()
         slug = slughifi(tytul.split(':')[0])
         if podrozdzial:
             podrozdzial.close()
@@ -97,14 +97,14 @@ order: %d
 ''' % (tytul, podrozdzial_n)).encode('utf-8'))
     elif podrozdzial:
         if tag.tag == 'h4':
-            tag.text = re.sub('^[0-9\. ]+', '', tag.text)
+            tag.text = re.sub('^[0-9\. ]+', '', tag.text).strip()
             tag.tag = 'h2'
             slug = slughifi(tag.text)
             etree.SubElement(tag, "a", {'class': 'permalink',
                 'id': slug, 'href': '#' + slug,
                 'title': 'Link do tego miejsca'})
         elif tag.tag == 'h5':
-            tag.text = re.sub('^[0-9\. ]+', '', tag.text)
+            tag.text = re.sub('^[0-9\. ]+', '', tag.text).strip()
             tag.tag = 'h3'
         podrozdzial.write(etree.tostring(tag, encoding='utf-8'))