aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2008-11-23 18:13:14 -0500
committerWaylan Limberg <waylan@gmail.com>2008-11-23 18:13:14 -0500
commitd952587e33fcebb8f3807a863f2bdd50b86b5b23 (patch)
treea7adde572fe0661b1551e4627ea747ba3c2811c3
parent019d7ca0cb3d1f98bb209cc3fb48d6941d1aac7d (diff)
downloadmarkdown-d952587e33fcebb8f3807a863f2bdd50b86b5b23.tar.gz
markdown-d952587e33fcebb8f3807a863f2bdd50b86b5b23.tar.bz2
markdown-d952587e33fcebb8f3807a863f2bdd50b86b5b23.zip
Fixed rss extension (I think). It throws away any paragraphs before first header, but I think that's what is was trying to do (and failing loadly) before.
-rw-r--r--markdown/extensions/rss.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/markdown/extensions/rss.py b/markdown/extensions/rss.py
index b7215df..1274da2 100644
--- a/markdown/extensions/rss.py
+++ b/markdown/extensions/rss.py
@@ -52,7 +52,7 @@ class RssExtension (markdown.Extension):
md.xml_mode = True
# Insert a tree-processor that would actually add the title tag
- treeprocessor = RssTreeProcessor(self)
+ treeprocessor = RssTreeProcessor(md)
treeprocessor.ext = self
md.treeprocessors['rss'] = treeprocessor
md.stripTopLevelTags = 0
@@ -60,10 +60,6 @@ class RssExtension (markdown.Extension):
class RssTreeProcessor(markdown.treeprocessors.Treeprocessor):
- def __init__(self, md):
-
- pass
-
def run (self, root):
rss = etree.Element("rss")
@@ -80,34 +76,34 @@ class RssTreeProcessor(markdown.treeprocessors.Treeprocessor):
for child in root:
-
- if child.tag in ["h1", "h2", "h3", "h4", "h5"] :
+ if child.tag in ["h1", "h2", "h3", "h4", "h5"]:
heading = child.text.strip()
-
item = etree.SubElement(channel, "item")
-
link = etree.SubElement(item, "link")
link.text = self.ext.getConfig("URL")
-
title = etree.SubElement(item, "title")
title.text = heading
guid = ''.join([x for x in heading if x.isalnum()])
-
guidElem = etree.SubElement(item, "guid")
guidElem.text = guid
guidElem.set("isPermaLink", "false")
- elif child.tag in ["p"] :
- if item:
+ elif child.tag in ["p"]:
+ try:
description = etree.SubElement(item, "description")
+ except UnboundLocalError:
+ # Item not defined - moving on
+ pass
+ else:
if len(child):
content = "\n".join([etree.tostring(node)
for node in child])
else:
content = child.text
- pholder = self.stash.store("<![CDATA[ %s]]>" % content)
+ pholder = self.markdown.htmlStash.store(
+ "<![CDATA[ %s]]>" % content)
description.text = pholder
return rss