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

* Re: [patch] Don't output preamble DIV if its contents is empty
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Carsten Dominik @ 2011-10-09 11:24 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Hi Sebastien,

are there adverse effects when an empty div is in the file?

THanks

- Carsten
On 29.9.2011, at 21:58, Sebastien Vauban wrote:

> 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
> <0002-Don-t-output-DIV-preamble-tags-when-contents-is-empt.patch>

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

* Re: [patch] Don't output preamble DIV if its contents is empty
  2011-10-09 11:24 ` Carsten Dominik
@ 2011-10-09 18:34   ` Sebastien Vauban
  2011-10-29 11:31     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-10-09 18:34 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Carsten,

Carsten Dominik wrote:
>> 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.
>
> are there adverse effects when an empty div is in the file?

Yes, there are, reason for such patch.

In some style I'm working on for the site I'm publishing, I'm using a quite
large banner in black background as site's preamble. That works OK.

But, even for exporting a single page (no publish, I mean, just `C-x C-e b'),
I got this black background coming into play, while I had *no preamble set* for
those orphan pages.

Hence, the patch to remove such a preamble when it is essentially empty.

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: [patch] Don't output preamble DIV if its contents is empty
  2011-10-09 18:34   ` Sebastien Vauban
@ 2011-10-29 11:31     ` Bastien
  2011-10-29 19:28       ` Sebastien Vauban
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2011-10-29 11:31 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Hi Sébastien,

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

>> are there adverse effects when an empty div is in the file?
>
> Yes, there are, reason for such patch.

I understand the reasons and I have applied the patch -- please
provide a ChangeLog next time.  

You can provide it like you just did (with the tag filter patch), but
even better is to include the ChangeLog in the commit log, after the
first line.  

Check available commits on http://orgmode.org/w/org-mode.git to 
get the idea.

Thanks!

-- 
 Bastien

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

* Re: [patch] Don't output preamble DIV if its contents is empty
  2011-10-29 11:31     ` Bastien
@ 2011-10-29 19:28       ` Sebastien Vauban
  2011-10-30  0:12         ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-10-29 19:28 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Bastien,

Bastien wrote:
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>>> are there adverse effects when an empty div is in the file?
>>
>> Yes, there are, reason for such patch.
>
> I understand the reasons and I have applied the patch -- please provide a
> ChangeLog next time.

I can assure you that I'll do, as I just began doing...

> You can provide it like you just did (with the tag filter patch), but even
> better is to include the ChangeLog in the commit log, after the first line.
> Check available commits on http://orgmode.org/w/org-mode.git to get the
> idea.

OK. Understood.

Question: why do we do like that (inserting the ChangeLog contents after the
first line of the commit log)?  Is it automatically used somewhere to generate
a proper ChangeLog file?

Why isn't there a real shared ChangeLog file in the repository?

I want to know, because I want to learn more about all the aspects of this
project in particular, but as well collaborative work in general...

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: [patch] Don't output preamble DIV if its contents is empty
  2011-10-29 19:28       ` Sebastien Vauban
@ 2011-10-30  0:12         ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2011-10-30  0:12 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

Hi Sébastien,

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

> Question: why do we do like that (inserting the ChangeLog contents after the
> first line of the commit log)?  Is it automatically used somewhere to generate
> a proper ChangeLog file?

Yes -- see UTILITIES/make_emacs_changelog which collects logs from 
git commits and format them into proper Emacs ChangeLog.

> Why isn't there a real shared ChangeLog file in the repository?

There are already two "ChangeLogs", the one that you get from a
simple "git log" in Org's repo, and the ChangeLog in Emacs.

It's nice to have both: grep'ing through git logs is quick and
useful, you get a lot of detailed information here; on the other 
hand, looking for a function/variable's name in Emacs ChangeLog 
(or calling M-x occur RET in this ChangeLog buffer) is also a
nice way to get information wrt a particular function/variable.

I'm fine with a semi-auto-generated ChangeLog that I review 
and manually fix before merging new releases of Org into Emacs.

But I would not be able to maintain a separate ChangeLog for
Org only.  Of course, this is a matter of personal preference
and laziness and future maintainers might want to have an Org
ChangeLog between the git log and the Emacs Org ChangeLog.

> I want to know, because I want to learn more about all the aspects of this
> project in particular, but as well collaborative work in general...

Not sure this can be generalized as I'm not familiar enough
with other projects.

While seeking information about this issue, I stumbled upon
this fresh and not-so-unrelated post by ESR¹ and discover this
tool: reposurgeon.

¹ http://esr.ibiblio.org/?p=3859
² http://catb.org/~esr/reposurgeon/

I promise I won't use it but I was curious if anyone tested
it on this list :)

-- 
 Bastien

^ permalink raw reply	[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).