Deutsche Version dieses Blogeintrags.
I, beeing a real geeky lazybone, use much HTML in my blog. The internal RSS encoding the XML entities does not work fine all, because that implementation does destroy HTML, changes it to plain text.
My flavour templates adds HTML to element description with a CDATA section. In a CDATA section you can insert HTML without special recoding, because CDATA means to the XML parser: Do not parse, use as is!
OK, my approach for a better RSS-HTML in Blosxom with filtering only the allowed and really useful HTML.
As prerequisites you need HTML::TagFilter; sorry for the inconvenience. Please fetch it from CPAN.
My patch refers to the CVS Rev. 1.69 of blosxom.
Instead of using (line 663–675):
if ( $encode_xml_entities && $content_type =~ m{\bxml\b} ) {
# Escape <, >, and &, and to produce valid RSS
my %escape = (
'<' => '<',
'>' => '>',
'&' => '&',
'"' => '"'
);
my $escape_re = join '|' => keys %escape;
$title =~ s/($escape_re)/$escape{$1}/g;
$body =~ s/($escape_re)/$escape{$1}/g;
}
use this part:
## --- 07-2008 Patch by GwenDragon for HTML and RSS ---
## (c)2008 Lilo von Hanffstengel "GwenDragon"
## see http://www.gwendragon.de/blog/Web/Webapplikationen/Blosxom/RSS-Patch-for-HTML.html
## --------------
if ( $content_type =~ m{\bxml\b} ) {
my $t = $title;
my $b = $body;
eval {
require HTML::Entities;
$t = HTML::Entities::decode( $t );
#$b = HTML::Entities::decode( $b );
require HTML::TagFilter;
# and strip off HTML
my $tf = new HTML::TagFilter;
$t = $tf->filter( $t );
$b = $tf->filter( $b );
};
if ( not $@ ) {
$title = $t;
$body = $b;
}
#
if ( $@ and $encode_xml_entities ) {
# decode HTML
$title = HTML::Entities::decode($title);
$body = HTML::Entities::decode($body);
#
# Escape <, >, and &, and to produce valid RSS
my %escape = (
'<' => '<',
'>' => '>',
'&' => '&',
'"' => '"'
);
my $escape_re = join '|' => keys %escape;
$title =~ s/($escape_re)/$escape{$1}/g;
$body =~ s/($escape_re)/$escape{$1}/g;
}
}
# -------------
Use and enjoy. But add a short author information about me for this patch in Blosxom's code. Thanks.
In case of problems with the patch please contact me.

Kommentar für Blogeintrag
Vorschau des Kommentars
TrackBack-URL:
http://gwendragon.de/blog/Web/Webapplikationen/Blosxom/RSS-Patch-for-HTML.html/trackback↑Artikel