>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