Page 1 of 1
HTML Characters in Emails
Posted: Mon Feb 23, 2009 4:56 pm
by dex
I'm using Serendipity in an environment with several bloggers and different groups of people that get automatic emails depending on the category of the post. Some of the bloggeres have the habit (as I do myself) of putting two spaces to start a sentence after a period. My issue is that this is converted to
(I.e. non breaking space plus a blank space) in the email. Entries become difficult to read. I'm sure someone would have had a similar issue and knows of the setting to get around this.
I have already scoured the general and plugin settings for something that might make sense. I have selected yes for each of the following two options in the Email plugin: Remove HTML?, Convert HTML-paragraphs to newlines?.
Thanks for any help
dex
Re: HTML Characters in Emails
Posted: Mon Feb 23, 2009 5:17 pm
by garvinhicking
Hi!
Are you using the WYSIWYG editor? In this case, this one is inserting the spacing, because in HTML there is no double space without this.
You could use the content-replace plugin to replace " " with only " ", maybe?
Regards,
Garvin
Re: HTML Characters in Emails
Posted: Mon Feb 23, 2009 5:33 pm
by dex
Indeed, I am using the FCKeditor as it allows for selectable templates which helps my users. I have also tried the content-replace plugin with no luck, but using the FCKeditor I haven't been able to get the content-replace plugin to replace anything.
Thanks
Re: HTML Characters in Emails
Posted: Mon Feb 23, 2009 6:43 pm
by garvinhicking
Hi!
What did you try to enter in the content-replace plugin, and how did you configure it? Basically, this should work...
Regards,
Garvin
Re: HTML Characters in Emails
Posted: Mon Feb 23, 2009 7:05 pm
by dex
Thanks Garvin. Here is my config modelled after the example in the "Using Plugins" section of the documentation. I apologize if I've mis-interpreted the fields. Let me know if you see anything incorrect.
Code: Select all
Plugin-Title: DoubleSpaceReplacement
Rewrite string: "{to}"
Rewrite char: ""
Title #0: " "
Description #0: " "
Entry Body: Yes
Extended Body: Yes
Comment: Yes
HTML Nugget: Yes
Thanks
dex
Re: HTML Characters in Emails
Posted: Mon Feb 23, 2009 9:04 pm
by garvinhicking
Hi!
Grmbl, I see. The plugin has trouble replacing special characters like spaces, because the regular expressions assume that the replaced word must be within spaces.
Hrm. The other way to do that replacement would be with a very simple custom event plugin.
Save this code as /plugins/serendipity_event_nonbsp/serendipity_event_nonbsp.php and then install the plugin:
Code: Select all
<?php
class serendipity_event_nonbsp extends serendipity_event {
var $title = 'No double space';
function introspect(&$propbag) {
global $serendipity;
$this->title = $this->get_config('title', $this->title);
$propbag->add('name', $this->title);
$propbag->add('event_hooks', array(
'frontend_display' => true
));
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (!isset($hooks[$event])) {
return null;
}
switch($event) {
case 'frontend_display':
if (isset($eventData['body'])) {
$eventData['body'] = str_replace(' ', ' ', $eventData['body']);
}
if (isset($eventData['extended'])) {
$eventData['extended'] = str_replace(' ', ' ', $eventData['extended']);
}
return true;
break;
}
}
}
HTH,
Garvin
Re: HTML Characters in Emails
Posted: Mon Feb 23, 2009 9:34 pm
by dex
Thanks Garvin. That did the trick.
dex