diff options
author | Waylan Limberg <waylan@gmail.com> | 2013-02-12 16:16:54 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2013-02-12 16:16:54 -0500 |
commit | 5c5612a404f920e08aacfb50fcf4eca08a994d17 (patch) | |
tree | cff0b705a10c72644ed3675e540b44f3e6e81a3e | |
parent | b913666b4392bab993cec34ee85dd5de77601bd5 (diff) | |
download | markdown-5c5612a404f920e08aacfb50fcf4eca08a994d17.tar.gz markdown-5c5612a404f920e08aacfb50fcf4eca08a994d17.tar.bz2 markdown-5c5612a404f920e08aacfb50fcf4eca08a994d17.zip |
Remove RSS Extension.
Closes #143. If you would like to continue using
the extension (not recomended), it is archived on
[Github](https://gist.github.com/waylan/4773365).
-rw-r--r-- | docs/extensions/index.txt | 2 | ||||
-rw-r--r-- | docs/extensions/nl2br.txt | 4 | ||||
-rw-r--r-- | docs/extensions/rss.txt | 41 | ||||
-rw-r--r-- | docs/extensions/sane_lists.txt | 4 | ||||
-rw-r--r-- | docs/release-2.3.txt | 4 | ||||
-rw-r--r-- | markdown/extensions/rss.py | 114 |
6 files changed, 8 insertions, 161 deletions
diff --git a/docs/extensions/index.txt b/docs/extensions/index.txt index c9ee005..5cbdd7d 100644 --- a/docs/extensions/index.txt +++ b/docs/extensions/index.txt @@ -69,7 +69,6 @@ Extension | Name in Python-Markdown [HeaderId] | `headerid` [Meta-Data] | `meta` [New Line to Break] | `nl2br` -[RSS] | `rss` [Sane Lists] | `sane_lists` [Table of Contents] | `toc` [WikiLinks] | `wikilinks` @@ -80,7 +79,6 @@ Extension | Name in Python-Markdown [HeaderId]: header_id.html [Meta-Data]: meta_data.html [New Line to Break]: nl2br.html -[RSS]: rss.html [Sane Lists]: sane_lists.html [Table of Contents]: toc.html [WikiLinks]: wikilinks.html diff --git a/docs/extensions/nl2br.txt b/docs/extensions/nl2br.txt index affd8ee..ef479fd 100644 --- a/docs/extensions/nl2br.txt +++ b/docs/extensions/nl2br.txt @@ -1,8 +1,8 @@ title: New Line to Break Extension prev_title: Meta-Data Extension prev_url: meta_data.html -next_title: RSS Extension -next_url: rss.html +next_title: Sane Lists Extension +next_url: sane_lists.html NL2BR Extension =============== diff --git a/docs/extensions/rss.txt b/docs/extensions/rss.txt deleted file mode 100644 index 67e6d96..0000000 --- a/docs/extensions/rss.txt +++ /dev/null @@ -1,41 +0,0 @@ -title: RSS Extension -prev_title: New Line to Break Extension -prev_url: nl2br.html -next_title: Sane Lists Extension -next_url: sane_lists.html - -RSS -=== - -Summary -------- - -An extension to Python-Markdown that outputs a markdown document as RSS. This -extension has been included with Python-Markdown since 1.7 and should be -available to anyone who has a typical install of Python-Markdown. - -Usage ------ - -From the Python interpreter: - - >>> import markdown - >>> text = "Some markdown document." - >>> rss = markdown.markdown(text, ['rss']) - -Configuring the Output ----------------------- - -An RSS document includes some data about the document (URI, author, title) that -will likely need to be configured for your needs. Therefore, three configuration -options are available: - -* **URL** : The Main URL for the document. -* **CREATOR** : The Feed creator's name. -* **TITLE** : The title for the feed. - -An example: - - >>> rss = markdown.markdown(text, extensions = \ - ... ['rss(URL=http://example.com,CREATOR=JOHN DOE,TITLE=My Document)'] - ... ) diff --git a/docs/extensions/sane_lists.txt b/docs/extensions/sane_lists.txt index e6c73f4..4d24d17 100644 --- a/docs/extensions/sane_lists.txt +++ b/docs/extensions/sane_lists.txt @@ -1,6 +1,6 @@ title: Sane Lists Extension -prev_title: RSS Extension -prev_url: rss.html +prev_title: New Line to Break Extension +prev_url: nl2br.html next_title: Table of Contents Extension next_url: toc.html diff --git a/docs/release-2.3.txt b/docs/release-2.3.txt index 37c42d9..e7a6414 100644 --- a/docs/release-2.3.txt +++ b/docs/release-2.3.txt @@ -29,6 +29,10 @@ reference to those ids in your JavaScript or CSS and using the HTML5 output, you will need to update your code accordingly. No changes are necessary if you are outputing XHTML (the default) or HTML4. +* The "RSS" extension has been removed and no longer ships with Python-Markdown. +If you would like to continue using the extension (not recomended), it is archived +on [Github](https://gist.github.com/waylan/4773365). + What's New in Python-Markdown 2.3 --------------------------------- diff --git a/markdown/extensions/rss.py b/markdown/extensions/rss.py deleted file mode 100644 index 72d6435..0000000 --- a/markdown/extensions/rss.py +++ /dev/null @@ -1,114 +0,0 @@ -import markdown -from markdown.util import etree - -DEFAULT_URL = "http://packages.python.org/Markdown/" -DEFAULT_CREATOR = "Yuri Takhteyev" -DEFAULT_TITLE = "Markdown in Python" -GENERATOR = "http://packages.python.org/Markdown/extensions/rss.html" - -month_map = { "Jan" : "01", - "Feb" : "02", - "March" : "03", - "April" : "04", - "May" : "05", - "June" : "06", - "July" : "07", - "August" : "08", - "September" : "09", - "October" : "10", - "November" : "11", - "December" : "12" } - -def get_time(heading): - - heading = heading.split("-")[0] - heading = heading.strip().replace(",", " ").replace(".", " ") - - month, date, year = heading.split() - month = month_map[month] - - return rdftime(" ".join((month, date, year, "12:00:00 AM"))) - -def rdftime(time): - - time = time.replace(":", " ") - time = time.replace("/", " ") - time = time.split() - return "%s-%s-%sT%s:%s:%s-08:00" % (time[0], time[1], time[2], - time[3], time[4], time[5]) - - -def get_date(text): - return "date" - -class RssExtension (markdown.Extension): - - def extendMarkdown(self, md, md_globals): - - self.config = { 'URL' : [DEFAULT_URL, "Main URL"], - 'CREATOR' : [DEFAULT_CREATOR, "Feed creator's name"], - 'TITLE' : [DEFAULT_TITLE, "Feed title"] } - - md.xml_mode = True - - # Insert a tree-processor that would actually add the title tag - treeprocessor = RssTreeProcessor(md) - treeprocessor.ext = self - md.treeprocessors['rss'] = treeprocessor - md.stripTopLevelTags = 0 - md.docType = '<?xml version="1.0" encoding="utf-8"?>\n' - -class RssTreeProcessor(markdown.treeprocessors.Treeprocessor): - - def run (self, root): - - rss = etree.Element("rss") - rss.set("version", "2.0") - - channel = etree.SubElement(rss, "channel") - - for tag, text in (("title", self.ext.getConfig("TITLE")), - ("link", self.ext.getConfig("URL")), - ("description", None)): - - element = etree.SubElement(channel, tag) - element.text = text - - for child in root: - - 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"]: - 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.markdown.htmlStash.store( - "<![CDATA[ %s]]>" % content) - description.text = pholder - - return rss - - -def makeExtension(configs): - - return RssExtension(configs) |