Module: Syndication::Content
- Included in:
- RSS::Channel, RSS::Item
- Defined in:
- lib/syndication/content.rb
Overview
Mixin for RSS 1.0 content module.
This is the approved way to include actual HTML text in an RSS feed. To use it, require ‘syndication/content’ to add the content_encoded and content_decoded methods to the Syndication::Item class.
Instance Attribute Summary collapse
-
#content_encoded ⇒ Object
Actual web content, entity encoded or CDATA-escaped.
Instance Method Summary collapse
-
#content_decoded ⇒ Object
Decoded version of content_encoded, as HTML.
Instance Attribute Details
#content_encoded ⇒ Object
Actual web content, entity encoded or CDATA-escaped.
14 15 16 |
# File 'lib/syndication/content.rb', line 14 def content_encoded @content_encoded end |
Instance Method Details
#content_decoded ⇒ Object
Decoded version of content_encoded, as HTML.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/syndication/content.rb', line 17 def content_decoded if !@content_encoded or @content_encoded == '' return @content_encoded end # CDATA is the easier case if @content_encoded.match(/<!\[CDATA\[(.*)\]\]>/m) return $1 end # Decode escaped entities x = @content_encoded.gsub(/</, '<') x.gsub!(/>/, '>') return x.gsub(/&/, '&') end |