From 6315527b2f7676ae4afa1ce5cb78e11d25917f23 Mon Sep 17 00:00:00 2001 From: Frederic Hemberger Date: Tue, 4 Oct 2011 19:18:40 +0200 Subject: [PATCH] Adds CDATA sections to atom.xml, fixes #198 --- .themes/classic/source/atom.xml | 12 +++++------- plugins/octopress_filters.rb | 5 +++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.themes/classic/source/atom.xml b/.themes/classic/source/atom.xml index ff8d259..83af3f8 100644 --- a/.themes/classic/source/atom.xml +++ b/.themes/classic/source/atom.xml @@ -4,26 +4,24 @@ layout: nil - {{ site.title | xml_escape }} + <![CDATA[{{ site.title }}]]> {{ site.time | date_to_xmlschema }} {{ site.url }}/ - {{ site.author | xml_escape }} - {% if site.email %} - {{ site.email | xml_escape }} - {% endif %} + + {% if site.email %}{% endif %} Octopress {% for post in site.posts limit: 20 %} - {{ post.title | xml_escape }} + <![CDATA[{{ post.title | cdata_escape }}]]> {{ post.date | date_to_xmlschema }} {{ site.url }}{{ post.id }} - {{ post.content | expand_urls: site.url | xml_escape }} + {% endfor %} diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index 7eaaaa7..ef8c1fb 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -63,6 +63,11 @@ module OctopressLiquidFilters return (content.nil?) ? input : content end + # Escapes CDATA sections in post content + def cdata_escape(input) + input.gsub(//, ']]>') + end + # Replaces relative urls with full urls def expand_urls(input, url='') url ||= '/'