瀏覽代碼

Add customization options for html checkboxes.

(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.  Defaults to "ascii"
(org-html-checkbox): Use the appropriate set of checkboxes as
specified in `org-html-checkbox-type'.
Rick Frankel 11 年之前
父節點
當前提交
2c782da801
共有 1 個文件被更改,包括 42 次插入7 次删除
  1. 42 7
      lisp/ox-html.el

+ 42 - 7
lisp/ox-html.el

@@ -975,6 +975,39 @@ 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 . "<code>[X]</code>")
+      (off . "<code>[&#xa0;]</code>")
+      (trans . "<code>[-]</code>")))
+    (html .
+	  ((on . "<input type='checkbox' checked='checked' />")
+	  (off . "<input type='checkbox' />")
+	  (trans . "<input type='checkbox' />"))))
+  "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
+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 values used for each option."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+	  (const :tag "ASCII characters" "ascii")
+	  (const :tag "Unicode characters" "unicode")
+	  (const :tag "HTML checkboxes" "html")))
+
 (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."
@@ -2417,18 +2450,20 @@ contextual information."
 
 ;;;; Item
 
-(defun org-html-checkbox (checkbox)
-  "Format CHECKBOX into HTML."
-  (case checkbox (on "<code>[X]</code>")
-	(off "<code>[&#xa0;]</code>")
-	(trans "<code>[-]</code>")
-	(t "")))
+(defun org-html-checkbox (checkbox info)
+  "Format CHECKBOX into HTML.  INFO is a plist holding contextual
+information.
+See `org-html-checkbox-type' for customization options."
+  (cdr (assoc checkbox
+	      (cdr (assoc (intern org-html-checkbox-type)
+			  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