(require 'package)
(package-initialize)
(load-file "ox-plumhtml.el")
(defun should-render-as (expected-result org-source &optional info skip-newline)
(let ((expected-result (if skip-newline expected-result (concat expected-result "\n")))
(info (plist-put info :html-container nil)))
(should (string= expected-result
(org-export-string-as org-source 'plumhtml t info)))))
(defun regexp-render-as (expected-regexp org-source &optional info)
(let ((info (plist-put info :html-container nil)))
(should (string-match-p expected-regexp
(org-export-string-as org-source 'plumhtml t info)))))
;; Tables
(ert-deftest body ()
(should-render-as
"
"
"|body|"))
(ert-deftest multi-line-body ()
(should-render-as
""
"|two|\n|lines|"))
(ert-deftest header-no-body ()
(should-render-as
""
"|just a header|\n|---|"))
(ert-deftest header-and-body ()
(should-render-as
""
"|header|\n|---|\n|body|"))
(ert-deftest header-and-multi-line-body ()
(should-render-as
"header |
\nline 1 |
\nline 2 |
\nline 3 |
\n
"
"|header|\n|---|\n|line 1|\n|line 2|\n|line 3|"))
(ert-deftest header-and-multiple-bodies ()
(should-render-as
""
"|header|\n|---|\n|two|\n|---|\n|bodies|"))
(ert-deftest header-and-body ()
(should-render-as
"multi-line |
\nheader |
\nbody |
\n
"
"|multi-line|\n|header|\n|---|\n|body|"))
;; Headers and IDs
(ert-deftest header ()
(should-render-as
"mwee
"
"* mwee"))
(ert-deftest header-export-ids ()
(regexp-render-as
"mwee
"
"* mwee" '(:export-header-ids t)))
(ert-deftest link-without-content ()
(should-render-as
"https://flanchan.moe
"
"[[https://flanchan.moe]]"))
;; Links and IDs
(ert-deftest link ()
(should-render-as
"example
"
"[[https://example.com][example]]"))