More fixes to blogging by email

I’ve been using Wordpress for my blog and recently using the ‘Postie‘ plug-in to have robust blogging using an email client (all of this because there are no good blogging clients for Linux).

I noticed that my embedded links were not opening in a new tab or window - even though I was using the correct syntax. It turned out Thunderbird managed to put a line break into the HTML of every link … ARGH!

I’ve managed to patch up the plug-in code to fix this. It meant a bunch of test posts (you may have seen this if you were watching my blog minute by minute today). The fix goes into the HTML2HTML function in postie_functions.php. Here is the function with the change highlighted in green …

// This function cleans up HTML in the e-mail
function HTML2HTML ( $content ) {
$search = array(
'/<html>/', '/<\/html>/',
'/<title>/', '/<\/title>/',
'/<body.*>/', '/<\/body>/',
'/<head>/', '/<\/head>/',
'/<meta content=.*>/',
'/<img src=".*>/',
‘/<a\s*?href=”(.*?)”.*?>/’,
‘/<!DOCTYPE.*>/’
);

$replace = array (
”, ”,
”, ”,
”, ”,
”, ”,
”,
”,
‘<a href=”\\1″ target=”_blank”>’,

);
// strip extra line breaks
$content = preg_replace($search,$replace,trim($content));
return ($content);
}

Hopefully, this will mean that all of my posted links from here on out will not navigate away from the post.

Comments are closed.