all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode
@ 2023-08-09 20:50 Hraban Luyat
  2023-08-10  9:36 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Hraban Luyat @ 2023-08-09 20:50 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

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.

[-- Attachment #2: 0001-test-ox-html-checkboxes-ascii-html-unicode.patch --]
[-- Type: text/plain, Size: 2931 bytes --]

From f9a343cc23bd5e99346797dd5e1cf4d1c661a605 Mon Sep 17 00:00:00 2001
From: Hraban Luyat <hraban@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))))))))
 
+\f
+;;; 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-10 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 20:50 [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode Hraban Luyat
2023-08-10  9:36 ` Ihor Radchenko
2023-08-10 17:32   ` Hraban Luyat

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.