From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Frankel Subject: [New Exporter] Parameterized wrapper elements Date: Fri, 8 Mar 2013 19:17:10 -0500 Message-ID: <20130309001710.GB22813@BigDog.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="LyciRD1jyfeSSjG0" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:41422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UE7TW-0001mo-4f for emacs-orgmode@gnu.org; Fri, 08 Mar 2013 19:17:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UE7TP-0003xb-AO for emacs-orgmode@gnu.org; Fri, 08 Mar 2013 19:17:22 -0500 Received: from [204.62.15.78] (port=54448 helo=mail.rickster.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UE7TP-0003xV-5t for emacs-orgmode@gnu.org; Fri, 08 Mar 2013 19:17:15 -0500 Received: from BigDog.local (pool-72-89-40-63.nycmny.fios.verizon.net [72.89.40.63]) by mail.rickster.com (Postfix) with ESMTPS id 2430E20003 for ; Fri, 8 Mar 2013 19:17:12 -0500 (EST) Content-Disposition: inline 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 --LyciRD1jyfeSSjG0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline (cc'ing list) Nicolas- The patch Jambunathan sent didn't really make much sense to me, as it didn't provide any added functionality over simply subclassing (deriving) from the current html exporter. Anyway, attached is a patch which parameterizes the html exporter in a way which is useful (for me :) in deriving new backends. It also make the exporter more capable of generating HTML5 compatible output instead of just XHTML. If you agree with it, i would be happy to apply it (or you can :). rick --LyciRD1jyfeSSjG0 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Parameterize-some-html-content-containers.patch" >From 01640c5a9f0d4957a0289a9dfc0497f5b7d42bd9 Mon Sep 17 00:00:00 2001 From: Rick Frankel Date: Fri, 8 Mar 2013 19:00:21 -0500 Subject: [PATCH] Parameterize some html content containers * lisp/ox-html.el: (define-backend): Add :html-doctype and :html-container parameters. (org-html-doctype): New customization variable for doctype declaration. (org-html-container-elemnt): New customization variable for specifying wrapper container element. (org-html-div): Change to list of pairs id, element type to allow setting container element. (org-html--build-preamble): Modified to use new org-html-div settings. (org-html--build-postamble): Modified to use new org-html-div settings. (org-html-template): Modified to use doctype and container-element settings. --- lisp/ox-html.el | 76 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 829fe28..a971440 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -113,6 +113,8 @@ (org-open-file (org-html-export-to-html nil s v b))))))) :options-alist ((:html-extension nil nil org-html-extension) + (:html-doctype "HTML_DOCTYPE" nil org-html-doctype) + (:html-container "HTML_CONTAINER" nil org-html-container-element) (:html-link-home "HTML_LINK_HOME" nil org-html-link-home) (:html-link-up "HTML_LINK_UP" nil org-html-link-up) (:html-mathjax "HTML_MATHJAX" nil "" space) @@ -859,19 +861,44 @@ Use utf-8 as the default value." :package-version '(Org . "8.0") :type 'coding-system) -(defcustom org-html-divs '("preamble" "content" "postamble") - "The name of the main divs for HTML export. -This is a list of three strings, the first one for the preamble -DIV, the second one for the content DIV and the third one for the -postamble DIV." +(defcustom org-html-doctype + "" + "Document type definition to use for exported HTML files. +Can be set with the in-buffer HTML_DOCTYPE property or for +publishing, with :html-doctype." :group 'org-export-html :version "24.4" :package-version '(Org . "8.0") - :type '(list - (string :tag " Div for the preamble:") - (string :tag " Div for the content:") - (string :tag "Div for the postamble:"))) + :type 'string) + +(defcustom org-html-container-element "div" + "Container class to use for wrapping top level sections in +the exported html file. Can be set with the in-buffer HTML_CONTAINER +property or for publishing, with :html-container" + :group 'org-export-html + :version "24.4" + :package-version '(Org . "8.0") + :type 'string) +(defcustom org-html-divs + '(("preamble" "div") + ("content" "div") + ("postamble" "div")) + "Alist of the main divs for HTML export. +This is a list of three pairs, ID and ELEMENT, the first one +for the preamble, the second one for the content and the +third one for the postamble." + :group 'org-export-html + :version "24.4" + :package-version '(Org . "8.0") + :type '(list + (list :tag "Preamble" + (string :tag " id") (string :tag "element")) + (list :tag "Content" + (string :tag " id") (string :tag "element")) + (list :tag "Postamble" + (string :tag " id") (string :tag "element")))) ;;;; Template :: Mathjax @@ -1482,9 +1509,11 @@ INFO is a plist used as a communication channel." `((?t . ,title) (?a . ,author) (?d . ,date) (?e . ,email)))))))) (when (org-string-nw-p preamble-contents) - (concat (format "
\n" (nth 0 org-html-divs)) + (concat (format "<%s id=\"%s\">\n" + (nth 1 (nth 0 org-html-divs)) + (nth 0 (nth 0 org-html-divs))) (org-element-normalize-string preamble-contents) - "
\n")))))) + (format "\n" (nth 1 (nth 0 org-html-divs))))))))) (defun org-html--build-postamble (info) "Return document postamble as a string, or nil. @@ -1534,9 +1563,11 @@ INFO is a plist used as a communication channel." (?v . ,html-validation-link))))))))) (when (org-string-nw-p postamble-contents) (concat - (format "
\n" (nth 2 org-html-divs)) + (format "<%s id=\"%s\">\n" + (nth 1 (nth 2 org-html-divs)) + (nth 0 (nth 2 org-html-divs))) (org-element-normalize-string postamble-contents) - "
\n")))))) + (format "\n" (nth 1 (nth 2 org-html-divs))))))))) (defun org-html-inner-template (contents info) "Return body of document string after HTML conversion. @@ -1571,8 +1602,8 @@ holding export options." (coding-system-get org-html-coding-system 'mime-charset)) "iso-8859-1")) "\n" - "\n" + (plist-get info :html-doctype) + "\n" (format "\n" (plist-get info :language) (plist-get info :language)) "\n" @@ -1590,12 +1621,14 @@ holding export options." ;; Preamble. (org-html--build-preamble info) ;; Document contents. - (format "
\n" (nth 1 org-html-divs)) + (format "<%s id=\"%s\">\n" + (nth 1 (nth 1 org-html-divs)) + (nth 0 (nth 1 org-html-divs))) ;; Document title. (let ((title (plist-get info :title))) (format "

%s

\n" (org-export-data (or title "") info))) contents - "
\n" + (format "\n" (nth 1 (nth 1 org-html-divs))) ;; Postamble. (org-html--build-postamble info) ;; Closing document. @@ -2157,7 +2190,10 @@ holding contextual information." (extra-class (org-element-property :HTML_CONTAINER_CLASS headline)) (level1 (+ level (1- org-html-toplevel-hlevel))) (first-content (car (org-element-contents headline)))) - (format "
%s%s
\n" + (format "<%s id=\"%s\" class=\"%s\">%s%s\n" + (if (= 1 (org-export-get-relative-level headline info)) + (plist-get info :html-container) + "div") (format "outline-container-%s" (or (org-element-property :CUSTOM_ID headline) section-number)) @@ -2181,7 +2217,9 @@ holding contextual information." (if (not (eq (org-element-type first-content) 'section)) (concat (org-html-section first-content "" info) contents) - contents))))))) + contents) + (if (= 1 (org-export-get-relative-level headline info)) + (plist-get info :html-container)))))))) ;;;; Horizontal Rule -- 1.8.1.5 --LyciRD1jyfeSSjG0--