emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch][ox-html] Support for level based containers
@ 2014-03-15 23:18 Rasmus
  2014-03-16 13:10 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Rasmus @ 2014-03-15 23:18 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]

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!

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-for-level-based-containers-in-ox-html.patch --]
[-- Type: text/x-diff, Size: 2231 bytes --]

From b24e403030ea76febc3fecb0ba9db56b3c39d5aa Mon Sep 17 00:00:00 2001
From: Rasmus <w530@pank.eu>
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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-03-19 14:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-15 23:18 [patch][ox-html] Support for level based containers Rasmus
2014-03-16 13:10 ` Nicolas Goaziou
2014-03-17  0:30   ` Rasmus
2014-03-17  2:15   ` Bastien
2014-03-17 17:31     ` Rick Frankel
2014-03-17 22:26       ` Rasmus
2014-03-18  0:33         ` Rick Frankel
2014-03-18  3:31           ` Rasmus
2014-03-18 15:05             ` Rick Frankel
2014-03-18 19:41               ` Rasmus
2014-03-19 14:24                 ` Rick Frankel

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).