Welcome to Geeklog, Anonymous Friday, April 19 2024 @ 06:08 am EDT

Geeklog Forums

Displaying HTML formatting in an RSS feed


Status: offline

lfalfa

Forum User
Newbie
Registered: 04/01/04
Posts: 12
I was unhappy that my RSS feed stripped out HTML formatting. So I hacked rss.feed.class.php so that it no longer stripped out the tags.

The change was on line 205 in method _formatContent().

Change:
Text Formatted Code

$storytext = trim (strip_tags ($text));

 


To:
Text Formatted Code

$storytext = trim ($text);

 


This doesn't seem to cause any ill effects in a typical story, but of course if your story contained tags that interfered with the RSS feed's tags, you'd end up with an invalid feed. Your mileage may vary, and so on.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Hmm, have you checked your RSS feed for validity after that change? If it's not valid RSS, many feed readers won't be able to read your feed any more ...

bye, Dirk
 Quote

Status: offline

lfalfa

Forum User
Newbie
Registered: 04/01/04
Posts: 12
Thanks for the tip. I just checked, and it's validating as well as it did before I removed the strip_tags() call. It's still failing because my HTML editor plug-in inserts curly-quotes as high-bit characters (bad) instead of as HTML entities (good). I've kinda stopped using the HTML editor plug-in anyway, though, so this shouldn't be a big deal in the future.
 Quote

Status: offline

lfalfa

Forum User
Newbie
Registered: 04/01/04
Posts: 12
Another change I decided to make to the class is to turn off HTML quoting. I realized that some feed readers de-quote quoted HTML, but others (notably BlogLines) don't. On line 214, change:
Text Formatted Code

return htmlspecialchars($storytext);


 

to:
Text Formatted Code

return $storytext;


 
 Quote

All times are EDT. The time is now 06:08 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content