From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [patch][ox-html] Support for level based containers Date: Sun, 16 Mar 2014 00:18:09 +0100 Message-ID: <87ha6z3vbi.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOxqb-0004qr-Eq for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 19:18:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOxqV-0005yo-QF for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 19:18:33 -0400 Received: from plane.gmane.org ([80.91.229.3]:60015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOxqV-0005yg-J3 for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 19:18:27 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WOxqT-0001Ev-6k for emacs-orgmode@gnu.org; Sun, 16 Mar 2014 00:18:25 +0100 Received: from dynamic-adsl-94-39-222-239.clienti.tiscali.it ([94.39.222.239]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 16 Mar 2014 00:18:25 +0100 Received: from rasmus by dynamic-adsl-94-39-222-239.clienti.tiscali.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 16 Mar 2014 00:18:25 +0100 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 --=-=-= Content-Type: text/plain Hi, This patch allows different containers in ox-html.el depending on the level of the heading. For example, it is possible to get a container structure like this (level . container): * . section ** . article *** . div This is good for HTML5 at least, and I suspect also for ox-publish projects. I don't know if this additional semantics is useful for "HTML4". Let me know if you find you'd be willing to merge something like this and what changes are necessary, if any. Thanks, Rasmus -- When in doubt, do it! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Support-for-level-based-containers-in-ox-html.patch >From b24e403030ea76febc3fecb0ba9db56b3c39d5aa Mon Sep 17 00:00:00 2001 From: Rasmus Date: Sun, 16 Mar 2014 00:01:35 +0100 Subject: [PATCH] Support for level-based containers in ox-html * ox-html.el (org-html-container-element): List of cons of section-level containers. (org-html--container): Redefine to consider 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 a8c924f..f1a4cb1 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -940,17 +940,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" . "section") + ("div" . "article") + ("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 a +section. 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 '(repeat (cons string string))) (defcustom org-html-divs '((preamble "div" "preamble") @@ -2412,9 +2418,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.9.0 --=-=-=--