Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
99f09eb247
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  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