diff --git a/lisp/org-exp.el b/lisp/org-exp.el index fafdb07cb..bfa3b464e 100644 --- a/lisp/org-exp.el +++ b/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 diff --git a/lisp/org-html.el b/lisp/org-html.el index d80a852f9..694c1863a 100644 --- a/lisp/org-html.el +++ b/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 "
") (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 diff --git a/lisp/org-latex.el b/lisp/org-latex.el index c01ab267d..838cc68ef 100644 --- a/lisp/org-latex.el +++ b/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