branch: elpa/org-mime
commit c6a3d73e78b11157ceb49bf5d79c6fd125efe0ac
Author: Chen Bin <[email protected]>
Commit: Chen Bin <[email protected]>
remove org-mime-default-header
---
org-mime.el | 25 +++++++++++--------------
test/org-mime-tests.el | 38 +++++++++++++++++++++++++-------------
2 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/org-mime.el b/org-mime.el
index bac7e415fb..d36a4a4f0f 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -129,13 +129,6 @@
:group 'org-mime
:type 'boolean)
-(defcustom org-mime-default-header
- "#+OPTIONS: latex:t toc:nil H:3\n"
- "Default header to control html export options.
-And ensure first line isn't assumed to be a title line."
- :group 'org-mime
- :type 'string)
-
(defcustom org-mime-library 'mml
"Library to use for marking up MIME elements."
:group 'org-mime
@@ -249,16 +242,20 @@ SUBTREEP is t if current node is subtree."
(kill-buffer buf))))
(cons body plain)))
-(defun org-mime-export-string (string &optional opts)
- "Export STRING into html.
-OPTS is export options."
+(defun org-mime-export-string (string &optional options)
+ "Export STRING into html with OPTIONS."
;; Emacs 25+ prefer exporting drawer by default
;; obviously not acceptable in exporting to mail body
(let* ((org-export-with-drawers nil))
+
+ (when org-mime-export-options
+ (setq options org-mime-export-options))
+
;; we won't export title from org file anyway
- (if opts (setq opts (plist-put opts 'title nil)))
+ (if options (setq options (plist-put options 'title nil)))
+
;; emacs24.4+
- (org-export-string-as string 'html t (or org-mime-export-options opts))))
+ (org-export-string-as string 'html t options)))
;; example hook, for setting a dark background in
;; <pre style="background-color: #EEE;"> elements
@@ -490,8 +487,8 @@ If called with an active region only export that region,
otherwise entire body."
;; to hold attachments for inline html images
(opts (org-mime-get-buffer-export-options))
(ascii-charset (org-mime-use-ascii-charset))
- (plain (org-mime-export-ascii-maybe (concat org-mime-default-header
org-text) org-text))
- (html (org-mime-export-string (concat org-mime-default-header
org-text) opts))
+ (plain (org-mime-export-ascii-maybe org-text org-text))
+ (html (org-mime-export-string org-text opts))
(file (make-temp-name (expand-file-name
"mail" temporary-file-directory))))
diff --git a/test/org-mime-tests.el b/test/org-mime-tests.el
index 25f366267a..fb790bf469 100644
--- a/test/org-mime-tests.el
+++ b/test/org-mime-tests.el
@@ -35,22 +35,34 @@
"--\n"
"Some quote\n"))
+(defun run-org-mime-htmlize (&rest mail-body)
+ "Create mail containing MAIL-BODY and run `org-mime-htmlize'."
+ (with-temp-buffer
+ (apply #'insert mail-header)
+ (apply #'insert mail-body)
+ (apply #'insert mail-footer)
+ (message-mode)
+ (goto-char (point-min))
+ (org-mime-htmlize)
+ (buffer-string)))
+
(ert-deftest test-org-mime-htmlize ()
- (let* (str)
- (with-temp-buffer
- (apply #'insert mail-header)
- (insert "* hello\n"
- "** world\n"
- "#+begin_src javascript\n"
- "console.log('hello world');\n"
- "#+end_src\n")
- (apply #'insert mail-footer)
- (message-mode)
- (goto-char (point-min))
- (org-mime-htmlize)
- (setq str (buffer-string)))
+ (let* ((str (run-org-mime-htmlize "* hello\n"
+ "** world\n"
+ "#+begin_src javascript\n"
+ "console.log('hello world');\n"
+ "#+end_src\n")))
(should (string-match "<#multipart" str))))
+(ert-deftest test-org-mime-export-options ()
+ (let* (str)
+ (setq org-mime-export-options '(:with-toc t))
+ (setq str (run-org-mime-htmlize "* hello\n"))
+ (should (string-match "Table of Contents" str))
+ (setq org-mime-export-options '(:with-toc nil))
+ (setq str (run-org-mime-htmlize "* hello\n"))
+ (should (not (string-match "Table of Contents" str)))))
+
(ert-deftest test-org-mime-org-subtree-htmlize ()
(let* (str opts)
(with-temp-buffer