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

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

[nongnu] elpa/org-mime 778f818ad3 078/118: Add ASCII text/plain export t


From: ELPA Syncer
Subject: [nongnu] elpa/org-mime 778f818ad3 078/118: Add ASCII text/plain export test
Date: Wed, 5 Jan 2022 07:58:48 -0500 (EST)

branch: elpa/org-mime
commit 778f818ad3d101f27786556c2a7a9995d5da47c6
Author: konezny <konezny@users.noreply.github.com>
Commit: konezny <konezny@users.noreply.github.com>

    Add ASCII text/plain export test
    
    The ASCII export test checks for org-mode markup for the default case,
    where the export variable is nil or not valid, and checks for absent
    org-mode markup for the three valid plain text exports. The ASCII export
    test does not attempt to verify the exported coding type.
---
 org-mime.el            | 18 +++++++++---------
 test/org-mime-tests.el | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/org-mime.el b/org-mime.el
index c6dc1de437..9c21ddffd4 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -204,14 +204,14 @@ buffer holding the text to be exported.")
   "Similar to `org-html-export-as-html' and `org-org-export-as-org'.
 SUBTREEP is t if current node is subtree."
   (let* (
-         (plain
-          (cl-case org-mime-export-ascii
-            (ascii (org-export-string-as (buffer-string) 'ascii nil 
'(:ascii-charset ascii)))
-            (latin1 (org-export-string-as (buffer-string) 'ascii nil 
'(:ascii-charset latin1)))
-            (utf-8 (org-export-string-as (buffer-string) 'ascii nil 
'(:ascii-charset utf-8)))
-            (t (buffer-string)) ;; default is the original org file
-           )
-          )
+         (plain (cl-case org-mime-export-ascii
+                  (ascii (org-export-string-as (buffer-string)
+                           'ascii nil '(:ascii-charset ascii)))
+                  (latin1 (org-export-string-as (buffer-string)
+                            'ascii nil '(:ascii-charset latin1)))
+                  (utf-8 (org-export-string-as (buffer-string)
+                           'ascii nil '(:ascii-charset utf-8)))
+                  (t (buffer-string)))) ;; original org file
          (buf (org-export-to-buffer 'html "*Org Mime Export*"
                 nil subtreep nil (org-mime-get-export-options subtreep)))
          (body (prog1
@@ -307,7 +307,7 @@ If html portion of message includes IMAGES they are wrapped 
in multipart/related
     (mml (concat "<#multipart type=alternative>\n<#part type=text/plain>\n"
                  plain
                  (when images "<#multipart type=related>")
-                 "<#part type=text/html>"
+                 "<#part type=text/html>\n"
                  (if org-mime-beautify-quoted-mail
                      (org-mime-beautify-quoted html)
                    html)
diff --git a/test/org-mime-tests.el b/test/org-mime-tests.el
index dea0846277..9bac50c04e 100644
--- a/test/org-mime-tests.el
+++ b/test/org-mime-tests.el
@@ -114,4 +114,43 @@
    (should (string= (car h) "Cc"))
    (should (string= (cdr h) cc))))
 
-(ert-run-tests-batch-and-exit)
\ No newline at end of file
+;;; The ASCII export test checks for org-mode markup for the default case, 
where
+;;; the export variable is nil or not valid, and checks for absent org-mode
+;;; markup for the three valid plain text exports. The ASCII export test does
+;;; not attempt to verify the exported coding type.
+
+(ert-deftest test-org-mime-org-buffer-htmlize-ascii-plain-text ()
+  (let* (str opts)
+    (setq orgBuf (generate-new-buffer "*org-mode-test-buf*"))
+    (with-current-buffer orgBuf
+      (insert "#+OPTIONS: toc:nil num:nil\n"
+              "\n#+begin_example\n"
+              "$ echo nothing to see here\n"
+              "#+end_example\n")
+      (org-mode)
+      (goto-char (point-min))
+      (setq opts (org-mime-get-export-options t))
+      (should opts)
+      ;; default: org-mode file
+      (mapcar (lambda (backend)
+                (setq org-mime-export-ascii backend)
+                (switch-to-buffer orgBuf)
+                (org-mime-org-buffer-htmlize)
+                (switch-to-buffer (car (message-buffers)))
+                (setq str (buffer-string))
+                (should (string-match "<#multipart" str))
+                (should (string-match "#\\+begin_example" str)))
+                '(nil bogus))
+      ;; 'ascii, 'latin1, and 'utf-8 exports
+      (mapcar (lambda (backend)
+                (setq org-mime-export-ascii backend)
+                (switch-to-buffer orgBuf)
+                (org-mime-org-buffer-htmlize)
+                (switch-to-buffer (car (message-buffers)))
+                (setq str (buffer-string))
+                (should (string-match "<#multipart" str))
+                (should-not (string-match "#\\+begin_example" str)))
+                '(ascii latin1 utf-8)))
+    (kill-buffer orgBuf)))
+
+(ert-run-tests-batch-and-exit)



reply via email to

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