Re: [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode

2023-08-10 Thread Hraban Luyat
Thank you for the sensible amendments

On 8/10/23 5:36 AM, Ihor Radchenko wrote:
> Hraban Luyat  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 .
> Support Org development at ,
> or support my work at 




Re: [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode

2023-08-10 Thread Ihor Radchenko
Hraban Luyat  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 .
Support Org development at ,
or support my work at 



[PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode

2023-08-09 Thread Hraban Luyat
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 
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