emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/org-mime b47811562b 099/118: Merge pull request #52 from t


From: ELPA Syncer
Subject: [nongnu] elpa/org-mime b47811562b 099/118: Merge pull request #52 from tomheon/fix-gmail-quoting
Date: Wed, 5 Jan 2022 07:58:50 -0500 (EST)

branch: elpa/org-mime
commit b47811562ba5c0882e9bacf9124b18fb5d0f4a61
Merge: 73fdd3f40d d71f57dc0d
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #52 from tomheon/fix-gmail-quoting
    
    Show individual paragraphs in gmail reply quotes
---
 org-mime.el            | 14 +++++++++++---
 test/org-mime-tests.el | 31 +++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/org-mime.el b/org-mime.el
index 45c3404a02..02273877b7 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 "&gt;[ \t]*")
+          (setq in-quote-p t)
           (replace-match "")
           (cl-incf line-depth))
         (cond
@@ -317,7 +320,12 @@ 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 /></div>\n<div>"))
+          (forward-line)))
       (buffer-substring (point-min) (point-max)))))
 
 (defun org-mime-multipart (plain html &optional images)
diff --git a/test/org-mime-tests.el b/test/org-mime-tests.el
index f4e19c0c8f..25f366267a 100644
--- a/test/org-mime-tests.el
+++ b/test/org-mime-tests.el
@@ -245,4 +245,35 @@
       (should-not (string-match "SECTION_ONE" str)))
     (kill-buffer orgBuf)))
 
+(ert-deftest test-org-mime-beautify-quoted-para-breaks ()
+    (setq html (concat "<p>\n"
+                       "Hello there\n"
+                       "</p>\n"
+                       "\n"
+                       "<p>\n"
+                       "&gt; this is a long-ish para that is broken\n"
+                       "&gt; on two lines\n"
+                       "&gt;\n"
+                       "&gt; followed by a single-line para\n"
+                       "</p>\n"))
+    (setq expected (concat "<p>\n"
+                           "Hello there\n"
+                           "</p>\n"
+                           "\n"
+                           "<p>\n"
+                           "<blockquote class=\"gmail_quote\" style=\"margin:0 
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex\">\n"
+                           "\n"
+                           "<div>this is a long-ish para that is broken\n"
+                           "on two lines\n"
+                           "</div>\n"
+                           "<div>\n"
+                           "<br /></div>\n"
+                           "<div>followed by a single-line para\n"
+                           "\n"
+                           "</div></blockquote>\n"
+                           "</p>\n"))
+    (setq beautified (org-mime-beautify-quoted html))
+    (should (equal beautified expected))
+)
+
 (ert-run-tests-batch-and-exit)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]