diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-07-13 11:46:51 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-09-01 19:05:45 +0200 |
commit | 99306969b06d4c91d0b9a0addd2ab7f0fc0bd33d (patch) | |
tree | b761383ef5a53085f8ba9c20a5ef238d97675dd1 | |
parent | f6770132767da202b711e684805a3e5399b23850 (diff) | |
download | org-mode-99306969b06d4c91d0b9a0addd2ab7f0fc0bd33d.tar.gz |
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.
-rw-r--r-- | lisp/org-exp.el | 16 | ||||
-rw-r--r-- | lisp/org-html.el | 27 | ||||
-rw-r--r-- | lisp/org-latex.el | 27 |
3 files changed, 40 insertions, 30 deletions
diff --git a/lisp/org-exp.el b/lisp/org-exp.el index fafdb07..bfa3b46 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 d80a852..694c186 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 "<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 diff --git a/lisp/org-latex.el b/lisp/org-latex.el index c01ab26..838cc68 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 |