Hi all,
I've added some minor unit tests for checkboxes in ox-html. I was playing around with something I thought was a bug, which turned out to be my project config. Thought I'd share the unit tests anyway, maybe this can help someone down the line create more patches.
From f9a343cc23bd5e99346797dd5e1cf4d1c661a605 Mon Sep 17 00:00:00 2001 From: Hraban Luyat <hra...@0brg.net> Date: Wed, 9 Aug 2023 14:09:18 -0400 Subject: [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode --- testing/lisp/test-ox-html.el | 69 ++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/testing/lisp/test-ox-html.el b/testing/lisp/test-ox-html.el index e1b492733..76329951b 100644 --- a/testing/lisp/test-ox-html.el +++ b/testing/lisp/test-ox-html.el @@ -814,5 +814,74 @@ $x$" nil nil nil nil nil #'html-mode)))))))) + +;;; Rendering checkboxes + +(ert-deftest ox-html/checkbox-ascii () + "Test ascii checkbox rendering" + (should + (equal + `(ul ((class . "org-ul")) + (li ((class . "off")) + (code nil ,(format "[%c]" (char-from-name "NO-BREAK SPACE"))) " not yet") + (li ((class . "on")) + (code nil "[X]") " I am done") + (li ((class . "trans")) + (code nil "[-]") " unclear")) + (org-test-with-temp-text " +- [ ] not yet +- [X] I am done +- [-] unclear +" + (let ((export-buffer "*Test HTML Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'html export-buffer + nil nil nil t nil) + (with-current-buffer export-buffer + (libxml-parse-xml-region))))))) + +(ert-deftest ox-html/checkbox-html () + "Test HTML checkbox rendering" + (should + (equal + '(ul ((class . "org-ul")) + (li ((class . "off")) + (input ((type . "checkbox"))) " not yet") + (li ((class . "on")) + (input ((type . "checkbox") (checked . "checked"))) " I am done") + (li ((class . "trans")) + (input ((type . "checkbox"))) " unclear")) + (org-test-with-temp-text " +- [ ] not yet +- [X] I am done +- [-] unclear +" + (let ((export-buffer "*Test HTML Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'html export-buffer + nil nil nil t '(:html-checkbox-type html)) + (with-current-buffer export-buffer + (libxml-parse-xml-region))))))) + +(ert-deftest ox-html/checkbox-unicode () + "Test HTML checkbox rendering" + (should + (equal + '(ul ((class . "org-ul")) + (li ((class . "off")) "☐ not yet") + (li ((class . "on")) "☑ I am done") + (li ((class . "trans")) "☐ unclear")) + (org-test-with-temp-text " +- [ ] not yet +- [X] I am done +- [-] unclear +" + (let ((export-buffer "*Test HTML Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'html export-buffer + nil nil nil t '(:html-checkbox-type unicode)) + (with-current-buffer export-buffer + (libxml-parse-xml-region))))))) + (provide 'test-ox-html) ;;; test-ox-html.el ends here -- 2.41.0