From mboxrd@z Thu Jan  1 00:00:00 1970
From: Baoqiu Cui <cbaoqiu@yahoo.com>
Subject: [PATCH] Fix a DocBook/HTML exporter bug for literal examples
Date: Sun, 14 Jun 2009 03:56:32 -0700
Message-ID: <bycr5xn2ie7.fsf@muchbodyking-lm.gateway.2wire.net>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1MFnOU-00023A-Am
	for emacs-orgmode@gnu.org; Sun, 14 Jun 2009 06:56:58 -0400
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1MFnOP-0001vo-Bc
	for emacs-orgmode@gnu.org; Sun, 14 Jun 2009 06:56:57 -0400
Received: from [199.232.76.173] (port=47938 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1MFnOO-0001vW-30
	for emacs-orgmode@gnu.org; Sun, 14 Jun 2009 06:56:52 -0400
Received: from main.gmane.org ([80.91.229.2]:48315 helo=ciao.gmane.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <geo-emacs-orgmode@m.gmane.org>)
	id 1MFnOM-0006uX-SM
	for emacs-orgmode@gnu.org; Sun, 14 Jun 2009 06:56:51 -0400
Received: from list by ciao.gmane.org with local (Exim 4.43)
	id 1MFnOJ-0005m9-0o
	for emacs-orgmode@gnu.org; Sun, 14 Jun 2009 10:56:47 +0000
Received: from adsl-76-192-233-190.dsl.pltn13.sbcglobal.net ([76.192.233.190])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <emacs-orgmode@gnu.org>; Sun, 14 Jun 2009 10:56:47 +0000
Received: from cbaoqiu by adsl-76-192-233-190.dsl.pltn13.sbcglobal.net with
	local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00
	for <emacs-orgmode@gnu.org>; Sun, 14 Jun 2009 10:56:47 +0000
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
To: emacs-orgmode@gnu.org

--=-=-=

Carsten,

Recent changes to respect example indentations introduced a bug in both
DocBook and HTML exporters.  The following example

------------------------------------------------------------------------
#+BEGIN_EXAMPLE
Group of lines separated by empty lines:

  Line One.

  Line Two.
  Line Three.

  Line Four.
  Line Five.
#+END_EXAMPLE
------------------------------------------------------------------------

is exported to HTML like the following (note that every empty line in
the above example is repeated 3 times):

------------------------------------------------------------------------
<pre class="example">
Lines...



  Line One.



  Line Two.
  Line Three.



  Line Four.
  Line Five.
</pre>
------------------------------------------------------------------------

and to DocBook format like this (empty lines are removed):

------------------------------------------------------------------------
<programlisting><![CDATA[Group of lines separated by empty lines:
Line One.
Line Two.
  Line Three.
Line Four.
  Line Five.
]]>
</programlisting>
------------------------------------------------------------------------

Attached please find a patch to fix this problem.

Thanks,
Baoqiu


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=example-indent.diff

diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index 12f6e8c..8a89675 100644
--- a/lisp/org-docbook.el
+++ b/lisp/org-docbook.el
@@ -653,7 +653,9 @@ publishing directory."
 		(replace-match "\\2\n"))
 	      (insert line "\n")
 	      (while (and lines
-			  (or (not ind) (equal ind (get-text-property 0 'original-indentation (car lines))))
+			  (or (= (length (car lines)) 0)
+			      (not ind)
+			      (equal ind (get-text-property 0 'original-indentation (car lines))))
 			  (or (= (length (car lines)) 0)
 			      (get-text-property 0 'org-protected (car lines))))
 		(insert (pop lines) "\n"))
diff --git a/lisp/org-html.el b/lisp/org-html.el
index bb73f24..77f820e 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -850,7 +850,9 @@ lang=\"%s\" xml:lang=\"%s\">
 		(replace-match "\\2\n"))
 	      (insert line "\n")
 	      (while (and lines
-			  (or (not ind) (equal ind (get-text-property 0 'original-indentation (car lines))))
+			  (or (= (length (car lines)) 0)
+			      (not ind)
+			      (equal ind (get-text-property 0 'original-indentation (car lines))))
 			  (or (= (length (car lines)) 0)
 			      (get-text-property 0 'org-protected (car lines))))
 		(insert (pop lines) "\n"))

--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

--=-=-=--