Hey Everyone,
You have all been so incredibly helpful in this group both for learning the simplest of things and the tougher stuff. I have appreciated that you've dealt with both. I have done web searching and asked on IRC about the following question without getting much of a response, so I am going to ask it here because this site seems to do everything right when it comes to drupal. I am just looking for a helping hand.
I notice in the emails sent out from this group the paragraph tags break properly in the emails and do not show up as html. On my sites (4.7.6), this is not the case. I've found it to be perplexing, as sometimes it seems to work, and other times it doesn't. However, every post I receive from this group the breaks are in the proper spot. So how exactly do I ensure that? By not using a WYSIWYG editor at all? Is this a setting somewhere? A hack? An add-on module? Does anyone have the secret? People have told me it's my email client, but then why do the emails from this group always show up properly? I have read and received so many conflicting forms of information, that I was hoping to put an end to it once and for all here.
I know this group is part of groups.drupal.org and you may not be in charge of this website, but you seem to know everything else. And I thought maybe we could hash this out here and that way it becomes its own little learning repository.
Thank you,
Emily
Comments
editing and OG
First, I'm not fond of using WYSWYG editors- and obviously they are not installed here.
Some modules (including Organic Groups and Project) do some conversion of HTML- like <p> tags to line breaks (see below). Of course, this may be a feature of the more recent (4.7.x or 5.x) modules. Are you sending these e-mails via OG, or some other module?
<?php
// takes filtered HTML as input and transforms for email
// modified from project.module
function og_mail_output($body, $html = TRUE) {
static $i = 0;
if ($html) {
$pattern = '@(<a href="(.+?)">(.+?)</a>)@ei';
$body = preg_replace($pattern, "'\3 ['. og_mail_urls('\2') .']'", $body);
$urls = og_mail_urls();
if (count($urls)) {
$body .= "\n";
for ($max = count($urls); $i < $max; $i++) {
$body .= '['. ($i + 1) .'] '. $urls[$i] ."\n";
}
}
$body = preg_replace('!</?blockquote>!i', '"', $body);
$body = preg_replace('!</?(em|i)>!i', '/', $body);
$body = preg_replace('!</?(b|strong)>!i', '<em>', $body);
$body = preg_replace("@<br />(?!\n)@i", "\n", $body);
$body = preg_replace("@</p.</em>>(?!\n\n)@i", "\n\n", $body);
$body = preg_replace("@</h1>(?!\n\n)@i", " #\n", $body);
$body = preg_replace("@</h2>(?!\n\n)@i", " ##\n", $body);
$body = preg_replace("@</h3>(?!\n\n)@i", " ###\n", $body);
$body = preg_replace("@</h4>(?!\n\n)@i", " ####\n", $body);
$body = preg_replace("@</(li|dd)>\n?@i", "\n", $body);
$body = preg_replace("@<h1.<em>>@i", "\n\n# ", $body);
$body = preg_replace("@<h2.</em>>@i", "\n\n## ", $body);
$body = preg_replace("@<h3.<em>>@i", "\n\n### ", $body);
$body = preg_replace("@<h4.</em>>@i", "\n\n#### ", $body);
$body = preg_replace("@<li.<em>>@i", "</em> ", $body);
$body = strip_tags($body);
$body = decode_entities($body);
$body = wordwrap($body, 72);
}
else {
$body = decode_entities($body);
}
return $body;
}
?>
Hm. Yeah, I am sending via
Hm. Yeah, I am sending via OG. So according to the module code, it should be all set on converting the tags. I am also using most recent 4.7.x version of OG. However, I did hack the module a little while ago in order to not send out just the teaser and to send out the entire body instead. But this hack only involved substituting the $teaser variable for the $body variable on line 1666. I didn't think that would at all change the $body variable that gets parsed through the function you've shown above, but perhaps I have incorrectly hacked and need to do more than just substitute that single variable. Thanks for the heads-up on this. I shall continue hacking and messing around, and if nothing works I shall start over!