branch: elpa/org-mime
commit dc7ae1de8564399fb706b18e7c8cacf044fcccb5
Author: Edmund Jorgensen <[email protected]>
Commit: Edmund Jorgensen <[email protected]>
Show individual paragraphs in gmail reply quotes
Prior to this patch, replies using the org-mime-beautify-quoted-mail option
would show up with multiple paragraphs in the reply squashed onto a single
line (at least in gmail).
For example, the reply:
```
> This is one para (which is
> split across two lines)
>
> This is another
```
Would get rendered as:
```
<p>
This is one para (which is
split across two lines)
This is another
</p>
```
And displayed in gmail as:
```
| This is one para (which is split across two lines) This is another
```
(Where '|' is the beautifed vertical line in gmail.)
Looking at how gmail itself deals with multiple paras in a reply, it appears
they:
1. put each paragraph in its own div
2. represent blank lines between divs as <br />
They do some funky nesting that doesn't seem to be needed to make the quotes
display correctly, so I've left it out.
This patch would render the example above into the structure:
```
<div>This is one para (which is
split across two lines)</div>
<div><br/></div>
<div>This is another</div>
```
(With some less beautiful line breaks) and displayed in gmail as:
```
| This is one para (which is split across two lines)
|
| This is another
```
To better represent the gmail de-factor standard, this patch also changes
the
top-level element in the gmail blockquote to div (from p).
---
org-mime.el | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/org-mime.el b/org-mime.el
index 45c3404a02..67ee5bbfc7 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -294,8 +294,9 @@ OPTS is export options."
HTML is the body of the message."
(let ((quote-depth 0)
(line-depth 0)
- (quote-opening "<blockquote class=\"gmail_quote\" style=\"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex\">\n<p>\n")
- (quote-closing "</p>\n</blockquote>\n"))
+ (in-quote-p nil)
+ (quote-opening "<blockquote class=\"gmail_quote\" style=\"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex\">\n\n<div>")
+ (quote-closing "\n</div></blockquote>\n"))
(with-temp-buffer
;; clean title of quoted
(insert (replace-regexp-in-string
@@ -305,7 +306,9 @@ HTML is the body of the message."
(goto-char (point-min))
(while (not (eobp))
(setq line-depth 0)
+ (setq in-quote-p nil)
(while (looking-at ">[ \t]*")
+ (setq in-quote-p t)
(replace-match "")
(cl-incf line-depth))
(cond
@@ -317,7 +320,13 @@ HTML is the body of the message."
(while (> quote-depth line-depth)
(insert quote-closing)
(cl-decf quote-depth))))
- (forward-line))
+ (if (and in-quote-p (looking-at "^[ \t]*$"))
+ (progn
+ (insert "</div>\n<div>")
+ (forward-line)
+ (insert "<br />")
+ (insert "</div>\n<div>"))
+ (forward-line)))
(buffer-substring (point-min) (point-max)))))
(defun org-mime-multipart (plain html &optional images)