From 184bed72a9da81a4de621ef62ab7aab0c61c0ddf Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 22 Feb 2010 20:57:17 +0000 Subject: Make rss feed generator atom 2.0 compliant. --- utils/markdown.php | 34 +++++++++++++++++++++++++++------- utils/rss.php | 7 ++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/utils/markdown.php b/utils/markdown.php index 89a85b2..eabd01d 100644 --- a/utils/markdown.php +++ b/utils/markdown.php @@ -38,7 +38,7 @@ define( 'MARKDOWNEXTRA_VERSION', "1.2.2" ); # Sat 21 Jun 2008 @define( 'MARKDOWN_PARSER_CLASS', 'MarkdownExtra_Parser' ); -function Markdown($text) { +function Markdown($text, $simple = false) { # # Initialize the parser and return the result of its transform method. # @@ -47,6 +47,7 @@ function Markdown($text) { if (!isset($parser)) { $parser_class = MARKDOWN_PARSER_CLASS; $parser = new $parser_class; + $parser->simple = $simple; } # Transform text using parser. @@ -83,6 +84,7 @@ class Markdown_Parser { var $predef_urls = array(); var $predef_titles = array(); + public $simple; function Markdown_Parser() { # @@ -2092,14 +2094,23 @@ class MarkdownExtra_Parser extends Markdown_Parser { $level = $matches[3]{0} == '=' ? 1 : 2; $attr = $this->_doHeaders_attr($id =& $matches[2]); $class = strtolower(str_replace(" ", "_", $this->runSpanGamut($matches[1]))); - $block = "
".$this->runSpanGamut($matches[1])."
"; + if($this->simple) { + $block = "".$this->runSpanGamut($matches[1]).""; + } else { + $block = "
".$this->runSpanGamut($matches[1])."
"; + } return "\n" . $this->hashBlock($block) . "\n\n"; } function _doHeaders_callback_atx($matches) { $level = strlen($matches[1]); $attr = $this->_doHeaders_attr($id =& $matches[3]); $class = strtolower(str_replace(" ", "_", $this->runSpanGamut($matches[2]))); - $block = "
".$this->runSpanGamut($matches[2])."
"; + if($this->simple) { + $block = "".$this->runSpanGamut($matches[2]).""; + } else { + $block = "
".$this->runSpanGamut($matches[2])."
"; + } + return "\n" . $this->hashBlock($block) . "\n\n"; } @@ -2453,12 +2464,21 @@ class MarkdownExtra_Parser extends Markdown_Parser { $centerr = ""; if(strlen($value) > 2 && $value[0] == '=' && $value[strlen($value)-1] == '=') { - $centerl = "
"; - $centerr = "
"; + if($this->simple) { + $centerl = "
"; + $centerr = "
"; + } else { + $centerl = "
"; + $centerr = "
"; + } $value = substr($value, 1, strlen($value) - 2); } - $value = "
" . - $centerl . $value . $centerr . "
"; + if($this->simple) { + $value = "

" . $centerl . $value . $centerr . "

"; + } else { + $value = "
" . + $centerl . $value . $centerr . "
"; + } } $grafs[$key] = $value; } diff --git a/utils/rss.php b/utils/rss.php index 6f909d3..bed69ce 100644 --- a/utils/rss.php +++ b/utils/rss.php @@ -56,9 +56,10 @@ class RSS { $fp = fopen($this->rssfile, "w"); fwrite($fp, "\n"); - fwrite($fp, "\n"); + fwrite($fp, "\n"); fwrite($fp, " \n"); fwrite($fp, " ".$RSS_TITLE."\n"); + fwrite($fp, " \n"); fwrite($fp, " ".$RSS_URL."\n"); fwrite($fp, " ".$RSS_DESCRIPTION."\n"); fwrite($fp, " en-us\n"); @@ -74,7 +75,7 @@ class RSS { fwrite($fp, " \n"); fwrite($fp, " ".$newsentry->title."\n"); fwrite($fp, " ".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&newsid=".$newsentry->time."\n"); - $content = Markdown(htmlspecialchars_decode($newsentry->description)); + $content = htmlspecialchars(Markdown(htmlspecialchars_decode($newsentry->description), true)); fwrite($fp, " ".$content."\n"); fwrite($fp, " ".$this->date($newsentry->time)."\n"); fwrite($fp, " ".$RSS_URL."/?page=".$RSS_TARGET_PAGE."&newsid=".$newsentry->time."\n"); @@ -101,7 +102,7 @@ class RSS { $rssentry = new RSSEntry($param->getAttribute('title'), $param->getAttribute('time'), $param->getAttribute('category'), - $param->getAttribute('description')); + $param->textContent); $this->add($rssentry); } -- cgit v1.2.3