| Module | FeedParser |
| In: |
lib/feedparser/html2text-parser.rb
lib/feedparser/feedparser.rb lib/feedparser/html-output.rb lib/feedparser/sgml-parser.rb lib/feedparser/text-output.rb |
A parser for SGML, using the derived class as static DTD. from raa.ruby-lang.org/project/html-parser
| VERSION | = | "0.3" |
# File lib/feedparser/feedparser.rb, line 275
275: def FeedParser::getcontent(e, feed = nil)
276: encoding = feed ? feed.encoding : 'utf-8'
277: children = e.children.reject do |i|
278: i.class == REXML::Text and i.to_s.chomp == ''
279: end
280: if children.length > 1
281: s = ''
282: children.each do |c|
283: s += c.to_s if c.class != REXML::Comment
284: end
285: return s.toUTF8(encoding).rmWhiteSpace!.text2html(feed)
286: elsif children.length == 1
287: c = children[0]
288: if c.class == REXML::Text
289: return e.text.toUTF8(encoding).rmWhiteSpace!.text2html(feed)
290: else
291: if c.class == REXML::CData
292: return c.to_s.toUTF8(encoding).rmWhiteSpace!.text2html(feed)
293: elsif c.text
294: return c.text.toUTF8(encoding).text2html(feed)
295: end
296: end
297: end
298: end