emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] Don't output preamble DIV if its contents is empty
@ 2011-09-29 19:58 Sebastien Vauban
  2011-10-09 11:24 ` Carsten Dominik
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-09-29 19:58 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

Hi,

To be sure that CSS rules don't apply to missing contents, there's no need to
output DIV preamble opening and closing tags if there is nothing in between.

Best regards,
  Seb

-- 
Sebastien Vauban

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Don-t-output-DIV-preamble-tags-when-contents-is-empt.patch --]
[-- Type: text/x-patch, Size: 1951 bytes --]

From 9bb3959f8ca978e7486ba7bde11cd407a40e653b Mon Sep 17 00:00:00 2001
From: Sebastien Vauban <sva-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
Date: Thu, 29 Sep 2011 21:49:11 +0200
Subject: [PATCH 2/2] Don't output DIV preamble tags when contents is empty.

---
 lisp/org-html.el |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/lisp/org-html.el b/lisp/org-html.el
index fde563b..0139c16 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1337,23 +1337,30 @@ lang=\"%s\" xml:lang=\"%s\">
 
 	;; insert html preamble
 	(when (plist-get opt-plist :html-preamble)
-	  (let ((html-pre (plist-get opt-plist :html-preamble)))
-	    (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+	  (let ((html-pre (plist-get opt-plist :html-preamble))
+		html-pre-real-contents)
 	    (cond ((stringp html-pre)
-		   (insert
-		    (format-spec html-pre `((?t . ,title) (?a . ,author)
-					    (?d . ,date) (?e . ,email)))))
+		   (setq html-pre-real-contents
+			 (format-spec html-pre `((?t . ,title) (?a . ,author)
+						 (?d . ,date) (?e . ,email)))))
 		  ((functionp html-pre)
-		   (funcall html-pre))
+		   (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+		   (funcall html-pre)
+		   (insert "\n</div>\n"))
 		  (t
-		   (insert
+		   (setq html-pre-real-contents
 		    (format-spec
 		     (or (cadr (assoc (nth 0 lang-words)
 				      org-export-html-preamble-format))
 			 (cadr (assoc "en" org-export-html-preamble-format)))
 		     `((?t . ,title) (?a . ,author)
 		       (?d . ,date) (?e . ,email))))))
-	    (insert "\n</div>\n")))
+	    ;; don't output an empty preamble DIV
+	    (unless (and (functionp html-pre)
+			 (equal html-pre-real-contents ""))
+	      (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
+	      (insert html-pre-real-contents)
+	      (insert "\n</div>\n"))))
 
 	;; begin wrap around body
 	(insert (format "\n<div id=\"%s\">"
-- 
1.7.5.1


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

end of thread, other threads:[~2011-10-30  0:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-29 19:58 [patch] Don't output preamble DIV if its contents is empty Sebastien Vauban
2011-10-09 11:24 ` Carsten Dominik
2011-10-09 18:34   ` Sebastien Vauban
2011-10-29 11:31     ` Bastien
2011-10-29 19:28       ` Sebastien Vauban
2011-10-30  0:12         ` Bastien

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).