<?php
ob_start( 'joke_xhtml_valid' ) ;
// ob filter
function joke_xhtml_valid( $s )
{
$s = str_replace( '<br>' , '<br />' , $s ) ;
$s = str_replace( '<hr>' , '<hr />' , $s ) ;
$s = str_replace( '<br /><br />' , '<br />' , $s ) ;
$s = preg_replace_callback( '/\<img [^>]+\>/' , 'joke_xhtml_valid_img_alt' , $s ) ;
$s = preg_replace_callback( '/\<table [^>]+\>/' , 'joke_xhtml_valid_table_summary' , $s ) ;
return $s ;
}
function joke_xhtml_valid_img_alt( $matches )
{
if( stristr( $matches[0] , 'alt=' ) ) {
return $matches[0] ;
} else {
return '<img alt="" ' . substr( $matches[0] , 5 ) ;
}
}
function joke_xhtml_valid_table_summary( $matches )
{
if( stristr( $matches[0] , 'summary=' ) ) {
return $matches[0] ;
} else {
return '<table summary="dummy" ' . substr( $matches[0] , 7 ) ;
}
}
?>