Ver Fonte

HTML 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 há 16 anos atrás
pai
commit
75117098f0
2 ficheiros alterados com 21 adições e 0 exclusões
  1. 4 0
      lisp/ChangeLog
  2. 17 0
      lisp/org-html.el

+ 4 - 0
lisp/ChangeLog

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

+ 17 - 0
lisp/org-html.el

@@ -841,6 +841,7 @@ lang=\"%s\" xml:lang=\"%s\">
 
 
 	  ;; Protected HTML
 	  ;; Protected HTML
 	  (when (get-text-property 0 'org-protected line)
 	  (when (get-text-property 0 'org-protected line)
+	    (org-export-html-close-lists-maybe line)
 	    (let (par)
 	    (let (par)
 	      (when (re-search-backward
 	      (when (re-search-backward
 		     "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
 		     "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
@@ -1865,6 +1866,22 @@ If there are links in the string, don't modify these."
   (org-close-par-maybe)
   (org-close-par-maybe)
   (insert (if (equal type "d") "</dd>\n" "</li>\n")))
   (insert (if (equal type "d") "</dd>\n" "</li>\n")))
 
 
+(defvar in-local-list)
+(defvar local-list-indent)
+(defun org-export-html-close-lists-maybe (line)
+  (let ((ind (get-text-property 0 'original-indentation line))
+	didclose)
+    (when ind
+      (while (and in-local-list
+		  (or (= ind (car local-list-indent))
+		      (< ind (car local-list-indent))))
+	(setq didclose t)
+	(org-close-li (car local-list-type))
+	(insert (format "</%sl>\n" (car local-list-type)))
+	(pop local-list-type) (pop local-list-indent)
+	(setq in-local-list local-list-indent))
+      (and didclose (org-open-par)))))
+
 (defvar body-only) ; dynamically scoped into this.
 (defvar body-only) ; dynamically scoped into this.
 (defun org-html-level-start (level title umax with-toc head-count)
 (defun org-html-level-start (level title umax with-toc head-count)
   "Insert a new level in HTML export.
   "Insert a new level in HTML export.