Просмотр исходного кода

Both latex and html should now export correctly.

* org-html.el (org-export-html-preprocess): Remove unneeded insertion
  of list end marker, as it is now handled by
  `org-export-mark-list-ending'.
* org-html.el (org-export-as-html): Cleaner termination of lists.
* org-exp.el (org-export-mark-list-ending): New function to insert
  specific markers at the end of lists when exporting to a backend not
  using `org-list-parse-list'.
  This function is called early in `org-export-preprocess-string',
  while it is still able to recognize lists.
* org-latex.el (org-export-latex-lists): Better search for lists. It
  now only finds items not enclosed and not protected.
Nicolas Goaziou 15 лет назад
Родитель
Сommit
99306969b0
3 измененных файлов с 40 добавлено и 30 удалено
  1. 16 0
      lisp/org-exp.el
  2. 10 17
      lisp/org-html.el
  3. 14 13
      lisp/org-latex.el

+ 16 - 0
lisp/org-exp.el

@@ -1076,6 +1076,9 @@ on this string to produce the exported version."
 				     (plist-get parameters :exclude-tags))
       (run-hooks 'org-export-preprocess-after-tree-selection-hook)
 
+      ;; Mark end of lists
+      (org-export-mark-list-ending backend)
+
       ;; Handle source code snippets
       (org-export-replace-src-segments-and-examples backend)
 
@@ -1626,6 +1629,19 @@ These special cookies will later be interpreted by the backend."
 	(delete-region beg end)
 	(insert (org-add-props content nil 'original-indentation ind))))))
 
+(defun org-export-mark-list-ending (backend)
+  "Mark list endings with special cookies.
+These special cookies will later be interpreted by the backend.
+`org-list-end-re' is replaced by a blank line in the process."
+  ;; Backends using `org-list-parse-list' do not need this.
+  (unless (eq backend 'latex)
+    (goto-char (point-min))
+    (while (org-search-forward-unenclosed (org-item-re) nil 'move)
+      (goto-char (org-list-bottom-point))
+      (when (looking-at (org-list-end-re))
+	(replace-match "\n"))
+      (insert "ORG-LIST-END\n"))))
+
 (defun org-export-attach-captions-and-attributes (backend target-alist)
   "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
 If the next thing following is a table, add the text properties to the first

+ 10 - 17
lisp/org-html.el

@@ -561,13 +561,7 @@ This may also be a function, building and inserting the postamble.")
 	  (if (string-match "\\`[a-z]\\{1,10\\}:\\(.+\\)" label)
 	      (setq l1 (substring label (match-beginning 1)))
 	    (setq l1 label)))
-	(replace-match (format "[[#%s][%s]]" label l1) t t))))
-  (goto-char (point-min))
-  (while (org-search-forward-unenclosed (org-item-re) nil 'move)
-    (goto-char (org-list-bottom-point))
-    (when (looking-at (org-list-end-re))
-      (replace-match ""))
-    (insert "ORG-LIST-END\n")))
+	(replace-match (format "[[#%s][%s]]" label l1) t t)))))
 
 ;;;###autoload
 (defun org-export-as-html-and-open (arg)
@@ -1511,16 +1505,15 @@ lang=\"%s\" xml:lang=\"%s\">
 	      (insert "<pre>")
 	      (setq inquote t)))
 
-	   ((string-match "^ORG-LIST-END" line)
-	    ;; Explicit list closure
-	    (let ((ind (org-get-indentation line)))
-	      (while (and local-list-indent
-			  (<= ind (car local-list-indent)))
-		(org-close-li (car local-list-type))
-		(insert (format "</%sl>\n" (car local-list-type)))
-		(pop local-list-type)
-		(pop local-list-indent))
-	      (or local-list-indent (setq in-local-list nil)))
+	   ;; Explicit list closure
+	   ((equal "ORG-LIST-END" line)
+	    (while local-list-indent
+	      (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 nil)
+	    (org-open-par)
 	    (throw 'nextline nil))
 
 	   ((and org-export-with-tables

+ 14 - 13
lisp/org-latex.el

@@ -2238,19 +2238,20 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   "Convert plain text lists in current buffer into LaTeX lists."
   (let (res)
     (goto-char (point-min))
-    (while (org-re-search-forward-unprotected (org-item-re) nil t)
-      (beginning-of-line)
-      (setq res (org-list-to-latex (org-list-parse-list t)
-				   org-export-latex-list-parameters))
-      (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
-			   res)
-	(setq res (replace-match
-		   (concat (format "\\setcounter{enumi}{%d}"
-				   (1- (string-to-number
-					(match-string 2 res))))
-			   "\n"
-			   (match-string 1 res))
-		   t t res)))
+    (while (org-search-forward-unenclosed (org-item-re) nil t)
+      (org-if-unprotected
+       (beginning-of-line)
+       (setq res (org-list-to-latex (org-list-parse-list t)
+				    org-export-latex-list-parameters))
+       (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
+			    res)
+	 (setq res (replace-match
+		    (concat (format "\\setcounter{enumi}{%d}"
+				    (1- (string-to-number
+					 (match-string 2 res))))
+			    "\n"
+			    (match-string 1 res))
+		    t t res))))
       (insert res "\n"))))
 
 (defconst org-latex-entities