From 21aed5d34613f9f922c2d1c8f5f67caac918c9cf Mon Sep 17 00:00:00 2001 From: Rick Frankel Date: Mon, 17 Mar 2014 13:27:12 -0400 Subject: [PATCH] Support for heading level based containers in ox-html. * ox-html.el (org-html-container-element): Change to list of cons cells for heading level containers. (org-html--container): Use heading level entries from org-html-container-element. --- lisp/ox-html.el | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index cb95161..b51a746 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -938,17 +938,23 @@ versions 8 and below." :package-version '(Org . "8.0") :type 'boolean) -(defcustom org-html-container-element "div" - "HTML element to use for wrapping top level sections. +(defcustom org-html-container-element '(("div" . "div")) + + "HTML elements to use for wrapping sections. Can be set with the in-buffer HTML_CONTAINER property or for publishing, with :html-container. -Note that changing the default will prevent you from using -org-info.js for your website." +Should be a list of cons cells with positions corresponding to +heading levels. If `org-html-html5-fancy' is t the cdr is used +otherwise the car. + +Note that changing the default will prevent you from +using org-info.js for your website." :group 'org-export-html :version "24.4" :package-version '(Org . "8.0") - :type 'string) + :type '(alist :key-type (string :tag "HTML4") + :value-type (string :tag "HTML5"))) (defcustom org-html-divs '((preamble "div" "preamble") @@ -2410,9 +2416,14 @@ holding contextual information." (defun org-html--container (headline info) (or (org-element-property :HTML_CONTAINER headline) - (if (= 1 (org-export-get-relative-level headline info)) - (plist-get info :html-container) - "div"))) + (let* ((hc (plist-get info :html-container)) + (n (org-export-get-relative-level headline info))) + (cond ((listp hc) + (or (funcall (if org-html-html5-fancy 'cdr-safe 'car-safe) + (nth (1- (min n (length hc))) hc)) "div")) + ((and (stringp hc) (= 1 n)) + (plist-get info :html-container)) + (t "div"))))) ;;;; Horizontal Rule -- 1.8.5.2 (Apple Git-48)