emacs-orgmode@gnu.org archives
 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

* Re: [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2023-08-10  9:36 UTC (permalink / raw)
  To: Hraban Luyat; +Cc: emacs-orgmode

Hraban Luyat <hraban@0brg.net> writes:

> 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.

Thanks!
Applied, onto main, with minor amendments.
I have updated the commit message to follow our standards and added
skip-unless checks to make sure that the tests will only run when Emacs
has libxml support.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=003927a59

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode
  2023-08-10  9:36 ` Ihor Radchenko
@ 2023-08-10 17:32   ` Hraban Luyat
  0 siblings, 0 replies; 3+ messages in thread
From: Hraban Luyat @ 2023-08-10 17:32 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Thank you for the sensible amendments

On 8/10/23 5:36 AM, Ihor Radchenko wrote:
> Hraban Luyat <hraban@0brg.net> writes:
>
>> 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.
> Thanks!
> Applied, onto main, with minor amendments.
> I have updated the commit message to follow our standards and added
> skip-unless checks to make sure that the tests will only run when Emacs
> has libxml support.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=003927a59
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>



^ permalink raw reply	[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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).