From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Frankel Subject: html checkbox output Date: Fri, 6 Dec 2013 16:53:21 -0500 Message-ID: <20131206215321.GA48654@eyeBook> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vp3Kz-0001wT-Q9 for emacs-orgmode@gnu.org; Fri, 06 Dec 2013 16:53:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vp3Ks-0003DI-PO for emacs-orgmode@gnu.org; Fri, 06 Dec 2013 16:53:29 -0500 Received: from mail.rickster.com ([204.62.15.78]:60333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vp3Ks-0003C6-LA for emacs-orgmode@gnu.org; Fri, 06 Dec 2013 16:53:22 -0500 Received: from eyeBook.localhost (pool-173-56-80-180.nycmny.fios.verizon.net [173.56.80.180]) by mail.rickster.com (Postfix) with ESMTPS id C3CA222664 for ; Fri, 6 Dec 2013 16:53:22 -0500 (EST) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline So, here's a patch I would like a couple of people to try before i commit it. It provides customization of checkbox formatting for html output (unicode, ascii, checkbox input fields or custom). I couldn't figure out how to add an association list customization with preset options to a customization choice, so the custom option is a partilally pre-filled sexp. The default is still ascii, partially so that the checkbox tests don't fail w/o being changed. Let me know if this works for every of if it is too complex a solution befor I apply it to master. tia rick --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Add-customization-options-for-html-checkboxes.patch" >From 41da34c352f9c3899ece8294c3f618b665f12281 Mon Sep 17 00:00:00 2001 From: Rick Frankel Date: Tue, 3 Dec 2013 14:37:30 -0500 Subject: [PATCH] Add customization options for html checkboxes. * lisp/ox-html.el (html): Add in-buffer option HTML_CHECKBOX_TYP (org-html-checkbox-types): New constant. Contains unicode, ascii and html checkbox alists. (org_html_checkbox_type): New customzation variable can be set to one of the above choices or a user-entered alist. (org_html_checkbox): Use of `:html-checkbox-type' export option. --- lisp/ox-html.el | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 9fa0a8c..8d0e3e3 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -126,6 +126,7 @@ (:html-head-include-scripts nil "html-scripts" org-html-head-include-scripts) (:html-table-attributes nil nil org-html-table-default-attributes) (:html-table-row-tags nil nil org-html-table-row-tags) + (:html-checkbox-type "HTML_CHECKBOX_TYPE" nil org-html-checkbox-type) (:html-xml-declaration nil nil org-html-xml-declaration) (:html-inline-images nil nil org-html-inline-images) (:infojs-opt "INFOJS_OPT" nil nil) @@ -973,6 +974,42 @@ org-info.js for your website." (list :tag "Postamble" (const :format "" postamble) (string :tag " id") (string :tag "element")))) +(defconst org-html-checkbox-types + '((unicode . + ((on . "☑") (off . "☐") (trans . "☐"))) + (ascii . + ((on . "[X]") + (off . "[ ]") + (trans . "[-]"))) + (html . + ((on . "") + (off . "") + (trans . "")))) + "Alist of checkbox types. +The cdr of each entry is an alist list three checkbox types for +html export: \"on\", \"off\" and \"trans\". + +The choices are: + - unicode characters (html entities) + - ascii characters + - html checkboxes + - a user defined alist +Note that only the ascii characters implement tri-state +checkboxes. The other two use the \"off\" checkbox for \"trans\".") + +(defcustom org-html-checkbox-type "ascii" + "The type of checkboxes to use for html export. See +`org-html-checkbox-types' for for the preset values." + :group 'org-export-html + :version "24.4" + :package-version '(Org . "8.0") + :type '(choice + (const :tag "Unicode characters" "unicode") + (const :tag "Ascii characters" "ascii") + (const :tag "HTML checkboxes" "html") + (sexp :tag "Custom alist" + ((on . "") (off . "") (trans . ""))))) + (defcustom org-html-metadata-timestamp-format "%Y-%m-%d %a %H:%M" "Format used for timestamps in preamble, postamble and metadata. See `format-time-string' for more information on its components." @@ -2415,18 +2452,29 @@ contextual information." ;;;; Item -(defun org-html-checkbox (checkbox) - "Format CHECKBOX into HTML." - (case checkbox (on "[X]") - (off "[ ]") - (trans "[-]") - (t ""))) +(defun org-html-checkbox (checkbox info) + "Format CHECKBOX into HTML. This can be overriden on a +per-buffer basis with the \"HTML_CHECKBOX_TYPE\" property, +which can be either the name of one of the entries in the +`org-html-checkbox-types' variable or an alist of the form: + ((on . \"\") (off . \"\") (trans . \"\"). +See `org-html-checkbox-type' for customization." + (let ((checkboxes (plist-get info :html-checkbox-type))) + (cdr + (assoc checkbox + (if (listp checkboxes) checkboxes + (if (string-equal (substring checkboxes 0 1) "(") + (read checkboxes) + (cdr (assoc + (intern checkboxes) + org-html-checkbox-types)))))))) (defun org-html-format-list-item (contents type checkbox info &optional term-counter-id headline) "Format a list item into HTML." - (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " "))) + (let ((checkbox (concat (org-html-checkbox checkbox info) + (and checkbox " "))) (br (org-html-close-tag "br" nil info))) (concat (case type -- 1.8.0 --envbJBWh7q8WU6mo--