Commit d5098885 authored by John Wiegley's avatar John Wiegley
Browse files

2007-09-26 Bastien Guerry <bzg@altern.org>

	* org-export-latex.el (org-export-latex-tables-verbatim): New
	function.
	(org-export-latex-remove-from-headlines): Name changed because of
	typo.
	(org-export-latex-quotation-marks-convention): Option removed.
	(org-export-latex-make-preamble): Handle the DATE option.
	(org-export-latex-cleaned-string): Now the only cleaning function,
	synched up with org.el.
	(org-export-latex-lists, org-export-latex-parse-list)
	(org-export-list-to-latex): New functions.


2007-09-26  Carsten Dominik  <dominik@science.uva.nl>

	* org.el (org-kill-is-subtree-p): Use `org-outline-regexp'.
	(org-outline-regexp): New constant.
	(org-remember-handler): Throw error when the target file is not in
	org-mode.
	(org-cleaned-string-for-export): No longer call
	`org-export-latex-cleaned-string' with an argument.
	(org-get-tags): Returns now a list, not a string.
	(org-get-tags-string): New function.
	(org-archive-subtree): No need to split return of `org-get-tags'.
	(org-set-tags, org-entry-properties): Call `org-get-tags-string'
	instead of `org-get-tags'.
	(org-agenda-format-date): Renamed from `org-agenda-date-format'.
	(org-time-from-absolute, org-agenda-format-date-aligned): New
	functions.
	(org-compatible-face): New argument INHERITS.  Inherit from this
	face if possible.
	(org-level-1, org-level-2, org-level-3, org-level-4)
	(org-level-5, org-level-6, org-level-7, org-level-8)
	(org-special-keyword, org-drawer, org-column, org-warning)
	(org-archived, org-todo, org-done, org-headline-done, org-table)
	(org-formula, org-code, org-agenda-structure)
	(org-scheduled-today, org-scheduled-previously)
	(org-upcoming-deadline, org-time-grid): Call `org-compatible-face'
	in the new way.
	(org-get-heading): New argument NO-TAGS.
	(org-fast-tag-selection-include-todo): Made defvar instead of
	defcustom, feature is not deprecated.
	(org-remember-store-without-prompt): New default value t.
	(org-todo-log-states): New variable.
	(org-set-regexps-and-options): #+TODO is an alias for SEQ_TODO.
	Compute the log states.
	(org-goto-map): More commands copied from global map.  Also bind
	`org-occur'.
	(org-goto): Made into a general lookup command.
	(org-get-location): Complete rewrite.
	(org-goto-exit-command): New variable.
	(org-goto-selected-point): New variable.
	(org-goto-ret, org-goto-left, org-goto-right, org-goto-quit): Set
	the new variables.
	(org-paste-subtree): Whitespace insertion strategy revised.
	(org-remember-apply-template): Protect v-A from the possibility
	that v-a might be nil.
	(org-remember-handler): Insertion rules revised.
	(org-todo): Respect org-todo-log-states.
	(org-up-heading-safe): New function.
	(org-entry-get-with-inheritance): Use `org-up-heading-safe'.

	* org.texi: Change links to webpage and maintained email.
	(Remember): Promoted to Chapter, significant changes.
	(Fast access to TODO states): New section.
	(Faces for TODO keywords): New section.
	(Export options): Example for #+DATE.
	(Progress logging): Section moved.
parent 62035afd
2007-09-26 Bastien Guerry <bzg@altern.org>
* org-export-latex.el (org-export-latex-tables-verbatim): New
function.
(org-export-latex-remove-from-headlines): Name changed because of
typo.
(org-export-latex-quotation-marks-convention): Option removed.
(org-export-latex-make-preamble): Handle the DATE option.
(org-export-latex-cleaned-string): Now the only cleaning function,
synched up with org.el.
(org-export-latex-lists, org-export-latex-parse-list)
(org-export-list-to-latex): New functions.
2007-09-26 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-kill-is-subtree-p): Use `org-outline-regexp'.
(org-outline-regexp): New constant.
(org-remember-handler): Throw error when the target file is not in
org-mode.
(org-cleaned-string-for-export): No longer call
`org-export-latex-cleaned-string' with an argument.
(org-get-tags): Returns now a list, not a string.
(org-get-tags-string): New function.
(org-archive-subtree): No need to split return of `org-get-tags'.
(org-set-tags, org-entry-properties): Call `org-get-tags-string'
instead of `org-get-tags'.
(org-agenda-format-date): Renamed from `org-agenda-date-format'.
(org-time-from-absolute, org-agenda-format-date-aligned): New
functions.
(org-compatible-face): New argument INHERITS. Inherit from this
face if possible.
(org-level-1, org-level-2, org-level-3, org-level-4)
(org-level-5, org-level-6, org-level-7, org-level-8)
(org-special-keyword, org-drawer, org-column, org-warning)
(org-archived, org-todo, org-done, org-headline-done, org-table)
(org-formula, org-code, org-agenda-structure)
(org-scheduled-today, org-scheduled-previously)
(org-upcoming-deadline, org-time-grid): Call `org-compatible-face'
in the new way.
(org-get-heading): New argument NO-TAGS.
(org-fast-tag-selection-include-todo): Made defvar instead of
defcustom, feature is not deprecated.
(org-remember-store-without-prompt): New default value t.
(org-todo-log-states): New variable.
(org-set-regexps-and-options): #+TODO is an alias for SEQ_TODO.
Compute the log states.
(org-goto-map): More commands copied from global map. Also bind
`org-occur'.
(org-goto): Made into a general lookup command.
(org-get-location): Complete rewrite.
(org-goto-exit-command): New variable.
(org-goto-selected-point): New variable.
(org-goto-ret, org-goto-left, org-goto-right, org-goto-quit): Set
the new variables.
(org-paste-subtree): Whitespace insertion strategy revised.
(org-remember-apply-template): Protect v-A from the possibility
that v-a might be nil.
(org-remember-handler): Insertion rules revised.
(org-todo): Respect org-todo-log-states.
(org-up-heading-safe): New function.
(org-entry-get-with-inheritance): Use `org-up-heading-safe'.
* org.texi: Change links to webpage and maintained email.
(Remember): Promoted to Chapter, significant changes.
(Fast access to TODO states): New section.
(Faces for TODO keywords): New section.
(Export options): Example for #+DATE.
(Progress logging): Section moved.
2007-09-26 Dan Nicolaescu <dann@ics.uci.edu>
* progmodes/cc-cmds.el (c-indent-line-or-region): Only indent the
......
......@@ -3,8 +3,8 @@
;;
;; Author: Bastien Guerry <bzg AT altern DOT org>
;; Keywords: org organizer latex export convert
;; Version: $Id: org-export-latex.el,v 1.5 2007/09/07 20:16:45 johnw Exp $
;; X-URL: <http://www.cognition.ens.fr/~guerry/u/org-export-latex.el>
;; Homepage: http://www.cognition.ens.fr/~guerry/u/org-export-latex.el
;; Version: 5.09
;;
;; This file is part of GNU Emacs.
;;
......@@ -52,6 +52,8 @@
(defvar org-latex-all-targets-regexp nil)
(defvar org-latex-add-level 0)
(defvar org-latex-sectioning-depth 0)
(defvar org-export-latex-list-beginning-re
"^\\([ \t]*\\)\\([-+]\\|[0-9]+\\(?:\\.\\|)\\)\\) *?")
(defvar org-latex-special-string-regexps
'(org-ts-regexp
......@@ -99,11 +101,17 @@ The %s formatter will be replaced by the title of the section."
:group 'org-export-latex
:type 'string)
(defcustom org-export-latex-date-format nil
(defcustom org-export-latex-date-format
"%d %B %Y"
"Format string for \\date{...}."
:group 'org-export-latex
:type 'string)
(defcustom org-export-latex-tables-verbatim nil
"When non-nil, export tables as verbatim."
:group 'org-export-latex
:type 'boolean)
(defcustom org-export-latex-packages-alist nil
"Alist of packages to be inserted in the preamble.
Each cell is of the forma \( option . package \).
......@@ -126,7 +134,7 @@ headline is mandatory)."
(symbol :tag "Convert as descriptive list" description)
(string :tag "Use a section string" :value "\\subparagraph{%s}")))
(defcustom org-export-latex-remove-from-headines
(defcustom org-export-latex-remove-from-headlines
'(:todo t :priority t :tags t)
"A plist of keywords to remove from headlines.
Non-nil means remove this keyword type from the headline.
......@@ -135,13 +143,6 @@ Don't remove the keys, just change their values."
:type 'plist
:group 'org-export-latex)
(defcustom org-export-latex-quotation-marks-convention "en"
"Convention for conversion of the quotation marks.
This value is overriden by any infile language setup."
:group 'org-export-latex
:type '(choice (string :tag "english" "en")
(string :tag "french" "fr")))
(defcustom org-export-latex-image-default-option "width=10em"
"Default option for images."
:group 'org-export-latex
......@@ -155,7 +156,6 @@ This value is overriden by any infile language setup."
;; FIXME Do we want this one?
;; (defun org-export-as-latex-and-open (arg) ...)
;;; Autoload functions:
;;;###autoload
(defun org-export-as-latex-batch ()
......@@ -280,13 +280,12 @@ in a window. A non-interactive call will only retunr the buffer."
(if region-p (region-beginning) (point-min))
(if region-p (region-end) (point-max))))
(string-for-export
;; FIXME Use org-cleaned-string-for-export instead, only when
;; everyone uses Org >5.04
(org-latex-cleaned-string-for-export
region :for-html nil
:comments nil
(org-cleaned-string-for-export
region :emph-multiline t
:for-LaTeX t
:skip-before-1st-heading nil
:comments nil
:add-text text
:skip-before-1st-heading skip
:LaTeX-fragments nil)))
(set-buffer buffer)
(erase-buffer)
......@@ -311,7 +310,7 @@ in a window. A non-interactive call will only retunr the buffer."
(setq org-latex-add-level
(if odd (1- (/ (1+ asters) 2)) (1- asters)))
(org-export-latex-parse-global level odd))))
(unless body-only (insert "\n\\end{document}"))
(or to-buffer (save-buffer))
(goto-char (point-min))
......@@ -321,7 +320,6 @@ in a window. A non-interactive call will only retunr the buffer."
(kill-buffer (current-buffer)))
(current-buffer))))
;;; Parsing functions:
(defun org-export-latex-parse-global (level odd)
"Parse the current buffer recursively, starting at LEVEL.
......@@ -372,6 +370,52 @@ Return A list reflecting the document structure."
(widen)))
(list output))))
(defun org-export-latex-parse-list (&optional delete)
"Parse the list at point.
Return a list containing first level items as strings and
sublevels as list of strings."
(let ((start (point))
;; Find the end of the list
(end (save-excursion
(catch 'exit
(while (or (looking-at org-export-latex-list-beginning-re)
(looking-at "^[ \t]+\\|^$"))
(if (eq (point) (point-max))
(throw 'exit (point-max)))
(forward-line 1))) (point)))
output itemsep)
(while (re-search-forward org-export-latex-list-beginning-re end t)
(setq itemsep (if (save-match-data
(string-match "^[0-9]" (match-string 2)))
"[0-9]+\\(?:\\.\\|)\\)" "[-+]"))
(let* ((indent1 (match-string 1))
(nextitem (save-excursion
(save-match-data
(or (and (re-search-forward
(concat "^" indent1 itemsep " *?") end t)
(match-beginning 0)) end))))
(item (buffer-substring
(point)
(or (and (re-search-forward
org-export-latex-list-beginning-re end t)
(goto-char (match-beginning 0)))
(goto-char end))))
(nextindent (match-string 1))
(item (org-trim item))
(item (if (string-match "^\\[.+\\]" item)
(replace-match "\\\\texttt{\\&}"
t nil item) item)))
(push item output)
(when (> (length nextindent)
(length indent1))
(narrow-to-region (point) nextitem)
(push (org-export-latex-parse-list) output)
(widen))))
(when delete (delete-region start end))
(setq output (nreverse output))
(push (if (string-match "^\\[0" itemsep)
'ordered 'unordered) output)))
(defun org-export-latex-parse-content ()
"Extract the content of a section."
(let ((beg (point))
......@@ -391,7 +435,6 @@ If ODD Is non-nil, assume subcontent only contains odd sections."
nil ; subcontent is nil
(org-export-latex-parse-global (+ (if odd 2 1) level) odd)))
;;; Rendering functions:
(defun org-export-latex-global (content)
"Export CONTENT to LaTeX.
......@@ -405,9 +448,10 @@ CONTENT is an element of the list produced by
"Export the list SUBCONTENT to LaTeX.
SUBCONTENT is an alist containing information about the headline
and its content."
(mapc (lambda(x) (org-export-latex-subcontent x)) subcontent))
(let ((num (plist-get org-latex-options-plist :section-numbers)))
(mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent)))
(defun org-export-latex-subcontent (subcontent)
(defun org-export-latex-subcontent (subcontent num)
"Export each cell of SUBCONTENT to LaTeX."
(let ((heading (org-export-latex-fontify-headline
(cdr (assoc 'heading subcontent))))
......@@ -415,8 +459,7 @@ and its content."
org-latex-add-level))
(occur (number-to-string (cdr (assoc 'occur subcontent))))
(content (cdr (assoc 'content subcontent)))
(subcontent (cadr (assoc 'subcontent subcontent)))
(num (plist-get org-latex-options-plist :section-numbers)))
(subcontent (cadr (assoc 'subcontent subcontent))))
(cond
;; Normal conversion
((<= level org-latex-sectioning-depth)
......@@ -475,49 +518,54 @@ EXT-PLIST is an optional additional plist."
"Make the LaTeX preamble and return it as a string.
Argument OPT-PLIST is the options plist for current buffer."
(let ((toc (plist-get opt-plist :table-of-contents)))
(format (concat org-export-latex-preamble
"
%s
\\begin{document}
\\title{%s}
%s
%s
\\maketitle
%s
%s
")
(if org-export-latex-packages-alist
(mapconcat (lambda(p)
(if (equal "" (car p))
(format "\\usepackage{%s}" (cadr p))
(format "\\usepackage[%s]{%s}"
(car p) (cadr p))))
org-export-latex-packages-alist "\n") "")
(or (plist-get opt-plist :title)
(and (not
(plist-get opt-plist :skip-before-1st-heading))
(org-export-grab-title-from-buffer))
(and buffer-file-name
(file-name-sans-extension
(file-name-nondirectory buffer-file-name)))
"UNTITLED")
(if (plist-get opt-plist :author-info)
(format "\\author{%s}"
(or (plist-get opt-plist :author) user-full-name))
(format "%%\\author{%s}"
(or (plist-get opt-plist :author) user-full-name)))
(if (plist-get opt-plist :timestamps)
(format "\\date{%s}"
(format-time-string (or org-export-latex-date-format
(car org-time-stamp-formats))))
"%\\date{}")
(if (and (plist-get opt-plist :section-numbers) toc)
(format "\\setcounter{tocdepth}{%s}"
(plist-get opt-plist :headline-levels)) "")
(if (and (plist-get opt-plist :section-numbers) toc)
"\\tableofcontents" ""))))
(concat (if (plist-get opt-plist :time-stamp-file)
(format-time-string "% Created %Y-%m-%d %a %H:%M\n"))
;; LaTeX custom preamble
org-export-latex-preamble "\n"
;; LaTeX packages
(if org-export-latex-packages-alist
(mapconcat (lambda(p)
(if (equal "" (car p))
(format "\\usepackage{%s}" (cadr p))
(format "\\usepackage[%s]{%s}"
(car p) (cadr p))))
org-export-latex-packages-alist "\n") "")
"\n\\begin{document}\n\n"
;; title
(format
"\\title{%s}\n"
(or (plist-get opt-plist :title)
(and (not
(plist-get opt-plist :skip-before-1st-heading))
(org-export-grab-title-from-buffer))
(and buffer-file-name
(file-name-sans-extension
(file-name-nondirectory buffer-file-name)))
"UNTITLED"))
;; author info
(if (plist-get opt-plist :author-info)
(format "\\author{%s}\n"
(or (plist-get opt-plist :author) user-full-name))
(format "%%\\author{%s}\n"
(or (plist-get opt-plist :author) user-full-name)))
;; date
(format "\\date{%s}\n"
(format-time-string
(or (plist-get opt-plist :date)
org-export-latex-date-format)))
"\\maketitle\n\n"
;; table of contents
(if (and (plist-get opt-plist :section-numbers) toc)
(format "\\setcounter{tocdepth}{%s}\n"
(plist-get opt-plist :headline-levels)) "")
(if (and (plist-get opt-plist :section-numbers) toc)
"\\tableofcontents\n" "\n"))))
(defun org-export-latex-first-lines (&optional comments)
"Export the first lines before first headline.
......@@ -529,10 +577,11 @@ formatting string like %%%%s if we want to comment them out."
(goto-char (match-beginning 0))
(goto-char (point-max)))))
(org-export-latex-content
(org-latex-cleaned-string-for-export
(org-cleaned-string-for-export
(buffer-substring (point-min) end)
:for-html nil
:for-LaTeX t
:emph-multiline t
:add-text nil
:comments nil
:skip-before-1st-heading nil
:LaTeX-fragments nil)))))
......@@ -565,39 +614,32 @@ formatting string like %%%%s if we want to comment them out."
;; the beginning of the buffer - inserting "\n" is safe here though.
(insert "\n" headline)
(goto-char (point-min))
(org-export-latex-special-chars
(plist-get org-latex-options-plist :sub-superscript))
(when (plist-get org-latex-options-plist :emphasize)
(org-export-latex-fontify))
(org-export-latex-special-chars
(plist-get org-latex-options-plist :sub-superscript))
(org-export-latex-keywords-maybe
org-export-latex-remove-from-headines)
org-export-latex-remove-from-headlines)
(org-export-latex-links)
(org-trim (buffer-substring-no-properties (point-min) (point-max)))))
(defun org-export-latex-fix-invisible-strings ()
"Comment out (INVISIBLE) warnings."
(goto-char (point-min))
(while (re-search-forward "(INVISIBLE)" nil t)
(replace-match "%\\&")))
(defun org-export-latex-content (content)
"Convert CONTENT string to LaTeX."
(with-temp-buffer
(insert content)
(org-export-latex-quotation-marks)
(org-export-latex-special-chars
(plist-get org-latex-options-plist :sub-superscript))
(when (plist-get org-latex-options-plist :emphasize)
(org-export-latex-fontify))
(org-export-latex-special-chars
(plist-get org-latex-options-plist :sub-superscript))
(org-export-latex-links)
(org-export-latex-keywords)
(org-export-latex-itemize)
(org-export-latex-enumerate)
(org-export-latex-keywords
(plist-get org-latex-options-plist :timestamps))
(org-export-latex-lists)
(org-export-latex-tables
(plist-get org-latex-options-plist :tables))
(org-export-latex-fixed-width
(plist-get org-latex-options-plist :fixed-width))
(org-export-latex-fix-invisible-strings)
(buffer-substring (point-min) (point-max))))
(defun org-export-latex-quotation-marks ()
......@@ -605,8 +647,7 @@ formatting string like %%%%s if we want to comment them out."
Local definition of the language overrides
`org-export-latex-quotation-marks-convention' which overrides
`org-export-default-language'."
(let* ((lang (or (plist-get org-latex-options-plist :language)
org-export-latex-quotation-marks-convention))
(let* ((lang (plist-get org-latex-options-plist :language))
(quote-rpl (if (equal lang "fr")
'(("\\(\\s-\\)\"" "«~")
("\\(\\S-\\)\"" "~»")
......@@ -624,7 +665,7 @@ Local definition of the language overrides
;; | chars/string in Org | normal environment | math environment |
;; |-----------------------+-----------------------+-----------------------|
;; | & # % $ | \& \# \% \$ | \& \# \% \$ |
;; | { } _ ^ \ | \ { \ } \_ \^ \\ | { } _ ^ \ |
;; | { } _ ^ \ | \{ \} \_ \^ \\ | { } _ ^ \ |
;; |-----------------------+-----------------------+-----------------------|
;; | a_b and a^b | $a_b$ and $a^b$ | a_b and a^b |
;; | a_abc and a_{abc} | $a_a$bc and $a_{abc}$ | a_abc and a_{abc} |
......@@ -718,8 +759,10 @@ Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
(format "$%s%s{%s}$" string-before char
(match-string 1 string-after)))
(subsup (concat "$" string-before char string-after "$"))
(t (concat string-before "\\" char string-after))))
(t (concat string-before "\\" char string-after))))
(t (org-latex-protect
(concat string-before "\\" char "{}" string-after)))))
(t (org-latex-protect
(concat string-before "\\" char "{}" string-after)))))
(defun org-export-latex-treat-backslash-char (string-before string-after)
"Convert the \"$\" special character to LaTeX.
......@@ -744,16 +787,17 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(concat string-before "$\\backslash$" string-after))
(t (concat string-before "$\\backslash$" string-after))))
(defun org-export-latex-keywords ()
(defun org-export-latex-keywords (timestamps)
"Convert special keywords to LaTeX.
Regexps are those from `org-latex-special-string-regexps'."
(let ((rg org-latex-special-string-regexps) r)
(while (setq r (pop rg))
(goto-char (point-min))
(while (re-search-forward (eval r) nil t)
(replace-match (format "\\\\texttt{%s}" (match-string 0)) t)))))
;; FIXME - we need better implementation for nested lists
(if (not timestamps)
(replace-match (format "\\\\texttt{%s}" (match-string 0)) t)
(replace-match ""))))))
(defun org-export-latex-fixed-width (opt)
"When OPT is non-nil convert fixed-width sections to LaTeX."
(goto-char (point-min))
......@@ -773,12 +817,78 @@ Regexps are those from `org-latex-special-string-regexps'."
(forward-line))))))
;; FIXME Use org-export-highlight-first-table-line ?
(defun org-export-latex-lists ()
"Convert lists to LaTeX."
(goto-char (point-min))
(while (re-search-forward org-export-latex-list-beginning-re nil t)
(beginning-of-line)
(org-export-list-to-latex
(org-export-latex-parse-list t))))
(defun org-export-list-to-generic (list params)
"Convert a LIST parsed through `org-export-latex-parse-list' to other formats.
Valid parameters are
:ustart String to start an unordered list
:uend String to end an unordered list
:ostart String to start an ordered list
:oend String to end an ordered list
:splice When set to t, return only list body lines, don't wrap
them into :[u/o]start and :[u/o]end. Default is nil.
:istart String to start a list item
:iend String to end a list item
:isep String to separate items
:lsep String to separate sublists"
(interactive)
(let* ((p params) sublist
(splicep (plist-get p :splice))
(ostart (plist-get p :ostart))
(oend (plist-get p :oend))
(ustart (plist-get p :ustart))
(uend (plist-get p :uend))
(istart (plist-get p :istart))
(iend (plist-get p :iend))
(isep (plist-get p :isep))
(lsep (plist-get p :lsep)))
(let ((wrapper
(cond ((eq (car list) 'ordered)
(concat ostart "\n%s" oend "\n"))
((eq (car list) 'unordered)
(concat ustart "\n%s" uend "\n"))))
rtn)
(while (setq sublist (pop list))
(cond ((symbolp sublist) nil)
((stringp sublist)
(setq rtn (concat rtn istart sublist iend isep)))
(t
(setq rtn (concat rtn ;; previous list
lsep ;; list separator
(org-export-list-to-generic sublist p)
lsep ;; list separator
)))))
(format wrapper rtn))))
(defun org-export-list-to-latex (list)
"Convert LIST into a LaTeX list."
(insert
(org-export-list-to-generic
list '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
:ustart "\\begin{itemize}" :uend "\\end{itemize}"
:istart "\\item " :iend ""
:isep "\n" :lsep "\n"))
;; Add a trailing \n after list conversion
"\n"))
(defun org-export-latex-tables (opt)
"When OPT is non-nil convert tables to LaTeX."
(goto-char (point-min))
(while (re-search-forward "^\\([ \t]*\\)|" nil t)
;; Re-align the table to update org-table-last-alignment
(save-window-excursion (save-match-data (org-table-align)))
;; (save-excursion (save-match-data (org-table-align)))
(let (tbl-list
(beg (match-beginning 0))
(end (save-excursion
......@@ -786,63 +896,22 @@ Regexps are those from `org-latex-special-string-regexps'."
(concat "^" (regexp-quote (match-string 1))
"[^|]\\|\\'") nil t) (match-beginning 0))))
(beginning-of-line)
(while (not (eq end (point)))
(if (looking-at "[ \t]*|\\([^-|].+\\)|[ \t]*$")
(push (split-string (org-trim (match-string 1)) "|") tbl-list)
(push 'hline tbl-list))
(forward-line))
;; comment region out instead of deleting it ?
(apply 'delete-region (list beg end))
(when opt (insert (orgtbl-to-latex (nreverse tbl-list)
nil) "\n\n")))))
(defun org-export-latex-list (srch0 srch1 srch2 rpl0 rpl1)
"Convert lists to LaTeX."
(goto-char (point-min))
(while (re-search-forward srch0 nil t)
(let* ((beg (match-beginning 0))
(prefix (regexp-quote (match-string 1)))
(end-string (when (re-search-forward srch1 nil t)
(match-string 0))))
(goto-char beg) (insert rpl0)
(while (re-search-forward
(concat "^" prefix srch2)
(if (not end-string)
(point-max)
(save-match-data
(save-excursion
(re-search-forward
(regexp-quote end-string) nil t)))) t)
(replace-match
(concat "\\item "
(if (match-string 1)
(format "\\texttt{%s}" (match-string 1))))
t t))
(goto-char (if end-string
(progn (re-search-forward
(regexp-quote end-string) nil t)
(match-beginning 0))
(point-max)))
(skip-chars-backward "\n") (forward-line 2)
(insert rpl1))))
(defun org-export-latex-itemize ()
"Convert item list to LaTeX."
(org-export-latex-list
"^\\([ \t]*\\)-"
"^[^ \n\t-]+.*$"
"- ?\\(\\[.+\\]\\)?"
"\\begin{itemize}\n"
"\\end{itemize}\n"))
(defun org-export-latex-enumerate ()
"Convert numeric list to LaTeX."
(org-export-latex-list
"^\\([ \t]*\\)[0-9]+[\.)] \\(\\[.+\\]\\)? ?"
"^[^ \n\t0-9]+.*$"
"[0-9]+[\.)] ?\\(\\[.+\\]\\)?"
"\\begin{enumerate}\n"
"\\end{enumerate}\n"))
(if org-export-latex-tables-verbatim
(let* ((raw-table (buffer-substring beg end))
(tbl (concat "\\begin{verbatim}\n" raw-table
"\\end{verbatim}\n")))
(apply 'delete-region (list beg end))
(insert tbl))
(progn
(while (not (eq end (point)))
(if (looking-at "[ \t]*|\\([^-|].+\\)|[ \t]*$")
(push (split-string (org-trim (match-string 1)) "|") tbl-list)