From: Hraban Luyat <hraban@0brg.net>
To: emacs-orgmode@gnu.org
Subject: [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode
Date: Wed, 09 Aug 2023 20:50:04 +0000 [thread overview]
Message-ID: <1c14c0ea-e363-4f88-b9cf-5d9e2c68ba7d@0brg.net> (raw)
[-- 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
next reply other threads:[~2023-08-09 20:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 20:50 Hraban Luyat [this message]
2023-08-10 9:36 ` [PATCH 1/2] test-ox-html: checkboxes: ascii, html & unicode Ihor Radchenko
2023-08-10 17:32 ` Hraban Luyat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c14c0ea-e363-4f88-b9cf-5d9e2c68ba7d@0brg.net \
--to=hraban@0brg.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).