emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rick Frankel <rick@rickster.com>
To: Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org, Nicolas Goaziou <n.goaziou@gmail.com>,
	Rasmus <rasmus@gmx.us>
Subject: Re: [patch][ox-html] Support for level based containers
Date: Mon, 17 Mar 2014 13:31:58 -0400	[thread overview]
Message-ID: <20140317173158.GB75979@eyeBook> (raw)
In-Reply-To: <87iordk1t5.fsf@bzg.ath.cx>

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

On Mon, Mar 17, 2014 at 03:15:50AM +0100, Bastien wrote:
> Hi Rasmus and Nicolas,
>
> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
> >> Let me know if you find you'd be willing to merge something like this
> >
> > I don't know enough HTML to have an opinion here.
>

I don't think it's a bad change, but i have a couple of concerns:

    1. It's a breaking change.
    2. The default should mimic the current functionality:
       ='((div . div))=
    3. The customization should be more structured, not just a
       string (see e.g., =org-html-text-markup-alist=.)

Attached is a modification of the patch which fixes 2 & 3. #1 is a
question more for Nicolas & Bastien...

rick

[-- Attachment #2: 0001-Support-for-heading-level-based-containers-in-ox-htm.patch --]
[-- Type: text/plain, Size: 2299 bytes --]

From 21aed5d34613f9f922c2d1c8f5f67caac918c9cf Mon Sep 17 00:00:00 2001
From: Rick Frankel <github@rickster.com>
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)


  reply	other threads:[~2014-03-17 17:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140317173158.GB75979@eyeBook \
    --to=rick@rickster.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    --cc=rasmus@gmx.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).