Browse Source

Docbook export: Respect example indentation when parsing plain lists

Examples and source code blocks that are not sufficiently indented
will now terminate plain lists.
Carsten Dominik 16 years ago
parent
commit
c4f90084d7
2 changed files with 24 additions and 0 deletions
  1. 4 0
      lisp/ChangeLog
  2. 20 0
      lisp/org-docbook.el

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2009-06-07  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-docbook.el (org-export-docbook-close-lists-maybe): New function.
+	(org-export-as-docbook): Close lists when original indentation
+	mandates it.
+
 	* org-html.el (org-export-html-close-lists-maybe): New function.
 	(org-export-as-html): Close lists when original indentation
 	mandates it.

+ 20 - 0
lisp/org-docbook.el

@@ -644,6 +644,7 @@ publishing directory."
 
 	  ;; Protected HTML
 	  (when (get-text-property 0 'org-protected line)
+	    (org-export-docbook-close-lists-maybe line)
 	    (let (par)
 	      (when (re-search-backward
 		     "\\(<para>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
@@ -1144,6 +1145,25 @@ publishing directory."
       (insert "</listitem></varlistentry>\n")
     (insert "</listitem>\n")))
 
+(defvar in-local-list)
+(defvar local-list-indent)
+(defun org-export-docbook-close-lists-maybe (line)
+  (let ((ind (get-text-property 0 'original-indentation line))
+	didclose)
+    (when ind
+      (while (and in-local-list
+		  (<= ind (car local-list-indent)))
+	(setq didclose t)
+	(let ((listtype (car local-list-type)))
+	  (org-export-docbook-close-li listtype)
+	  (insert (cond
+		   ((equal listtype "o") "</orderedlist>\n")
+		   ((equal listtype "u") "</itemizedlist>\n")
+		   ((equal listtype "d") "</variablelist>\n"))))
+	(pop local-list-type) (pop local-list-indent)
+	(setq in-local-list local-list-indent))
+      (and didclose (org-export-docbook-open-para)))))
+
 (defun org-export-docbook-level-start (level title)
   "Insert a new level in DocBook export.
 When TITLE is nil, just close all open levels."