Przeglądaj źródła

Clean div tags from summary

There are some open div tags in the summary if you're using rst and headings. This will remove these tags from the summary.
Geert Braekmans 7 lat temu
rodzic
commit
99f09eb247
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      summary/summary.py

+ 4 - 0
summary/summary.py

@@ -9,6 +9,7 @@ body of your articles.
 from __future__ import unicode_literals
 from pelican import signals
 from pelican.generators import ArticlesGenerator, StaticGenerator, PagesGenerator
+import re
 
 def initialized(pelican):
     from pelican.settings import DEFAULT_CONFIG
@@ -76,6 +77,9 @@ def extract_summary(instance):
         if end_summary:
             content = content.replace(end_marker, '', 1)
 
+    summary = re.sub(r"<div.*>", "", summary)
+    summary = re.sub(r"</div>", "", summary)
+
     instance._content = content
     instance._summary = summary
     instance.has_summary = True