2011-07-07 09:18:47 -04:00
|
|
|
;;; org-lparse.el --- Line-oriented parser-exporter for Org-mode
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2013-01-01 10:04:24 -05:00
|
|
|
;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
;; Author: Jambunathan K <kjambunathan at gmail dot com>
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
|
|
|
;; Homepage: http://orgmode.org
|
2012-01-05 03:43:21 -05:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2012-01-05 03:43:21 -05:00
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
;;; Commentary:
|
|
|
|
|
2011-07-07 09:18:47 -04:00
|
|
|
;; `org-lparse' is the entry point for the generic line-oriented
|
|
|
|
;; exporter. `org-do-lparse' is the genericized version of the
|
|
|
|
;; original `org-export-as-html' routine.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-07-07 09:18:47 -04:00
|
|
|
;; `org-lparse-native-backends' is a good starting point for
|
|
|
|
;; exploring the generic exporter.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-07-07 09:18:47 -04:00
|
|
|
;; Following new interactive commands are provided by this library.
|
|
|
|
;; `org-lparse', `org-lparse-and-open', `org-lparse-to-buffer'
|
|
|
|
;; `org-replace-region-by', `org-lparse-region'.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-07-07 09:18:47 -04:00
|
|
|
;; Note that the above routines correspond to the following routines
|
|
|
|
;; in the html exporter `org-export-as-html',
|
|
|
|
;; `org-export-as-html-and-open', `org-export-as-html-to-buffer',
|
|
|
|
;; `org-replace-region-by-html' and `org-export-region-as-html'.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-07-08 06:39:05 -04:00
|
|
|
;; The new interactive command `org-lparse-convert' can be used to
|
2011-07-07 09:18:47 -04:00
|
|
|
;; convert documents between various formats. Use this to command,
|
|
|
|
;; for example, to convert odt file to doc or pdf format.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
;;; Code:
|
2011-12-10 10:09:07 -05:00
|
|
|
(eval-when-compile
|
|
|
|
(require 'cl))
|
2011-07-01 05:12:19 -04:00
|
|
|
(require 'org-exp)
|
|
|
|
(require 'org-list)
|
2011-12-10 10:09:07 -05:00
|
|
|
(require 'format-spec)
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-11-07 16:33:03 -05:00
|
|
|
(defun org-lparse-and-open (target-backend native-backend arg
|
|
|
|
&optional file-or-buf)
|
2011-08-04 16:31:19 -04:00
|
|
|
"Export outline to TARGET-BACKEND via NATIVE-BACKEND and open exported file.
|
2011-07-02 18:37:29 -04:00
|
|
|
If there is an active region, export only the region. The prefix
|
|
|
|
ARG specifies how many levels of the outline should become
|
|
|
|
headlines. The default is 3. Lower levels will become bulleted
|
|
|
|
lists."
|
2011-11-07 16:33:03 -05:00
|
|
|
(let (f (file-or-buf (or file-or-buf
|
|
|
|
(org-lparse target-backend native-backend
|
|
|
|
arg 'hidden))))
|
2011-07-01 05:12:19 -04:00
|
|
|
(when file-or-buf
|
|
|
|
(setq f (cond
|
|
|
|
((bufferp file-or-buf) buffer-file-name)
|
|
|
|
((file-exists-p file-or-buf) file-or-buf)
|
|
|
|
(t (error "org-lparse-and-open: This shouldn't happen"))))
|
|
|
|
(message "Opening file %s" f)
|
2012-09-03 09:59:21 -04:00
|
|
|
(org-open-file f 'system)
|
2011-07-01 05:12:19 -04:00
|
|
|
(when org-export-kill-product-buffer-when-displayed
|
|
|
|
(kill-buffer (current-buffer))))))
|
|
|
|
|
|
|
|
(defun org-lparse-batch (target-backend &optional native-backend)
|
|
|
|
"Call the function `org-lparse'.
|
|
|
|
This function can be used in batch processing as:
|
|
|
|
emacs --batch
|
|
|
|
--load=$HOME/lib/emacs/org.el
|
|
|
|
--eval \"(setq org-export-headline-levels 2)\"
|
|
|
|
--visit=MyFile --funcall org-lparse-batch"
|
|
|
|
(setq native-backend (or native-backend target-backend))
|
|
|
|
(org-lparse target-backend native-backend
|
|
|
|
org-export-headline-levels 'hidden))
|
|
|
|
|
|
|
|
(defun org-lparse-to-buffer (backend arg)
|
2011-07-02 18:37:29 -04:00
|
|
|
"Call `org-lparse' with output to a temporary buffer.
|
|
|
|
No file is created. The prefix ARG is passed through to
|
|
|
|
`org-lparse'."
|
2011-07-01 05:12:19 -04:00
|
|
|
(let ((tempbuf (format "*Org %s Export*" (upcase backend))))
|
2012-08-11 13:10:44 -04:00
|
|
|
(org-lparse backend backend arg nil nil tempbuf)
|
|
|
|
(when org-export-show-temporary-export-buffer
|
|
|
|
(switch-to-buffer-other-window tempbuf))))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-replace-region-by (backend beg end)
|
|
|
|
"Assume the current region has org-mode syntax, and convert it to HTML.
|
|
|
|
This can be used in any buffer. For example, you could write an
|
2011-08-18 12:38:05 -04:00
|
|
|
itemized list in org-mode syntax in an HTML buffer and then use
|
|
|
|
this command to convert it."
|
2011-07-01 05:12:19 -04:00
|
|
|
(let (reg backend-string buf pop-up-frames)
|
|
|
|
(save-window-excursion
|
Use (derived-mode-p 'org-mode) instead of (eq major-mode 'org-mode).
* org.el (org-show-hierarchy-above, org-cycle)
(org-global-cycle, org-files-list, org-store-link)
(org-link-search, org-open-file, org-display-outline-path)
(org-refile-get-location, org-update-all-dblocks)
(org-change-tag-in-region, org-entry-properties)
(org-save-all-org-buffers, org-revert-all-org-buffers)
(org-buffer-list, org-cdlatex-mode)
(org-install-agenda-files-menu, org-end-of-subtree)
(org-speedbar-set-agenda-restriction): Use (derived-mode-p
'org-mode) instead of (eq major-mode 'org-mode).
* org-timer.el (org-timer-set-timer): Ditto.
* org-table.el (orgtbl-mode, org-table-align, orgtbl-mode): Ditto.
* org-src.el (org-edit-src-exit, org-edit-src-code)
(org-edit-fixed-width-region, org-edit-src-exit): Ditto.
* org-remember.el (org-remember-handler): Ditto.
* org-mouse.el (dnd-open-file, org-mouse-insert-item): Ditto.
* org-macs.el (org-get-limited-outline-regexp): Ditto.
* org-lparse.el (org-replace-region-by): Ditto.
* org-latex.el (org-latex-to-pdf-process)
(org-replace-region-by-latex): Ditto.
* org-indent.el (org-indent-indent-buffer): Ditto.
* org-id.el (org-id-store-link, org-id-update-id-locations)
(org-id-store-link): Ditto.
* org-html.el (org-export-html-preprocess)
(org-replace-region-by-html): Ditto.
* org-footnote.el (org-footnote-normalize)
(org-footnote-goto-definition)
(org-footnote-create-definition, org-footnote-normalize): Ditto.
* org-docbook.el (org-replace-region-by-docbook): Ditto.
* org-ctags.el (find-tag): Ditto.
* org-colview.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-colview-xemacs.el (org-columns-redo)
(org-columns-display-here, org-columns-edit-value)
(org-columns-redo): Ditto.
* org-capture.el (org-capture-insert-template-here)
(org-capture, org-capture-finalize)
(org-capture-set-target-location)
(org-capture-insert-template-here): Ditto.
* org-ascii.el (org-replace-region-by-ascii): Ditto.
* org-archive.el (org-archive-subtree): Ditto.
* org-agenda.el (org-agenda)
(org-agenda-get-restriction-and-command)
(org-agenda-get-some-entry-text, org-search-view)
(org-tags-view, org-agenda-get-day-entries)
(org-agenda-format-item, org-agenda-goto, org-agenda-kill)
(org-agenda-archive-with, org-agenda-switch-to): Ditto.
2012-04-20 14:03:45 -04:00
|
|
|
(if (derived-mode-p 'org-mode)
|
2011-07-01 05:12:19 -04:00
|
|
|
(setq backend-string (org-lparse-region backend beg end t 'string))
|
|
|
|
(setq reg (buffer-substring beg end)
|
|
|
|
buf (get-buffer-create "*Org tmp*"))
|
|
|
|
(with-current-buffer buf
|
|
|
|
(erase-buffer)
|
|
|
|
(insert reg)
|
|
|
|
(org-mode)
|
|
|
|
(setq backend-string (org-lparse-region backend (point-min)
|
|
|
|
(point-max) t 'string)))
|
|
|
|
(kill-buffer buf)))
|
|
|
|
(delete-region beg end)
|
|
|
|
(insert backend-string)))
|
|
|
|
|
|
|
|
(defun org-lparse-region (backend beg end &optional body-only buffer)
|
|
|
|
"Convert region from BEG to END in org-mode buffer to HTML.
|
|
|
|
If prefix arg BODY-ONLY is set, omit file header, footer, and table of
|
|
|
|
contents, and only produce the region of converted text, useful for
|
|
|
|
cut-and-paste operations.
|
|
|
|
If BUFFER is a buffer or a string, use/create that buffer as a target
|
|
|
|
of the converted HTML. If BUFFER is the symbol `string', return the
|
|
|
|
produced HTML as a string and leave not buffer behind. For example,
|
|
|
|
a Lisp program could call this function in the following way:
|
|
|
|
|
|
|
|
(setq html (org-lparse-region \"html\" beg end t 'string))
|
|
|
|
|
|
|
|
When called interactively, the output buffer is selected, and shown
|
|
|
|
in a window. A non-interactive call will only return the buffer."
|
|
|
|
(let ((transient-mark-mode t) (zmacs-regions t)
|
|
|
|
ext-plist rtn)
|
|
|
|
(setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
|
|
|
|
(goto-char end)
|
|
|
|
(set-mark (point)) ;; to activate the region
|
|
|
|
(goto-char beg)
|
|
|
|
(setq rtn (org-lparse backend backend nil nil ext-plist buffer body-only))
|
|
|
|
(if (fboundp 'deactivate-mark) (deactivate-mark))
|
|
|
|
(if (and (org-called-interactively-p 'any) (bufferp rtn))
|
|
|
|
(switch-to-buffer-other-window rtn)
|
|
|
|
rtn)))
|
|
|
|
|
|
|
|
(defvar org-lparse-par-open nil)
|
|
|
|
|
|
|
|
(defun org-lparse-should-inline-p (filename descp)
|
2012-08-11 13:10:44 -04:00
|
|
|
"Return non-nil if link FILENAME should be inlined.
|
2011-07-01 05:12:19 -04:00
|
|
|
The decision to inline the FILENAME link is based on the current
|
|
|
|
settings. DESCP is the boolean of whether there was a link
|
|
|
|
description. See variables `org-export-html-inline-images' and
|
|
|
|
`org-export-html-inline-image-extensions'."
|
2012-08-11 13:10:44 -04:00
|
|
|
(let ((inline-images (org-lparse-get 'INLINE-IMAGES))
|
|
|
|
(inline-image-extensions
|
|
|
|
(org-lparse-get 'INLINE-IMAGE-EXTENSIONS)))
|
|
|
|
(and (or (eq t inline-images) (and inline-images (not descp)))
|
|
|
|
(org-file-image-p filename inline-image-extensions))))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-lparse-format-org-link (line opt-plist)
|
|
|
|
"Return LINE with markup of Org mode links.
|
|
|
|
OPT-PLIST is the export options list."
|
|
|
|
(let ((start 0)
|
|
|
|
(current-dir (if buffer-file-name
|
|
|
|
(file-name-directory buffer-file-name)
|
|
|
|
default-directory))
|
|
|
|
(link-validate (plist-get opt-plist :link-validation-function))
|
|
|
|
type id-file fnc
|
|
|
|
rpl path attr desc descp desc1 desc2 link
|
|
|
|
org-lparse-link-description-is-image)
|
|
|
|
(while (string-match org-bracket-link-analytic-regexp++ line start)
|
|
|
|
(setq org-lparse-link-description-is-image nil)
|
|
|
|
(setq start (match-beginning 0))
|
|
|
|
(setq path (save-match-data (org-link-unescape
|
|
|
|
(match-string 3 line))))
|
|
|
|
(setq type (cond
|
|
|
|
((match-end 2) (match-string 2 line))
|
|
|
|
((save-match-data
|
|
|
|
(or (file-name-absolute-p path)
|
|
|
|
(string-match "^\\.\\.?/" path)))
|
|
|
|
"file")
|
|
|
|
(t "internal")))
|
2011-09-11 10:57:01 -04:00
|
|
|
(setq path (org-extract-attributes path))
|
2011-07-01 05:12:19 -04:00
|
|
|
(setq attr (get-text-property 0 'org-attributes path))
|
|
|
|
(setq desc1 (if (match-end 5) (match-string 5 line))
|
|
|
|
desc2 (if (match-end 2) (concat type ":" path) path)
|
|
|
|
descp (and desc1 (not (equal desc1 desc2)))
|
|
|
|
desc (or desc1 desc2))
|
|
|
|
;; Make an image out of the description if that is so wanted
|
|
|
|
(when (and descp (org-file-image-p
|
|
|
|
desc (org-lparse-get 'INLINE-IMAGE-EXTENSIONS)))
|
|
|
|
(setq org-lparse-link-description-is-image t)
|
|
|
|
(save-match-data
|
|
|
|
(if (string-match "^file:" desc)
|
|
|
|
(setq desc (substring desc (match-end 0)))))
|
|
|
|
(save-match-data
|
|
|
|
(setq desc (org-add-props
|
|
|
|
(org-lparse-format 'INLINE-IMAGE desc)
|
|
|
|
'(org-protected t)))))
|
|
|
|
(cond
|
|
|
|
((equal type "internal")
|
|
|
|
(let
|
|
|
|
((frag-0
|
|
|
|
(if (= (string-to-char path) ?#)
|
|
|
|
(substring path 1)
|
|
|
|
path)))
|
|
|
|
(setq rpl
|
|
|
|
(org-lparse-format
|
|
|
|
'ORG-LINK opt-plist "" "" (org-solidify-link-text
|
|
|
|
(save-match-data
|
|
|
|
(org-link-unescape frag-0))
|
|
|
|
nil) desc attr descp))))
|
|
|
|
((and (equal type "id")
|
|
|
|
(setq id-file (org-id-find-id-file path)))
|
|
|
|
;; This is an id: link to another file (if it was the same file,
|
|
|
|
;; it would have become an internal link...)
|
|
|
|
(save-match-data
|
|
|
|
(setq id-file (file-relative-name
|
|
|
|
id-file
|
|
|
|
(file-name-directory org-current-export-file)))
|
|
|
|
(setq rpl
|
|
|
|
(org-lparse-format
|
|
|
|
'ORG-LINK opt-plist type id-file
|
|
|
|
(concat (if (org-uuidgen-p path) "ID-") path)
|
|
|
|
desc attr descp))))
|
|
|
|
((member type '("http" "https"))
|
|
|
|
;; standard URL, can inline as image
|
|
|
|
(setq rpl
|
|
|
|
(org-lparse-format
|
|
|
|
'ORG-LINK opt-plist type path nil desc attr descp)))
|
|
|
|
((member type '("ftp" "mailto" "news"))
|
|
|
|
;; standard URL, can't inline as image
|
|
|
|
(setq rpl
|
|
|
|
(org-lparse-format
|
|
|
|
'ORG-LINK opt-plist type path nil desc attr descp)))
|
|
|
|
|
|
|
|
((string= type "coderef")
|
2011-10-07 05:24:17 -04:00
|
|
|
(setq rpl (org-lparse-format
|
|
|
|
'ORG-LINK opt-plist type "" path desc nil descp)))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
|
|
|
|
;; The link protocol has a function for format the link
|
2011-11-12 16:03:35 -05:00
|
|
|
(setq rpl (save-match-data
|
|
|
|
(funcall fnc (org-link-unescape path)
|
2011-12-10 10:09:07 -05:00
|
|
|
desc1 (and (boundp 'org-lparse-backend)
|
|
|
|
(case org-lparse-backend
|
|
|
|
(xhtml 'html)
|
|
|
|
(t org-lparse-backend)))))))
|
2011-07-01 05:12:19 -04:00
|
|
|
((string= type "file")
|
|
|
|
;; FILE link
|
|
|
|
(save-match-data
|
|
|
|
(let*
|
|
|
|
((components
|
|
|
|
(if
|
|
|
|
(string-match "::\\(.*\\)" path)
|
|
|
|
(list
|
|
|
|
(replace-match "" t nil path)
|
|
|
|
(match-string 1 path))
|
|
|
|
(list path nil)))
|
|
|
|
|
|
|
|
;;The proper path, without a fragment
|
|
|
|
(path-1
|
|
|
|
(first components))
|
|
|
|
|
|
|
|
;;The raw fragment
|
|
|
|
(fragment-0
|
|
|
|
(second components))
|
|
|
|
|
|
|
|
;;Check the fragment. If it can't be used as
|
|
|
|
;;target fragment we'll pass nil instead.
|
|
|
|
(fragment-1
|
|
|
|
(if
|
|
|
|
(and fragment-0
|
|
|
|
(not (string-match "^[0-9]*$" fragment-0))
|
|
|
|
(not (string-match "^\\*" fragment-0))
|
|
|
|
(not (string-match "^/.*/$" fragment-0)))
|
|
|
|
(org-solidify-link-text
|
|
|
|
(org-link-unescape fragment-0))
|
|
|
|
nil))
|
|
|
|
(desc-2
|
|
|
|
;;Description minus "file:" and ".org"
|
|
|
|
(if (string-match "^file:" desc)
|
|
|
|
(let
|
|
|
|
((desc-1 (replace-match "" t t desc)))
|
|
|
|
(if (string-match "\\.org$" desc-1)
|
|
|
|
(replace-match "" t t desc-1)
|
|
|
|
desc-1))
|
|
|
|
desc)))
|
|
|
|
|
|
|
|
(setq rpl
|
|
|
|
(if
|
|
|
|
(and
|
|
|
|
(functionp link-validate)
|
|
|
|
(not (funcall link-validate path-1 current-dir)))
|
|
|
|
desc
|
|
|
|
(org-lparse-format
|
|
|
|
'ORG-LINK opt-plist "file" path-1 fragment-1
|
|
|
|
desc-2 attr descp))))))
|
|
|
|
|
|
|
|
(t
|
|
|
|
;; just publish the path, as default
|
|
|
|
(setq rpl (concat "<i><" type ":"
|
|
|
|
(save-match-data (org-link-unescape path))
|
|
|
|
"></i>"))))
|
|
|
|
(setq line (replace-match rpl t t line)
|
|
|
|
start (+ start (length rpl))))
|
|
|
|
line))
|
|
|
|
|
2011-10-28 18:12:30 -04:00
|
|
|
(defvar org-lparse-par-open-stashed) ; bound during `org-do-lparse'
|
|
|
|
(defun org-lparse-stash-save-paragraph-state ()
|
|
|
|
(assert (zerop org-lparse-par-open-stashed))
|
|
|
|
(setq org-lparse-par-open-stashed org-lparse-par-open)
|
|
|
|
(setq org-lparse-par-open nil))
|
|
|
|
|
|
|
|
(defun org-lparse-stash-pop-paragraph-state ()
|
|
|
|
(setq org-lparse-par-open org-lparse-par-open-stashed)
|
|
|
|
(setq org-lparse-par-open-stashed 0))
|
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
(defmacro with-org-lparse-preserve-paragraph-state (&rest body)
|
|
|
|
`(let ((org-lparse-do-open-par org-lparse-par-open))
|
|
|
|
(org-lparse-end-paragraph)
|
|
|
|
,@body
|
|
|
|
(when org-lparse-do-open-par
|
|
|
|
(org-lparse-begin-paragraph))))
|
2011-08-28 10:03:38 -04:00
|
|
|
(def-edebug-spec with-org-lparse-preserve-paragraph-state (body))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-07-08 16:02:34 -04:00
|
|
|
(defvar org-lparse-native-backends nil
|
2011-07-01 05:12:19 -04:00
|
|
|
"List of native backends registered with `org-lparse'.
|
2011-07-08 16:02:34 -04:00
|
|
|
A backend can use `org-lparse-register-backend' to add itself to
|
|
|
|
this list.
|
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
All native backends must implement a get routine and a mandatory
|
|
|
|
set of callback routines.
|
|
|
|
|
|
|
|
The get routine must be named as org-<backend>-get where backend
|
|
|
|
is the name of the backend. The exporter uses `org-lparse-get'
|
|
|
|
and retrieves the backend-specific callback by querying for
|
|
|
|
ENTITY-CONTROL and ENTITY-FORMAT variables.
|
|
|
|
|
|
|
|
For the sake of illustration, the html backend implements
|
|
|
|
`org-xhtml-get'. It returns
|
|
|
|
`org-xhtml-entity-control-callbacks-alist' and
|
|
|
|
`org-xhtml-entity-format-callbacks-alist' as the values of
|
|
|
|
ENTITY-CONTROL and ENTITY-FORMAT settings.")
|
|
|
|
|
2011-07-08 16:02:34 -04:00
|
|
|
(defun org-lparse-register-backend (backend)
|
2011-08-04 16:31:19 -04:00
|
|
|
"Make BACKEND known to `org-lparse' library.
|
2011-07-08 16:02:34 -04:00
|
|
|
Add BACKEND to `org-lparse-native-backends'."
|
|
|
|
(when backend
|
|
|
|
(setq backend (cond
|
|
|
|
((symbolp backend) (symbol-name backend))
|
|
|
|
((stringp backend) backend)
|
|
|
|
(t (error "Error while registering backend: %S" backend))))
|
|
|
|
(add-to-list 'org-lparse-native-backends backend)))
|
|
|
|
|
2011-08-02 05:21:09 -04:00
|
|
|
(defun org-lparse-unregister-backend (backend)
|
|
|
|
(setq org-lparse-native-backends
|
|
|
|
(remove (cond
|
|
|
|
((symbolp backend) (symbol-name backend))
|
|
|
|
((stringp backend) backend))
|
|
|
|
org-lparse-native-backends))
|
|
|
|
(message "Unregistered backend %S" backend))
|
|
|
|
|
2011-10-24 14:53:42 -04:00
|
|
|
(defun org-lparse-do-reachable-formats (in-fmt)
|
|
|
|
"Return verbose info about formats to which IN-FMT can be converted.
|
|
|
|
Return a list where each element is of the
|
|
|
|
form (CONVERTER-PROCESS . OUTPUT-FMT-ALIST). See
|
|
|
|
`org-export-odt-convert-processes' for CONVERTER-PROCESS and see
|
|
|
|
`org-export-odt-convert-capabilities' for OUTPUT-FMT-ALIST."
|
|
|
|
(let (reachable-formats)
|
|
|
|
(dolist (backend org-lparse-native-backends reachable-formats)
|
|
|
|
(let* ((converter (org-lparse-backend-get
|
|
|
|
backend 'CONVERT-METHOD))
|
|
|
|
(capabilities (org-lparse-backend-get
|
|
|
|
backend 'CONVERT-CAPABILITIES)))
|
|
|
|
(when converter
|
|
|
|
(dolist (c capabilities)
|
2011-08-04 16:31:19 -04:00
|
|
|
(when (member in-fmt (nth 1 c))
|
2011-10-24 14:53:42 -04:00
|
|
|
(push (cons converter (nth 2 c)) reachable-formats))))))))
|
|
|
|
|
|
|
|
(defun org-lparse-reachable-formats (in-fmt)
|
|
|
|
"Return list of formats to which IN-FMT can be converted.
|
|
|
|
The list of the form (OUTPUT-FMT-1 OUTPUT-FMT-2 ...)."
|
|
|
|
(let (l)
|
|
|
|
(mapc (lambda (e) (add-to-list 'l e))
|
|
|
|
(apply 'append (mapcar
|
|
|
|
(lambda (e) (mapcar 'car (cdr e)))
|
|
|
|
(org-lparse-do-reachable-formats in-fmt))))
|
|
|
|
l))
|
|
|
|
|
|
|
|
(defun org-lparse-reachable-p (in-fmt out-fmt)
|
|
|
|
"Return non-nil if IN-FMT can be converted to OUT-FMT."
|
|
|
|
(catch 'done
|
|
|
|
(let ((reachable-formats (org-lparse-do-reachable-formats in-fmt)))
|
|
|
|
(dolist (e reachable-formats)
|
|
|
|
(let ((out-fmt-spec (assoc out-fmt (cdr e))))
|
|
|
|
(when out-fmt-spec
|
|
|
|
(throw 'done (cons (car e) out-fmt-spec))))))))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-lparse-backend-is-native-p (backend)
|
|
|
|
(member backend org-lparse-native-backends))
|
|
|
|
|
|
|
|
(defun org-lparse (target-backend native-backend arg
|
|
|
|
&optional hidden ext-plist
|
|
|
|
to-buffer body-only pub-dir)
|
|
|
|
"Export the outline to various formats.
|
2011-08-18 12:38:05 -04:00
|
|
|
If there is an active region, export only the region. The
|
|
|
|
outline is first exported to NATIVE-BACKEND and optionally
|
|
|
|
converted to TARGET-BACKEND. See `org-lparse-native-backends'
|
|
|
|
for list of known native backends. Each native backend can
|
|
|
|
specify a converter and list of target backends it exports to
|
|
|
|
using the CONVERT-PROCESS and OTHER-BACKENDS settings of it's get
|
|
|
|
method. See `org-xhtml-get' for an illustrative example.
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
ARG is a prefix argument that specifies how many levels of
|
|
|
|
outline should become headlines. The default is 3. Lower levels
|
|
|
|
will become bulleted lists.
|
|
|
|
|
|
|
|
HIDDEN is obsolete and does nothing.
|
|
|
|
|
|
|
|
EXT-PLIST is a property list that controls various aspects of
|
2011-08-18 12:38:05 -04:00
|
|
|
export. The settings here override org-mode's default settings
|
2011-07-01 05:12:19 -04:00
|
|
|
and but are inferior to file-local settings.
|
|
|
|
|
|
|
|
TO-BUFFER dumps the exported lines to a buffer or a string
|
2011-08-18 12:38:05 -04:00
|
|
|
instead of a file. If TO-BUFFER is the symbol `string' return the
|
2011-07-01 05:12:19 -04:00
|
|
|
exported lines as a string. If TO-BUFFER is non-nil, create a
|
|
|
|
buffer with that name and export to that buffer.
|
|
|
|
|
|
|
|
BODY-ONLY controls the presence of header and footer lines in
|
2011-08-18 12:38:05 -04:00
|
|
|
exported text. If BODY-ONLY is non-nil, don't produce the file
|
2011-07-01 05:12:19 -04:00
|
|
|
header and footer, simply return the content of <body>...</body>,
|
|
|
|
without even the body tags themselves.
|
|
|
|
|
|
|
|
PUB-DIR specifies the publishing directory."
|
|
|
|
(let* ((org-lparse-backend (intern native-backend))
|
2011-08-04 16:31:19 -04:00
|
|
|
(org-lparse-other-backend (and target-backend
|
|
|
|
(intern target-backend))))
|
2012-09-27 18:12:53 -04:00
|
|
|
(add-hook 'org-export-preprocess-hook
|
|
|
|
'org-lparse-strip-experimental-blocks-maybe)
|
|
|
|
(add-hook 'org-export-preprocess-after-blockquote-hook
|
|
|
|
'org-lparse-preprocess-after-blockquote)
|
2011-07-01 05:12:19 -04:00
|
|
|
(unless (org-lparse-backend-is-native-p native-backend)
|
|
|
|
(error "Don't know how to export natively to backend %s" native-backend))
|
2011-10-24 14:53:42 -04:00
|
|
|
|
|
|
|
(unless (or (equal native-backend target-backend)
|
|
|
|
(org-lparse-reachable-p native-backend target-backend))
|
2011-07-01 05:12:19 -04:00
|
|
|
(error "Don't know how to export to backend %s %s" target-backend
|
|
|
|
(format "via %s" native-backend)))
|
|
|
|
(run-hooks 'org-export-first-hook)
|
2012-10-24 09:55:59 -04:00
|
|
|
(prog1
|
|
|
|
(org-do-lparse arg hidden ext-plist to-buffer body-only pub-dir)
|
|
|
|
(remove-hook 'org-export-preprocess-hook
|
|
|
|
'org-lparse-strip-experimental-blocks-maybe)
|
|
|
|
(remove-hook 'org-export-preprocess-after-blockquote-hook
|
|
|
|
'org-lparse-preprocess-after-blockquote))))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-07-08 16:54:00 -04:00
|
|
|
(defcustom org-lparse-use-flashy-warning nil
|
2011-08-04 16:31:19 -04:00
|
|
|
"Control flashing of messages logged with `org-lparse-warn'.
|
|
|
|
When non-nil, messages are fontified with warning face and the
|
|
|
|
exporter lingers for a while to catch user's attention."
|
2011-07-08 06:28:35 -04:00
|
|
|
:type 'boolean
|
2011-08-04 16:31:19 -04:00
|
|
|
:group 'org-lparse)
|
2011-07-08 06:28:35 -04:00
|
|
|
|
2011-10-24 14:53:42 -04:00
|
|
|
(defun org-lparse-convert-read-params ()
|
|
|
|
"Return IN-FILE and OUT-FMT params for `org-lparse-do-convert'.
|
|
|
|
This is a helper routine for interactive use."
|
|
|
|
(let* ((input (if (featurep 'ido) 'ido-completing-read 'completing-read))
|
|
|
|
(in-file (read-file-name "File to be converted: "
|
|
|
|
nil buffer-file-name t))
|
|
|
|
(in-fmt (file-name-extension in-file))
|
|
|
|
(out-fmt-choices (org-lparse-reachable-formats in-fmt))
|
|
|
|
(out-fmt
|
|
|
|
(or (and out-fmt-choices
|
|
|
|
(funcall input "Output format: "
|
|
|
|
out-fmt-choices nil nil nil))
|
|
|
|
(error
|
|
|
|
"No known converter or no known output formats for %s files"
|
|
|
|
in-fmt))))
|
|
|
|
(list in-file out-fmt)))
|
|
|
|
|
2011-12-10 10:09:07 -05:00
|
|
|
(eval-when-compile
|
|
|
|
(require 'browse-url))
|
|
|
|
|
2012-10-24 06:44:22 -04:00
|
|
|
(declare-function browse-url-file-url "browse-url" (file))
|
|
|
|
|
2011-10-24 14:53:42 -04:00
|
|
|
(defun org-lparse-do-convert (in-file out-fmt &optional prefix-arg)
|
|
|
|
"Workhorse routine for `org-export-odt-convert'."
|
2011-07-01 05:12:19 -04:00
|
|
|
(require 'browse-url)
|
|
|
|
(let* ((in-file (expand-file-name (or in-file buffer-file-name)))
|
2011-08-04 16:31:19 -04:00
|
|
|
(dummy (or (file-readable-p in-file)
|
|
|
|
(error "Cannot read %s" in-file)))
|
|
|
|
(in-fmt (file-name-extension in-file))
|
|
|
|
(out-fmt (or out-fmt (error "Output format unspecified")))
|
2011-10-24 14:53:42 -04:00
|
|
|
(how (or (org-lparse-reachable-p in-fmt out-fmt)
|
|
|
|
(error "Cannot convert from %s format to %s format?"
|
|
|
|
in-fmt out-fmt)))
|
|
|
|
(convert-process (car how))
|
2011-08-04 16:31:19 -04:00
|
|
|
(out-file (concat (file-name-sans-extension in-file) "."
|
2011-10-24 14:53:42 -04:00
|
|
|
(nth 1 (or (cdr how) out-fmt))))
|
Pull up ODT files from "maint" to "master" levels
2012-01-17 Jambunathan K <kjambunathan@gmail.com>
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
Add support for indented tables in ODT export
2012-01-20 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-textbox): Honor user-specified
width in captioned images.
Fix for bug reported here:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00641.html
Honor user-specified width in captioned images
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-table-style-format): New. Template for
auto-generated table styles.
(org-odt-automatic-styles, org-odt-object-counters): New
variables.
(org-odt-add-automatic-style): New function.
(org-odt-write-automatic-styles): New function. Create
automatic styles for tables that have custom :rel-width.
(org-odt-begin-table): Parse attributes specified with
"#+ATTR_ODT: " option and use it to create an automatic table
style.
(org-odt-save-as-outfile): Call
`org-odt-add-write-automatic-styles'.
(org-odt-init-outfile): Init newly add variables.
(org-odt-section-count): Remove it.
(org-odt-begin-section): Use `org-odt-add-automatic-style' to
generate an automatic section name.
Customize table width using :rel-width option. For example,
to create a table of width 60% use:
#+attr_odt: :rel-width 60
| A | B |
|---+---|
| | |
org-odt.el: Put table width under user-control
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-label-styles): Add a new style.
(org-odt-category-map-alist): Use it.
Andreas Leha writes:
The following snippet exports correctly to LaTeX and to html, but
produces the text "Figure Figure" in odt.
Could the behaviour be synchronized?
=== example.org ==========================
* Test ref
plot(1:10, 1:10)
Here is a reference to Figure \ref{fig:bar}
=== example.org ==========================
org-odt.el: Make label references consistent with LaTeX export
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-entity-frame-styles): Add frame params
for images that are anchored as character.
(org-export-odt-format-image): Handle new anchor type
"as-char".
(org-export-odt-default-image-sizes-alist): Misc. change.
(org-export-odt-format-formula): Misc. change.
With this change, one can use the below snippet to produce
images that are laid out side-by-side.
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file foo.png
[[./foo.png]]
#+caption: bar
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file bar.png
[[./bar.png]]
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00677.html.
org-odt.el: Allow images to be anchored as characters
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-format-formula): Use :style
property to specify custom table styles.
Continuation of the earlier commit titled: "Put table width
under user-control".
org-odt.el: Fix regression in typesetting of MathML formulae
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-preamble): Don't insert TOC here.
Delay it till the end of export.
(org-odt-begin-document-body): Make a note of the default
position of TOC in `org-lparse-dyn-first-heading-pos'.
(org-odt-insert-toc): Insert TOC as directed by
[TABLE-OF-CONTENTS] line or at the default position.
(org-odt-end-export): Call `org-odt-insert-toc'.
Fix for the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00974.html
org-odt.el: Honor "[TABLE-OF-CONTENTS]" directive
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix earlier commit
2012-01-30 Jambunathan K <kjambunathan@gmail.com>
* OrgOdtStyles.xml (OrgTitlePage): New page style. Include no
footer. Use "OrgFrontMatterPage" for the following page.
(OrgFrontMatterPage): New page style. Include a footer that
displays page numbers in Roman style. Use mirrored pages.
Use "OrgFrontMatterPage" for the following page.
(OrgPage): New page style. Include a footer that displays
page numbers. Use mirrored pages. Use "OrgPage" for the
following page.
(OrgFirstPage): New page style. Include a footer that
displays page numbers. Right page only. Use "OrgPage" for
the following page.
(Standard): Modify to include a footer that displays page
numbers. Use mirrored pages. Use "Standard" for the
following page.
None of the above page styles have a header.
The newly added page styles are not used as yet.
org-odt.el: By default, include page numbers in the page footer
2012-01-31 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Do `clear-image-cache' before `create-image'
2012-02-03 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-lparse.el (org-lparse-do-convert): Replace
`call-process' with `shell-command-to-string'.
* lisp/org-odt.el (org-export-odt-convert-processes): Add a new
converter which depends solely on LibreOffice and nothing
else.
(org-export-odt-convert-process): Make the above native
converter the default.
Thanks to Giles for introducing the "--convert-to" option of
soffice.exe. The option seems to be a fairly recent
development.
http://imperfectsoftware.blogspot.in/2012/01/one-of-my-less-enjoyable-tasks-is-to.html
With this change, one can export to pdf via odt by a simple
(setq org-export-odt-preferred-output-format "pdf")
There is no need to install additional converters.
org-odt.el: Make LibreOffice the default converter
2012-02-09 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-convert-capabilities): Change the
default value.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00293.html.
Offer "docx" as an option in `org-export-odt-preferred-output-format'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix indentation
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Tag all custom variables with Emacs version
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-convert-processes): Re-define
(org-export-odt-convert-capabilities): Fix an accidental
regression.
* lisp/org-lparse.el (org-lparse-do-convert): Related change.
Simplify definition of `org-export-odt-convert-processes'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
Retire support for BasicODConverter
2012-02-14 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-as-odt-to-buffer)
(org-replace-region-by-odt, org-export-region-as-odt): Remove
these interactive functions. They are of questionable value.
org-odt.el: Remove interactive functions of questionable value
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
Improve converting from ODT to other formats
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-image-size-probe-method)
(org-odt-do-image-size): Use imagemagick preferentially to
determine image sizes.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00288.html
org-odt.el: Use imagemagick to determine image sizes
2012-02-16 Jambunathan K <kjambunathan@gmail.com>
* org.texi (Top, OpenDocument Text export)
(ODT export commands, Extending ODT export)
(Images in ODT export, Tables in ODT export)
(Configuring a document converter): Add or Update.
org.texi: Update ODT section
2012-02-19 23:55:31 -05:00
|
|
|
(extra-options (or (nth 2 (cdr how)) ""))
|
2011-07-01 05:12:19 -04:00
|
|
|
(out-dir (file-name-directory in-file))
|
Pull up ODT files from "maint" to "master" levels
2012-01-17 Jambunathan K <kjambunathan@gmail.com>
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
Add support for indented tables in ODT export
2012-01-20 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-textbox): Honor user-specified
width in captioned images.
Fix for bug reported here:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00641.html
Honor user-specified width in captioned images
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-table-style-format): New. Template for
auto-generated table styles.
(org-odt-automatic-styles, org-odt-object-counters): New
variables.
(org-odt-add-automatic-style): New function.
(org-odt-write-automatic-styles): New function. Create
automatic styles for tables that have custom :rel-width.
(org-odt-begin-table): Parse attributes specified with
"#+ATTR_ODT: " option and use it to create an automatic table
style.
(org-odt-save-as-outfile): Call
`org-odt-add-write-automatic-styles'.
(org-odt-init-outfile): Init newly add variables.
(org-odt-section-count): Remove it.
(org-odt-begin-section): Use `org-odt-add-automatic-style' to
generate an automatic section name.
Customize table width using :rel-width option. For example,
to create a table of width 60% use:
#+attr_odt: :rel-width 60
| A | B |
|---+---|
| | |
org-odt.el: Put table width under user-control
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-label-styles): Add a new style.
(org-odt-category-map-alist): Use it.
Andreas Leha writes:
The following snippet exports correctly to LaTeX and to html, but
produces the text "Figure Figure" in odt.
Could the behaviour be synchronized?
=== example.org ==========================
* Test ref
plot(1:10, 1:10)
Here is a reference to Figure \ref{fig:bar}
=== example.org ==========================
org-odt.el: Make label references consistent with LaTeX export
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-entity-frame-styles): Add frame params
for images that are anchored as character.
(org-export-odt-format-image): Handle new anchor type
"as-char".
(org-export-odt-default-image-sizes-alist): Misc. change.
(org-export-odt-format-formula): Misc. change.
With this change, one can use the below snippet to produce
images that are laid out side-by-side.
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file foo.png
[[./foo.png]]
#+caption: bar
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file bar.png
[[./bar.png]]
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00677.html.
org-odt.el: Allow images to be anchored as characters
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-format-formula): Use :style
property to specify custom table styles.
Continuation of the earlier commit titled: "Put table width
under user-control".
org-odt.el: Fix regression in typesetting of MathML formulae
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-preamble): Don't insert TOC here.
Delay it till the end of export.
(org-odt-begin-document-body): Make a note of the default
position of TOC in `org-lparse-dyn-first-heading-pos'.
(org-odt-insert-toc): Insert TOC as directed by
[TABLE-OF-CONTENTS] line or at the default position.
(org-odt-end-export): Call `org-odt-insert-toc'.
Fix for the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00974.html
org-odt.el: Honor "[TABLE-OF-CONTENTS]" directive
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix earlier commit
2012-01-30 Jambunathan K <kjambunathan@gmail.com>
* OrgOdtStyles.xml (OrgTitlePage): New page style. Include no
footer. Use "OrgFrontMatterPage" for the following page.
(OrgFrontMatterPage): New page style. Include a footer that
displays page numbers in Roman style. Use mirrored pages.
Use "OrgFrontMatterPage" for the following page.
(OrgPage): New page style. Include a footer that displays
page numbers. Use mirrored pages. Use "OrgPage" for the
following page.
(OrgFirstPage): New page style. Include a footer that
displays page numbers. Right page only. Use "OrgPage" for
the following page.
(Standard): Modify to include a footer that displays page
numbers. Use mirrored pages. Use "Standard" for the
following page.
None of the above page styles have a header.
The newly added page styles are not used as yet.
org-odt.el: By default, include page numbers in the page footer
2012-01-31 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Do `clear-image-cache' before `create-image'
2012-02-03 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-lparse.el (org-lparse-do-convert): Replace
`call-process' with `shell-command-to-string'.
* lisp/org-odt.el (org-export-odt-convert-processes): Add a new
converter which depends solely on LibreOffice and nothing
else.
(org-export-odt-convert-process): Make the above native
converter the default.
Thanks to Giles for introducing the "--convert-to" option of
soffice.exe. The option seems to be a fairly recent
development.
http://imperfectsoftware.blogspot.in/2012/01/one-of-my-less-enjoyable-tasks-is-to.html
With this change, one can export to pdf via odt by a simple
(setq org-export-odt-preferred-output-format "pdf")
There is no need to install additional converters.
org-odt.el: Make LibreOffice the default converter
2012-02-09 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-convert-capabilities): Change the
default value.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00293.html.
Offer "docx" as an option in `org-export-odt-preferred-output-format'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix indentation
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Tag all custom variables with Emacs version
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-convert-processes): Re-define
(org-export-odt-convert-capabilities): Fix an accidental
regression.
* lisp/org-lparse.el (org-lparse-do-convert): Related change.
Simplify definition of `org-export-odt-convert-processes'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
Retire support for BasicODConverter
2012-02-14 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-as-odt-to-buffer)
(org-replace-region-by-odt, org-export-region-as-odt): Remove
these interactive functions. They are of questionable value.
org-odt.el: Remove interactive functions of questionable value
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
Improve converting from ODT to other formats
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-image-size-probe-method)
(org-odt-do-image-size): Use imagemagick preferentially to
determine image sizes.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00288.html
org-odt.el: Use imagemagick to determine image sizes
2012-02-16 Jambunathan K <kjambunathan@gmail.com>
* org.texi (Top, OpenDocument Text export)
(ODT export commands, Extending ODT export)
(Images in ODT export, Tables in ODT export)
(Configuring a document converter): Add or Update.
org.texi: Update ODT section
2012-02-19 23:55:31 -05:00
|
|
|
(cmd (format-spec convert-process
|
|
|
|
`((?i . ,(shell-quote-argument in-file))
|
|
|
|
(?I . ,(browse-url-file-url in-file))
|
|
|
|
(?f . ,out-fmt)
|
|
|
|
(?o . ,out-file)
|
|
|
|
(?O . ,(browse-url-file-url out-file))
|
|
|
|
(?d . , (shell-quote-argument out-dir))
|
|
|
|
(?D . ,(browse-url-file-url out-dir))
|
|
|
|
(?x . ,extra-options)))))
|
2011-08-04 16:31:19 -04:00
|
|
|
(when (file-exists-p out-file)
|
|
|
|
(delete-file out-file))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
Pull up ODT files from "maint" to "master" levels
2012-01-17 Jambunathan K <kjambunathan@gmail.com>
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
Add support for indented tables in ODT export
2012-01-20 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-textbox): Honor user-specified
width in captioned images.
Fix for bug reported here:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00641.html
Honor user-specified width in captioned images
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-table-style-format): New. Template for
auto-generated table styles.
(org-odt-automatic-styles, org-odt-object-counters): New
variables.
(org-odt-add-automatic-style): New function.
(org-odt-write-automatic-styles): New function. Create
automatic styles for tables that have custom :rel-width.
(org-odt-begin-table): Parse attributes specified with
"#+ATTR_ODT: " option and use it to create an automatic table
style.
(org-odt-save-as-outfile): Call
`org-odt-add-write-automatic-styles'.
(org-odt-init-outfile): Init newly add variables.
(org-odt-section-count): Remove it.
(org-odt-begin-section): Use `org-odt-add-automatic-style' to
generate an automatic section name.
Customize table width using :rel-width option. For example,
to create a table of width 60% use:
#+attr_odt: :rel-width 60
| A | B |
|---+---|
| | |
org-odt.el: Put table width under user-control
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-label-styles): Add a new style.
(org-odt-category-map-alist): Use it.
Andreas Leha writes:
The following snippet exports correctly to LaTeX and to html, but
produces the text "Figure Figure" in odt.
Could the behaviour be synchronized?
=== example.org ==========================
* Test ref
plot(1:10, 1:10)
Here is a reference to Figure \ref{fig:bar}
=== example.org ==========================
org-odt.el: Make label references consistent with LaTeX export
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-entity-frame-styles): Add frame params
for images that are anchored as character.
(org-export-odt-format-image): Handle new anchor type
"as-char".
(org-export-odt-default-image-sizes-alist): Misc. change.
(org-export-odt-format-formula): Misc. change.
With this change, one can use the below snippet to produce
images that are laid out side-by-side.
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file foo.png
[[./foo.png]]
#+caption: bar
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file bar.png
[[./bar.png]]
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00677.html.
org-odt.el: Allow images to be anchored as characters
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-format-formula): Use :style
property to specify custom table styles.
Continuation of the earlier commit titled: "Put table width
under user-control".
org-odt.el: Fix regression in typesetting of MathML formulae
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-preamble): Don't insert TOC here.
Delay it till the end of export.
(org-odt-begin-document-body): Make a note of the default
position of TOC in `org-lparse-dyn-first-heading-pos'.
(org-odt-insert-toc): Insert TOC as directed by
[TABLE-OF-CONTENTS] line or at the default position.
(org-odt-end-export): Call `org-odt-insert-toc'.
Fix for the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00974.html
org-odt.el: Honor "[TABLE-OF-CONTENTS]" directive
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix earlier commit
2012-01-30 Jambunathan K <kjambunathan@gmail.com>
* OrgOdtStyles.xml (OrgTitlePage): New page style. Include no
footer. Use "OrgFrontMatterPage" for the following page.
(OrgFrontMatterPage): New page style. Include a footer that
displays page numbers in Roman style. Use mirrored pages.
Use "OrgFrontMatterPage" for the following page.
(OrgPage): New page style. Include a footer that displays
page numbers. Use mirrored pages. Use "OrgPage" for the
following page.
(OrgFirstPage): New page style. Include a footer that
displays page numbers. Right page only. Use "OrgPage" for
the following page.
(Standard): Modify to include a footer that displays page
numbers. Use mirrored pages. Use "Standard" for the
following page.
None of the above page styles have a header.
The newly added page styles are not used as yet.
org-odt.el: By default, include page numbers in the page footer
2012-01-31 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Do `clear-image-cache' before `create-image'
2012-02-03 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-lparse.el (org-lparse-do-convert): Replace
`call-process' with `shell-command-to-string'.
* lisp/org-odt.el (org-export-odt-convert-processes): Add a new
converter which depends solely on LibreOffice and nothing
else.
(org-export-odt-convert-process): Make the above native
converter the default.
Thanks to Giles for introducing the "--convert-to" option of
soffice.exe. The option seems to be a fairly recent
development.
http://imperfectsoftware.blogspot.in/2012/01/one-of-my-less-enjoyable-tasks-is-to.html
With this change, one can export to pdf via odt by a simple
(setq org-export-odt-preferred-output-format "pdf")
There is no need to install additional converters.
org-odt.el: Make LibreOffice the default converter
2012-02-09 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-convert-capabilities): Change the
default value.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00293.html.
Offer "docx" as an option in `org-export-odt-preferred-output-format'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix indentation
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Tag all custom variables with Emacs version
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-convert-processes): Re-define
(org-export-odt-convert-capabilities): Fix an accidental
regression.
* lisp/org-lparse.el (org-lparse-do-convert): Related change.
Simplify definition of `org-export-odt-convert-processes'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
Retire support for BasicODConverter
2012-02-14 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-as-odt-to-buffer)
(org-replace-region-by-odt, org-export-region-as-odt): Remove
these interactive functions. They are of questionable value.
org-odt.el: Remove interactive functions of questionable value
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
Improve converting from ODT to other formats
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-image-size-probe-method)
(org-odt-do-image-size): Use imagemagick preferentially to
determine image sizes.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00288.html
org-odt.el: Use imagemagick to determine image sizes
2012-02-16 Jambunathan K <kjambunathan@gmail.com>
* org.texi (Top, OpenDocument Text export)
(ODT export commands, Extending ODT export)
(Images in ODT export, Tables in ODT export)
(Configuring a document converter): Add or Update.
org.texi: Update ODT section
2012-02-19 23:55:31 -05:00
|
|
|
(message "Executing %s" cmd)
|
|
|
|
(let ((cmd-output (shell-command-to-string cmd)))
|
|
|
|
(message "%s" cmd-output))
|
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
(cond
|
|
|
|
((file-exists-p out-file)
|
Pull up ODT files from "maint" to "master" levels
2012-01-17 Jambunathan K <kjambunathan@gmail.com>
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
Add support for indented tables in ODT export
2012-01-20 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-textbox): Honor user-specified
width in captioned images.
Fix for bug reported here:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00641.html
Honor user-specified width in captioned images
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-table-style-format): New. Template for
auto-generated table styles.
(org-odt-automatic-styles, org-odt-object-counters): New
variables.
(org-odt-add-automatic-style): New function.
(org-odt-write-automatic-styles): New function. Create
automatic styles for tables that have custom :rel-width.
(org-odt-begin-table): Parse attributes specified with
"#+ATTR_ODT: " option and use it to create an automatic table
style.
(org-odt-save-as-outfile): Call
`org-odt-add-write-automatic-styles'.
(org-odt-init-outfile): Init newly add variables.
(org-odt-section-count): Remove it.
(org-odt-begin-section): Use `org-odt-add-automatic-style' to
generate an automatic section name.
Customize table width using :rel-width option. For example,
to create a table of width 60% use:
#+attr_odt: :rel-width 60
| A | B |
|---+---|
| | |
org-odt.el: Put table width under user-control
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-label-styles): Add a new style.
(org-odt-category-map-alist): Use it.
Andreas Leha writes:
The following snippet exports correctly to LaTeX and to html, but
produces the text "Figure Figure" in odt.
Could the behaviour be synchronized?
=== example.org ==========================
* Test ref
plot(1:10, 1:10)
Here is a reference to Figure \ref{fig:bar}
=== example.org ==========================
org-odt.el: Make label references consistent with LaTeX export
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-entity-frame-styles): Add frame params
for images that are anchored as character.
(org-export-odt-format-image): Handle new anchor type
"as-char".
(org-export-odt-default-image-sizes-alist): Misc. change.
(org-export-odt-format-formula): Misc. change.
With this change, one can use the below snippet to produce
images that are laid out side-by-side.
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file foo.png
[[./foo.png]]
#+caption: bar
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file bar.png
[[./bar.png]]
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00677.html.
org-odt.el: Allow images to be anchored as characters
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-format-formula): Use :style
property to specify custom table styles.
Continuation of the earlier commit titled: "Put table width
under user-control".
org-odt.el: Fix regression in typesetting of MathML formulae
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-preamble): Don't insert TOC here.
Delay it till the end of export.
(org-odt-begin-document-body): Make a note of the default
position of TOC in `org-lparse-dyn-first-heading-pos'.
(org-odt-insert-toc): Insert TOC as directed by
[TABLE-OF-CONTENTS] line or at the default position.
(org-odt-end-export): Call `org-odt-insert-toc'.
Fix for the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00974.html
org-odt.el: Honor "[TABLE-OF-CONTENTS]" directive
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix earlier commit
2012-01-30 Jambunathan K <kjambunathan@gmail.com>
* OrgOdtStyles.xml (OrgTitlePage): New page style. Include no
footer. Use "OrgFrontMatterPage" for the following page.
(OrgFrontMatterPage): New page style. Include a footer that
displays page numbers in Roman style. Use mirrored pages.
Use "OrgFrontMatterPage" for the following page.
(OrgPage): New page style. Include a footer that displays
page numbers. Use mirrored pages. Use "OrgPage" for the
following page.
(OrgFirstPage): New page style. Include a footer that
displays page numbers. Right page only. Use "OrgPage" for
the following page.
(Standard): Modify to include a footer that displays page
numbers. Use mirrored pages. Use "Standard" for the
following page.
None of the above page styles have a header.
The newly added page styles are not used as yet.
org-odt.el: By default, include page numbers in the page footer
2012-01-31 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Do `clear-image-cache' before `create-image'
2012-02-03 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-lparse.el (org-lparse-do-convert): Replace
`call-process' with `shell-command-to-string'.
* lisp/org-odt.el (org-export-odt-convert-processes): Add a new
converter which depends solely on LibreOffice and nothing
else.
(org-export-odt-convert-process): Make the above native
converter the default.
Thanks to Giles for introducing the "--convert-to" option of
soffice.exe. The option seems to be a fairly recent
development.
http://imperfectsoftware.blogspot.in/2012/01/one-of-my-less-enjoyable-tasks-is-to.html
With this change, one can export to pdf via odt by a simple
(setq org-export-odt-preferred-output-format "pdf")
There is no need to install additional converters.
org-odt.el: Make LibreOffice the default converter
2012-02-09 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-convert-capabilities): Change the
default value.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00293.html.
Offer "docx" as an option in `org-export-odt-preferred-output-format'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix indentation
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Tag all custom variables with Emacs version
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-convert-processes): Re-define
(org-export-odt-convert-capabilities): Fix an accidental
regression.
* lisp/org-lparse.el (org-lparse-do-convert): Related change.
Simplify definition of `org-export-odt-convert-processes'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
Retire support for BasicODConverter
2012-02-14 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-as-odt-to-buffer)
(org-replace-region-by-odt, org-export-region-as-odt): Remove
these interactive functions. They are of questionable value.
org-odt.el: Remove interactive functions of questionable value
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
Improve converting from ODT to other formats
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-image-size-probe-method)
(org-odt-do-image-size): Use imagemagick preferentially to
determine image sizes.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00288.html
org-odt.el: Use imagemagick to determine image sizes
2012-02-16 Jambunathan K <kjambunathan@gmail.com>
* org.texi (Top, OpenDocument Text export)
(ODT export commands, Extending ODT export)
(Images in ODT export, Tables in ODT export)
(Configuring a document converter): Add or Update.
org.texi: Update ODT section
2012-02-19 23:55:31 -05:00
|
|
|
(message "Exported to %s" out-file)
|
2011-08-04 16:31:19 -04:00
|
|
|
(when prefix-arg
|
|
|
|
(message "Opening %s..." out-file)
|
2012-09-03 09:59:21 -04:00
|
|
|
(org-open-file out-file 'system))
|
Pull up ODT files from "maint" to "master" levels
2012-01-17 Jambunathan K <kjambunathan@gmail.com>
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
Add support for indented tables in ODT export
2012-01-20 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-textbox): Honor user-specified
width in captioned images.
Fix for bug reported here:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00641.html
Honor user-specified width in captioned images
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-table-style-format): New. Template for
auto-generated table styles.
(org-odt-automatic-styles, org-odt-object-counters): New
variables.
(org-odt-add-automatic-style): New function.
(org-odt-write-automatic-styles): New function. Create
automatic styles for tables that have custom :rel-width.
(org-odt-begin-table): Parse attributes specified with
"#+ATTR_ODT: " option and use it to create an automatic table
style.
(org-odt-save-as-outfile): Call
`org-odt-add-write-automatic-styles'.
(org-odt-init-outfile): Init newly add variables.
(org-odt-section-count): Remove it.
(org-odt-begin-section): Use `org-odt-add-automatic-style' to
generate an automatic section name.
Customize table width using :rel-width option. For example,
to create a table of width 60% use:
#+attr_odt: :rel-width 60
| A | B |
|---+---|
| | |
org-odt.el: Put table width under user-control
2012-01-23 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-label-styles): Add a new style.
(org-odt-category-map-alist): Use it.
Andreas Leha writes:
The following snippet exports correctly to LaTeX and to html, but
produces the text "Figure Figure" in odt.
Could the behaviour be synchronized?
=== example.org ==========================
* Test ref
plot(1:10, 1:10)
Here is a reference to Figure \ref{fig:bar}
=== example.org ==========================
org-odt.el: Make label references consistent with LaTeX export
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-entity-frame-styles): Add frame params
for images that are anchored as character.
(org-export-odt-format-image): Handle new anchor type
"as-char".
(org-export-odt-default-image-sizes-alist): Misc. change.
(org-export-odt-format-formula): Misc. change.
With this change, one can use the below snippet to produce
images that are laid out side-by-side.
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file foo.png
[[./foo.png]]
#+caption: bar
#+ATTR_ODT: :width 7 :height 7 :anchor as-char
#+header: :file bar.png
[[./bar.png]]
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00677.html.
org-odt.el: Allow images to be anchored as characters
2012-01-24 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-format-formula): Use :style
property to specify custom table styles.
Continuation of the earlier commit titled: "Put table width
under user-control".
org-odt.el: Fix regression in typesetting of MathML formulae
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-odt-format-preamble): Don't insert TOC here.
Delay it till the end of export.
(org-odt-begin-document-body): Make a note of the default
position of TOC in `org-lparse-dyn-first-heading-pos'.
(org-odt-insert-toc): Insert TOC as directed by
[TABLE-OF-CONTENTS] line or at the default position.
(org-odt-end-export): Call `org-odt-insert-toc'.
Fix for the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00974.html
org-odt.el: Honor "[TABLE-OF-CONTENTS]" directive
2012-01-27 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix earlier commit
2012-01-30 Jambunathan K <kjambunathan@gmail.com>
* OrgOdtStyles.xml (OrgTitlePage): New page style. Include no
footer. Use "OrgFrontMatterPage" for the following page.
(OrgFrontMatterPage): New page style. Include a footer that
displays page numbers in Roman style. Use mirrored pages.
Use "OrgFrontMatterPage" for the following page.
(OrgPage): New page style. Include a footer that displays
page numbers. Use mirrored pages. Use "OrgPage" for the
following page.
(OrgFirstPage): New page style. Include a footer that
displays page numbers. Right page only. Use "OrgPage" for
the following page.
(Standard): Modify to include a footer that displays page
numbers. Use mirrored pages. Use "Standard" for the
following page.
None of the above page styles have a header.
The newly added page styles are not used as yet.
org-odt.el: By default, include page numbers in the page footer
2012-01-31 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Do `clear-image-cache' before `create-image'
2012-02-03 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-lparse.el (org-lparse-do-convert): Replace
`call-process' with `shell-command-to-string'.
* lisp/org-odt.el (org-export-odt-convert-processes): Add a new
converter which depends solely on LibreOffice and nothing
else.
(org-export-odt-convert-process): Make the above native
converter the default.
Thanks to Giles for introducing the "--convert-to" option of
soffice.exe. The option seems to be a fairly recent
development.
http://imperfectsoftware.blogspot.in/2012/01/one-of-my-less-enjoyable-tasks-is-to.html
With this change, one can export to pdf via odt by a simple
(setq org-export-odt-preferred-output-format "pdf")
There is no need to install additional converters.
org-odt.el: Make LibreOffice the default converter
2012-02-09 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-convert-capabilities): Change the
default value.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00293.html.
Offer "docx" as an option in `org-export-odt-preferred-output-format'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Fix indentation
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
org-odt.el: Tag all custom variables with Emacs version
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
* lisp/org-odt.el (org-export-odt-convert-processes): Re-define
(org-export-odt-convert-capabilities): Fix an accidental
regression.
* lisp/org-lparse.el (org-lparse-do-convert): Related change.
Simplify definition of `org-export-odt-convert-processes'
2012-02-12 Jambunathan K <kjambunathan@gmail.com>
Retire support for BasicODConverter
2012-02-14 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-as-odt-to-buffer)
(org-replace-region-by-odt, org-export-region-as-odt): Remove
these interactive functions. They are of questionable value.
org-odt.el: Remove interactive functions of questionable value
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
Improve converting from ODT to other formats
2012-02-15 Jambunathan K <kjambunathan@gmail.com>
* org-odt.el (org-export-odt-image-size-probe-method)
(org-odt-do-image-size): Use imagemagick preferentially to
determine image sizes.
See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00288.html
org-odt.el: Use imagemagick to determine image sizes
2012-02-16 Jambunathan K <kjambunathan@gmail.com>
* org.texi (Top, OpenDocument Text export)
(ODT export commands, Extending ODT export)
(Images in ODT export, Tables in ODT export)
(Configuring a document converter): Add or Update.
org.texi: Update ODT section
2012-02-19 23:55:31 -05:00
|
|
|
out-file)
|
2011-07-01 05:12:19 -04:00
|
|
|
(t
|
|
|
|
(message "Export to %s failed" out-file)
|
|
|
|
nil))))
|
|
|
|
|
|
|
|
(defvar org-lparse-insert-tag-with-newlines 'both)
|
|
|
|
|
|
|
|
;; Following variables are let-bound during `org-lparse'
|
|
|
|
(defvar org-lparse-dyn-first-heading-pos)
|
|
|
|
(defvar org-lparse-toc)
|
|
|
|
(defvar org-lparse-entity-control-callbacks-alist)
|
|
|
|
(defvar org-lparse-entity-format-callbacks-alist)
|
2011-07-02 18:37:29 -04:00
|
|
|
(defvar org-lparse-backend nil
|
|
|
|
"The native backend to which the document is currently exported.
|
|
|
|
This variable is let bound during `org-lparse'. Valid values are
|
|
|
|
one of the symbols corresponding to `org-lparse-native-backends'.
|
|
|
|
|
|
|
|
Compare this variable with `org-export-current-backend' which is
|
|
|
|
bound only during `org-export-preprocess-string' stage of the
|
|
|
|
export process.
|
|
|
|
|
|
|
|
See also `org-lparse-other-backend'.")
|
|
|
|
|
|
|
|
(defvar org-lparse-other-backend nil
|
|
|
|
"The target backend to which the document is currently exported.
|
|
|
|
This variable is let bound during `org-lparse'. This variable is
|
|
|
|
set to either `org-lparse-backend' or one of the symbols
|
|
|
|
corresponding to OTHER-BACKENDS specification of the
|
|
|
|
org-lparse-backend.
|
|
|
|
|
|
|
|
For example, if a document is exported to \"odt\" then both
|
|
|
|
org-lparse-backend and org-lparse-other-backend are bound to
|
|
|
|
'odt. On the other hand, if a document is exported to \"odt\"
|
|
|
|
and then converted to \"doc\" then org-lparse-backend is set to
|
|
|
|
'odt and org-lparse-other-backend is set to 'doc.")
|
|
|
|
|
|
|
|
(defvar org-lparse-body-only nil
|
|
|
|
"Bind this to BODY-ONLY arg of `org-lparse'.")
|
|
|
|
|
|
|
|
(defvar org-lparse-to-buffer nil
|
|
|
|
"Bind this to TO-BUFFER arg of `org-lparse'.")
|
|
|
|
|
2011-10-28 18:12:30 -04:00
|
|
|
(defun org-lparse-get-block-params (params)
|
|
|
|
(save-match-data
|
|
|
|
(when params
|
|
|
|
(setq params (org-trim params))
|
|
|
|
(unless (string-match "\\`(.*)\\'" params)
|
|
|
|
(setq params (format "(%s)" params)))
|
|
|
|
(ignore-errors (read params)))))
|
|
|
|
|
2011-11-13 03:46:42 -05:00
|
|
|
(defvar org-heading-keyword-regexp-format) ; defined in org.el
|
2011-10-28 18:12:30 -04:00
|
|
|
(defvar org-lparse-special-blocks '("list-table" "annotation"))
|
2011-07-01 05:12:19 -04:00
|
|
|
(defun org-do-lparse (arg &optional hidden ext-plist
|
|
|
|
to-buffer body-only pub-dir)
|
|
|
|
"Export the outline to various formats.
|
2012-08-11 13:10:44 -04:00
|
|
|
See `org-lparse' for more information. This function is a
|
2011-07-01 05:12:19 -04:00
|
|
|
html-agnostic version of the `org-export-as-html' function in 7.5
|
|
|
|
version."
|
|
|
|
;; Make sure we have a file name when we need it.
|
|
|
|
(when (and (not (or to-buffer body-only))
|
|
|
|
(not buffer-file-name))
|
|
|
|
(if (buffer-base-buffer)
|
|
|
|
(org-set-local 'buffer-file-name
|
|
|
|
(with-current-buffer (buffer-base-buffer)
|
|
|
|
buffer-file-name))
|
|
|
|
(error "Need a file name to be able to export")))
|
|
|
|
|
|
|
|
(org-lparse-warn
|
|
|
|
(format "Exporting to %s using org-lparse..."
|
|
|
|
(upcase (symbol-name
|
|
|
|
(or org-lparse-backend org-lparse-other-backend)))))
|
|
|
|
|
|
|
|
(setq-default org-todo-line-regexp org-todo-line-regexp)
|
|
|
|
(setq-default org-deadline-line-regexp org-deadline-line-regexp)
|
|
|
|
(setq-default org-done-keywords org-done-keywords)
|
|
|
|
(setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
|
2011-08-18 10:56:14 -04:00
|
|
|
(let* (hfy-user-sheet-assoc ; let `htmlfontify' know that
|
|
|
|
; we are interested in
|
|
|
|
; collecting styles
|
|
|
|
org-lparse-encode-pending
|
2011-07-01 05:12:19 -04:00
|
|
|
org-lparse-par-open
|
2011-10-28 18:12:30 -04:00
|
|
|
(org-lparse-par-open-stashed 0)
|
2011-09-01 14:11:26 -04:00
|
|
|
|
|
|
|
;; list related vars
|
Add support for indented tables in ODT export
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
2012-01-16 15:55:47 -05:00
|
|
|
(org-lparse-list-stack '())
|
2011-09-01 14:11:26 -04:00
|
|
|
|
|
|
|
;; list-table related vars
|
|
|
|
org-lparse-list-table-p
|
|
|
|
org-lparse-list-table:table-cell-open
|
|
|
|
org-lparse-list-table:table-row
|
|
|
|
org-lparse-list-table:lines
|
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
org-lparse-outline-text-open
|
|
|
|
(org-lparse-latex-fragment-fallback ; currently used only by
|
|
|
|
; odt exporter
|
|
|
|
(or (ignore-errors (org-lparse-get 'LATEX-FRAGMENT-FALLBACK))
|
|
|
|
(if (and (org-check-external-command "latex" "" t)
|
|
|
|
(org-check-external-command "dvipng" "" t))
|
|
|
|
'dvipng
|
|
|
|
'verbatim)))
|
|
|
|
(org-lparse-insert-tag-with-newlines 'both)
|
|
|
|
(org-lparse-to-buffer to-buffer)
|
|
|
|
(org-lparse-body-only body-only)
|
|
|
|
(org-lparse-entity-control-callbacks-alist
|
|
|
|
(org-lparse-get 'ENTITY-CONTROL))
|
|
|
|
(org-lparse-entity-format-callbacks-alist
|
|
|
|
(org-lparse-get 'ENTITY-FORMAT))
|
|
|
|
(opt-plist
|
|
|
|
(org-export-process-option-filters
|
|
|
|
(org-combine-plists (org-default-export-plist)
|
|
|
|
ext-plist
|
|
|
|
(org-infile-export-plist))))
|
|
|
|
(body-only (or body-only (plist-get opt-plist :body-only)))
|
|
|
|
valid org-lparse-dyn-first-heading-pos
|
|
|
|
(odd org-odd-levels-only)
|
|
|
|
(region-p (org-region-active-p))
|
|
|
|
(rbeg (and region-p (region-beginning)))
|
|
|
|
(rend (and region-p (region-end)))
|
|
|
|
(subtree-p
|
|
|
|
(if (plist-get opt-plist :ignore-subtree-p)
|
|
|
|
nil
|
|
|
|
(when region-p
|
|
|
|
(save-excursion
|
|
|
|
(goto-char rbeg)
|
|
|
|
(and (org-at-heading-p)
|
|
|
|
(>= (org-end-of-subtree t t) rend))))))
|
|
|
|
(level-offset (if subtree-p
|
|
|
|
(save-excursion
|
|
|
|
(goto-char rbeg)
|
|
|
|
(+ (funcall outline-level)
|
|
|
|
(if org-odd-levels-only 1 0)))
|
|
|
|
0))
|
|
|
|
(opt-plist (setq org-export-opt-plist
|
|
|
|
(if subtree-p
|
|
|
|
(org-export-add-subtree-options opt-plist rbeg)
|
|
|
|
opt-plist)))
|
|
|
|
;; The following two are dynamically scoped into other
|
|
|
|
;; routines below.
|
|
|
|
(org-current-export-dir
|
|
|
|
(or pub-dir (org-lparse-get 'EXPORT-DIR opt-plist)))
|
|
|
|
(org-current-export-file buffer-file-name)
|
|
|
|
(level 0) (line "") (origline "") txt todo
|
|
|
|
(umax nil)
|
|
|
|
(umax-toc nil)
|
|
|
|
(filename (if to-buffer nil
|
|
|
|
(expand-file-name
|
|
|
|
(concat
|
|
|
|
(file-name-sans-extension
|
|
|
|
(or (and subtree-p
|
|
|
|
(org-entry-get (region-beginning)
|
|
|
|
"EXPORT_FILE_NAME" t))
|
|
|
|
(file-name-nondirectory buffer-file-name)))
|
|
|
|
"." (org-lparse-get 'FILE-NAME-EXTENSION opt-plist))
|
|
|
|
(file-name-as-directory
|
|
|
|
(or pub-dir (org-lparse-get 'EXPORT-DIR opt-plist))))))
|
|
|
|
(current-dir (if buffer-file-name
|
|
|
|
(file-name-directory buffer-file-name)
|
|
|
|
default-directory))
|
2011-11-13 03:46:42 -05:00
|
|
|
(auto-insert nil) ; Avoid any auto-insert stuff for the new file
|
2011-07-01 05:12:19 -04:00
|
|
|
(buffer (if to-buffer
|
|
|
|
(cond
|
|
|
|
((eq to-buffer 'string)
|
|
|
|
(get-buffer-create (org-lparse-get 'EXPORT-BUFFER-NAME)))
|
|
|
|
(t (get-buffer-create to-buffer)))
|
|
|
|
(find-file-noselect
|
|
|
|
(or (let ((f (org-lparse-get 'INIT-METHOD)))
|
|
|
|
(and f (functionp f) (funcall f filename)))
|
|
|
|
filename))))
|
|
|
|
(org-levels-open (make-vector org-level-max nil))
|
2011-11-13 03:46:42 -05:00
|
|
|
(dummy (mapc
|
|
|
|
(lambda(p)
|
|
|
|
(let* ((val (plist-get opt-plist p))
|
|
|
|
(val (org-xml-encode-org-text-skip-links val)))
|
|
|
|
(setq opt-plist (plist-put opt-plist p val))))
|
|
|
|
'(:date :author :keywords :description)))
|
2011-07-01 05:12:19 -04:00
|
|
|
(date (plist-get opt-plist :date))
|
|
|
|
(date (cond
|
|
|
|
((and date (string-match "%" date))
|
|
|
|
(format-time-string date))
|
|
|
|
(date date)
|
|
|
|
(t (format-time-string "%Y-%m-%d %T %Z"))))
|
|
|
|
(dummy (setq opt-plist (plist-put opt-plist :effective-date date)))
|
|
|
|
(title (org-xml-encode-org-text-skip-links
|
|
|
|
(or (and subtree-p (org-export-get-title-from-subtree))
|
|
|
|
(plist-get opt-plist :title)
|
|
|
|
(and (not body-only)
|
|
|
|
(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")))
|
|
|
|
(dummy (setq opt-plist (plist-put opt-plist :title title)))
|
|
|
|
(html-table-tag (plist-get opt-plist :html-table-tag))
|
2011-11-13 03:46:42 -05:00
|
|
|
(quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
|
|
|
|
(quote-re (format org-heading-keyword-regexp-format
|
|
|
|
org-quote-string))
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-dyn-current-environment nil)
|
|
|
|
;; Get the language-dependent settings
|
|
|
|
(lang-words (or (assoc (plist-get opt-plist :language)
|
|
|
|
org-export-language-setup)
|
|
|
|
(assoc "en" org-export-language-setup)))
|
|
|
|
(dummy (setq opt-plist (plist-put opt-plist :lang-words lang-words)))
|
|
|
|
(head-count 0) cnt
|
|
|
|
(start 0)
|
|
|
|
(coding-system-for-write
|
|
|
|
(or (ignore-errors (org-lparse-get 'CODING-SYSTEM-FOR-WRITE))
|
|
|
|
(and (boundp 'buffer-file-coding-system)
|
|
|
|
buffer-file-coding-system)))
|
|
|
|
(save-buffer-coding-system
|
|
|
|
(or (ignore-errors (org-lparse-get 'CODING-SYSTEM-FOR-SAVE))
|
|
|
|
(and (boundp 'buffer-file-coding-system)
|
|
|
|
buffer-file-coding-system)))
|
|
|
|
(region
|
|
|
|
(buffer-substring
|
|
|
|
(if region-p (region-beginning) (point-min))
|
|
|
|
(if region-p (region-end) (point-max))))
|
|
|
|
(org-export-have-math nil)
|
|
|
|
(org-export-footnotes-seen nil)
|
|
|
|
(org-export-footnotes-data (org-footnote-all-labels 'with-defs))
|
|
|
|
(org-footnote-insert-pos-for-preprocessor 'point-min)
|
2011-08-27 10:57:16 -04:00
|
|
|
(org-lparse-opt-plist opt-plist)
|
2011-07-01 05:12:19 -04:00
|
|
|
(lines
|
|
|
|
(org-split-string
|
|
|
|
(org-export-preprocess-string
|
|
|
|
region
|
|
|
|
:emph-multiline t
|
|
|
|
:for-backend (if (equal org-lparse-backend 'xhtml) ; hack
|
|
|
|
'html
|
|
|
|
org-lparse-backend)
|
|
|
|
:skip-before-1st-heading
|
|
|
|
(plist-get opt-plist :skip-before-1st-heading)
|
|
|
|
:drawers (plist-get opt-plist :drawers)
|
|
|
|
:todo-keywords (plist-get opt-plist :todo-keywords)
|
|
|
|
:tasks (plist-get opt-plist :tasks)
|
|
|
|
:tags (plist-get opt-plist :tags)
|
|
|
|
:priority (plist-get opt-plist :priority)
|
|
|
|
:footnotes (plist-get opt-plist :footnotes)
|
|
|
|
:timestamps (plist-get opt-plist :timestamps)
|
|
|
|
:archived-trees
|
|
|
|
(plist-get opt-plist :archived-trees)
|
|
|
|
:select-tags (plist-get opt-plist :select-tags)
|
|
|
|
:exclude-tags (plist-get opt-plist :exclude-tags)
|
|
|
|
:add-text
|
|
|
|
(plist-get opt-plist :text)
|
|
|
|
:LaTeX-fragments
|
|
|
|
(plist-get opt-plist :LaTeX-fragments))
|
|
|
|
"[\r\n]"))
|
|
|
|
table-open
|
|
|
|
table-buffer table-orig-buffer
|
|
|
|
ind
|
|
|
|
rpl path attr desc descp desc1 desc2 link
|
|
|
|
snumber fnc
|
|
|
|
footnotes footref-seen
|
|
|
|
org-lparse-output-buffer
|
|
|
|
org-lparse-footnote-definitions
|
|
|
|
org-lparse-footnote-number
|
2011-09-01 07:02:06 -04:00
|
|
|
;; collection
|
|
|
|
org-lparse-collect-buffer
|
|
|
|
(org-lparse-collect-count 0) ; things will get haywire if
|
2012-08-11 13:10:44 -04:00
|
|
|
; collections are chained. Use
|
2011-09-01 07:02:06 -04:00
|
|
|
; this variable to assert this
|
|
|
|
; pre-requisite
|
2011-07-01 05:12:19 -04:00
|
|
|
org-lparse-toc
|
|
|
|
href
|
|
|
|
)
|
|
|
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(org-unmodified
|
|
|
|
(remove-text-properties (point-min) (point-max)
|
|
|
|
'(:org-license-to-kill t))))
|
|
|
|
|
|
|
|
(message "Exporting...")
|
|
|
|
(org-init-section-numbers)
|
|
|
|
|
|
|
|
;; Switch to the output buffer
|
|
|
|
(setq org-lparse-output-buffer buffer)
|
|
|
|
(set-buffer org-lparse-output-buffer)
|
|
|
|
(let ((inhibit-read-only t)) (erase-buffer))
|
|
|
|
(fundamental-mode)
|
|
|
|
(org-install-letbind)
|
|
|
|
|
|
|
|
(and (fboundp 'set-buffer-file-coding-system)
|
|
|
|
(set-buffer-file-coding-system coding-system-for-write))
|
|
|
|
|
|
|
|
(let ((case-fold-search nil)
|
|
|
|
(org-odd-levels-only odd))
|
|
|
|
;; create local variables for all options, to make sure all called
|
|
|
|
;; functions get the correct information
|
|
|
|
(mapc (lambda (x)
|
|
|
|
(set (make-local-variable (nth 2 x))
|
|
|
|
(plist-get opt-plist (car x))))
|
|
|
|
org-export-plist-vars)
|
|
|
|
(setq umax (if arg (prefix-numeric-value arg)
|
|
|
|
org-export-headline-levels))
|
|
|
|
(setq umax-toc (if (integerp org-export-with-toc)
|
|
|
|
(min org-export-with-toc umax)
|
|
|
|
umax))
|
2012-03-20 04:02:23 -04:00
|
|
|
(setq org-lparse-opt-plist
|
|
|
|
(plist-put org-lparse-opt-plist :headline-levels umax))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(when (and org-export-with-toc (not body-only))
|
|
|
|
(setq lines (org-lparse-prepare-toc
|
|
|
|
lines level-offset opt-plist umax-toc)))
|
|
|
|
|
|
|
|
(unless body-only
|
|
|
|
(org-lparse-begin 'DOCUMENT-CONTENT opt-plist)
|
|
|
|
(org-lparse-begin 'DOCUMENT-BODY opt-plist))
|
|
|
|
|
|
|
|
(setq head-count 0)
|
|
|
|
(org-init-section-numbers)
|
|
|
|
|
|
|
|
(org-lparse-begin-paragraph)
|
|
|
|
|
|
|
|
(while (setq line (pop lines) origline line)
|
|
|
|
(catch 'nextline
|
|
|
|
(when (and (org-lparse-current-environment-p 'quote)
|
2011-07-18 02:45:41 -04:00
|
|
|
(string-match org-outline-regexp-bol line))
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-end-environment 'quote))
|
|
|
|
|
|
|
|
(when (org-lparse-current-environment-p 'quote)
|
|
|
|
(org-lparse-insert 'LINE line)
|
|
|
|
(throw 'nextline nil))
|
|
|
|
|
|
|
|
;; Fixed-width, verbatim lines (examples)
|
|
|
|
(when (and org-export-with-fixed-width
|
|
|
|
(string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
|
|
|
|
(when (not (org-lparse-current-environment-p 'fixedwidth))
|
|
|
|
(org-lparse-begin-environment 'fixedwidth))
|
|
|
|
(org-lparse-insert 'LINE (match-string 3 line))
|
|
|
|
(when (or (not lines)
|
|
|
|
(not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
|
|
|
|
(car lines))))
|
|
|
|
(org-lparse-end-environment 'fixedwidth))
|
|
|
|
(throw 'nextline nil))
|
|
|
|
|
|
|
|
;; Native Text
|
|
|
|
(when (and (get-text-property 0 'org-native-text line)
|
|
|
|
;; Make sure it is the entire line that is protected
|
|
|
|
(not (< (or (next-single-property-change
|
|
|
|
0 'org-native-text line) 10000)
|
|
|
|
(length line))))
|
|
|
|
(let ((ind (get-text-property 0 'original-indentation line)))
|
|
|
|
(org-lparse-begin-environment 'native)
|
|
|
|
(org-lparse-insert 'LINE line)
|
|
|
|
(while (and lines
|
|
|
|
(or (= (length (car lines)) 0)
|
|
|
|
(not ind)
|
|
|
|
(equal ind (get-text-property
|
|
|
|
0 'original-indentation (car lines))))
|
|
|
|
(or (= (length (car lines)) 0)
|
|
|
|
(get-text-property 0 'org-native-text (car lines))))
|
|
|
|
(org-lparse-insert 'LINE (pop lines)))
|
|
|
|
(org-lparse-end-environment 'native))
|
|
|
|
(throw 'nextline nil))
|
|
|
|
|
|
|
|
;; Protected HTML
|
|
|
|
(when (and (get-text-property 0 'org-protected line)
|
|
|
|
;; Make sure it is the entire line that is protected
|
|
|
|
(not (< (or (next-single-property-change
|
|
|
|
0 'org-protected line) 10000)
|
|
|
|
(length line))))
|
|
|
|
(let ((ind (get-text-property 0 'original-indentation line)))
|
|
|
|
(org-lparse-insert 'LINE line)
|
|
|
|
(while (and lines
|
|
|
|
(or (= (length (car lines)) 0)
|
|
|
|
(not ind)
|
|
|
|
(equal ind (get-text-property
|
|
|
|
0 'original-indentation (car lines))))
|
|
|
|
(or (= (length (car lines)) 0)
|
|
|
|
(get-text-property 0 'org-protected (car lines))))
|
|
|
|
(org-lparse-insert 'LINE (pop lines))))
|
|
|
|
(throw 'nextline nil))
|
|
|
|
|
|
|
|
;; Blockquotes, verse, and center
|
2011-10-28 18:12:30 -04:00
|
|
|
(when (string-match
|
|
|
|
"^ORG-\\(.+\\)-\\(START\\|END\\)\\([ \t]+.*\\)?$" line)
|
2011-07-01 05:12:19 -04:00
|
|
|
(let* ((style (intern (downcase (match-string 1 line))))
|
2011-10-28 18:12:30 -04:00
|
|
|
(env-options-plist (org-lparse-get-block-params
|
|
|
|
(match-string 3 line)))
|
2011-07-01 05:12:19 -04:00
|
|
|
(f (cdr (assoc (match-string 2 line)
|
|
|
|
'(("START" . org-lparse-begin-environment)
|
|
|
|
("END" . org-lparse-end-environment))))))
|
2011-10-28 18:12:30 -04:00
|
|
|
(when (memq style
|
|
|
|
(append
|
|
|
|
'(blockquote verse center)
|
|
|
|
(mapcar 'intern org-lparse-special-blocks)))
|
|
|
|
(funcall f style env-options-plist)
|
2011-07-01 05:12:19 -04:00
|
|
|
(throw 'nextline nil))))
|
|
|
|
|
|
|
|
(when (org-lparse-current-environment-p 'verse)
|
|
|
|
(let ((i (org-get-string-indentation line)))
|
|
|
|
(if (> i 0)
|
|
|
|
(setq line (concat
|
|
|
|
(let ((org-lparse-encode-pending t))
|
|
|
|
(org-lparse-format 'SPACES (* 2 i)))
|
|
|
|
" " (org-trim line))))
|
|
|
|
(unless (string-match "\\\\\\\\[ \t]*$" line)
|
|
|
|
(setq line (concat line "\\\\")))))
|
|
|
|
|
|
|
|
;; make targets to anchors
|
|
|
|
(setq start 0)
|
|
|
|
(while (string-match
|
|
|
|
"<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
|
|
|
|
(cond
|
|
|
|
((get-text-property (match-beginning 1) 'org-protected line)
|
|
|
|
(setq start (match-end 1)))
|
|
|
|
((match-end 2)
|
|
|
|
(setq line (replace-match
|
|
|
|
(let ((org-lparse-encode-pending t))
|
|
|
|
(org-lparse-format
|
|
|
|
'ANCHOR "" (org-solidify-link-text
|
|
|
|
(match-string 1 line))))
|
|
|
|
t t line)))
|
|
|
|
((and org-export-with-toc (equal (string-to-char line) ?*))
|
|
|
|
;; FIXME: NOT DEPENDENT on TOC?????????????????????
|
|
|
|
(setq line (replace-match
|
|
|
|
(let ((org-lparse-encode-pending t))
|
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY (match-string 1 line) "target"))
|
|
|
|
;; (concat "@<i>" (match-string 1 line) "@</i> ")
|
|
|
|
t t line)))
|
|
|
|
(t
|
|
|
|
(setq line (replace-match
|
|
|
|
(concat
|
|
|
|
(let ((org-lparse-encode-pending t))
|
|
|
|
(org-lparse-format
|
|
|
|
'ANCHOR (match-string 1 line)
|
|
|
|
(org-solidify-link-text (match-string 1 line))
|
|
|
|
"target")) " ")
|
|
|
|
t t line)))))
|
|
|
|
|
|
|
|
(let ((org-lparse-encode-pending t))
|
|
|
|
(setq line (org-lparse-handle-time-stamps line)))
|
|
|
|
|
|
|
|
;; replace "&" by "&", "<" and ">" by "<" and ">"
|
|
|
|
;; handle @<..> HTML tags (replace "@>..<" by "<..>")
|
|
|
|
;; Also handle sub_superscripts and checkboxes
|
|
|
|
(or (string-match org-table-hline-regexp line)
|
|
|
|
(string-match "^[ \t]*\\([+]-\\||[ ]\\)[-+ |]*[+|][ \t]*$" line)
|
|
|
|
(setq line (org-xml-encode-org-text-skip-links line)))
|
|
|
|
|
|
|
|
(setq line (org-lparse-format-org-link line opt-plist))
|
|
|
|
|
|
|
|
;; TODO items
|
2011-11-13 01:15:24 -05:00
|
|
|
(if (and org-todo-line-regexp
|
|
|
|
(string-match org-todo-line-regexp line)
|
2011-07-01 05:12:19 -04:00
|
|
|
(match-beginning 2))
|
|
|
|
(setq line (concat
|
|
|
|
(substring line 0 (match-beginning 2))
|
|
|
|
(org-lparse-format 'TODO (match-string 2 line))
|
|
|
|
(substring line (match-end 2)))))
|
|
|
|
|
|
|
|
;; Does this contain a reference to a footnote?
|
|
|
|
(when org-export-with-footnotes
|
|
|
|
(setq start 0)
|
|
|
|
(while (string-match "\\([^* \t].*?\\)[ \t]*\\[\\([0-9]+\\)\\]" line start)
|
|
|
|
;; Discard protected matches not clearly identified as
|
|
|
|
;; footnote markers.
|
|
|
|
(if (or (get-text-property (match-beginning 2) 'org-protected line)
|
|
|
|
(not (get-text-property (match-beginning 2) 'org-footnote line)))
|
|
|
|
(setq start (match-end 2))
|
|
|
|
(let ((n (match-string 2 line)) refcnt a)
|
|
|
|
(if (setq a (assoc n footref-seen))
|
|
|
|
(progn
|
|
|
|
(setcdr a (1+ (cdr a)))
|
|
|
|
(setq refcnt (cdr a)))
|
|
|
|
(setq refcnt 1)
|
|
|
|
(push (cons n 1) footref-seen))
|
|
|
|
(setq line
|
|
|
|
(replace-match
|
|
|
|
(concat
|
|
|
|
(or (match-string 1 line) "")
|
|
|
|
(org-lparse-format
|
|
|
|
'FOOTNOTE-REFERENCE
|
|
|
|
n (cdr (assoc n org-lparse-footnote-definitions))
|
|
|
|
refcnt)
|
|
|
|
;; If another footnote is following the
|
|
|
|
;; current one, add a separator.
|
|
|
|
(if (save-match-data
|
|
|
|
(string-match "\\`\\[[0-9]+\\]"
|
|
|
|
(substring line (match-end 0))))
|
|
|
|
(ignore-errors
|
|
|
|
(org-lparse-get 'FOOTNOTE-SEPARATOR))
|
|
|
|
""))
|
|
|
|
t t line))))))
|
|
|
|
|
|
|
|
(cond
|
2011-11-13 03:46:42 -05:00
|
|
|
((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line)
|
2011-07-01 05:12:19 -04:00
|
|
|
;; This is a headline
|
|
|
|
(setq level (org-tr-level (- (match-end 1) (match-beginning 1)
|
|
|
|
level-offset))
|
|
|
|
txt (match-string 2 line))
|
|
|
|
(if (string-match quote-re0 txt)
|
|
|
|
(setq txt (replace-match "" t t txt)))
|
|
|
|
(if (<= level (max umax umax-toc))
|
|
|
|
(setq head-count (+ head-count 1)))
|
|
|
|
(unless org-lparse-dyn-first-heading-pos
|
|
|
|
(setq org-lparse-dyn-first-heading-pos (point)))
|
|
|
|
(org-lparse-begin-level level txt umax head-count)
|
|
|
|
|
|
|
|
;; QUOTES
|
|
|
|
(when (string-match quote-re line)
|
|
|
|
(org-lparse-begin-environment 'quote)))
|
|
|
|
|
|
|
|
((and org-export-with-tables
|
|
|
|
(string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
|
|
|
|
(when (not table-open)
|
|
|
|
;; New table starts
|
|
|
|
(setq table-open t table-buffer nil table-orig-buffer nil))
|
|
|
|
|
|
|
|
;; Accumulate lines
|
|
|
|
(setq table-buffer (cons line table-buffer)
|
|
|
|
table-orig-buffer (cons origline table-orig-buffer))
|
|
|
|
(when (or (not lines)
|
|
|
|
(not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
|
|
|
|
(car lines))))
|
|
|
|
(setq table-open nil
|
|
|
|
table-buffer (nreverse table-buffer)
|
|
|
|
table-orig-buffer (nreverse table-orig-buffer))
|
|
|
|
(org-lparse-end-paragraph)
|
Add support for indented tables in ODT export
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
2012-01-16 15:55:47 -05:00
|
|
|
(when org-lparse-list-table-p
|
|
|
|
(error "Regular tables are not allowed in a list-table block"))
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-insert 'TABLE table-buffer table-orig-buffer)))
|
|
|
|
|
|
|
|
;; Normal lines
|
|
|
|
(t
|
|
|
|
;; This line either is list item or end a list.
|
|
|
|
(when (get-text-property 0 'list-item line)
|
|
|
|
(setq line (org-lparse-export-list-line
|
|
|
|
line
|
|
|
|
(get-text-property 0 'list-item line)
|
|
|
|
(get-text-property 0 'list-struct line)
|
|
|
|
(get-text-property 0 'list-prevs line))))
|
|
|
|
|
|
|
|
;; Horizontal line
|
|
|
|
(when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
|
|
|
|
(with-org-lparse-preserve-paragraph-state
|
|
|
|
(org-lparse-insert 'HORIZONTAL-LINE))
|
|
|
|
(throw 'nextline nil))
|
|
|
|
|
|
|
|
;; Empty lines start a new paragraph. If hand-formatted lists
|
|
|
|
;; are not fully interpreted, lines starting with "-", "+", "*"
|
|
|
|
;; also start a new paragraph.
|
|
|
|
(when (string-match "^ [-+*]-\\|^[ \t]*$" line)
|
|
|
|
(when org-lparse-footnote-number
|
|
|
|
(org-lparse-end-footnote-definition org-lparse-footnote-number)
|
|
|
|
(setq org-lparse-footnote-number nil))
|
|
|
|
(org-lparse-begin-paragraph))
|
|
|
|
|
|
|
|
;; Is this the start of a footnote?
|
|
|
|
(when org-export-with-footnotes
|
|
|
|
(when (and (boundp 'footnote-section-tag-regexp)
|
|
|
|
(string-match (concat "^" footnote-section-tag-regexp)
|
|
|
|
line))
|
|
|
|
;; ignore this line
|
|
|
|
(throw 'nextline nil))
|
|
|
|
(when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
|
|
|
|
(org-lparse-end-paragraph)
|
|
|
|
(setq org-lparse-footnote-number (match-string 1 line))
|
|
|
|
(setq line (replace-match "" t t line))
|
|
|
|
(org-lparse-begin-footnote-definition org-lparse-footnote-number)))
|
|
|
|
;; Check if the line break needs to be conserved
|
|
|
|
(cond
|
|
|
|
((string-match "\\\\\\\\[ \t]*$" line)
|
|
|
|
(setq line (replace-match
|
|
|
|
(org-lparse-format 'LINE-BREAK)
|
|
|
|
t t line)))
|
|
|
|
(org-export-preserve-breaks
|
|
|
|
(setq line (concat line (org-lparse-format 'LINE-BREAK)))))
|
|
|
|
|
|
|
|
;; Check if a paragraph should be started
|
|
|
|
(let ((start 0))
|
|
|
|
(while (and org-lparse-par-open
|
|
|
|
(string-match "\\\\par\\>" line start))
|
|
|
|
(error "FIXME")
|
|
|
|
;; Leave a space in the </p> so that the footnote matcher
|
|
|
|
;; does not see this.
|
|
|
|
(if (not (get-text-property (match-beginning 0)
|
|
|
|
'org-protected line))
|
|
|
|
(setq line (replace-match "</p ><p >" t t line)))
|
|
|
|
(setq start (match-end 0))))
|
|
|
|
|
|
|
|
(org-lparse-insert 'LINE line)))))
|
|
|
|
|
|
|
|
;; Properly close all local lists and other lists
|
|
|
|
(when (org-lparse-current-environment-p 'quote)
|
|
|
|
(org-lparse-end-environment 'quote))
|
|
|
|
|
|
|
|
(org-lparse-end-level 1 umax)
|
|
|
|
|
|
|
|
;; the </div> to close the last text-... div.
|
|
|
|
(when (and (> umax 0) org-lparse-dyn-first-heading-pos)
|
|
|
|
(org-lparse-end-outline-text-or-outline))
|
|
|
|
|
|
|
|
(org-lparse-end 'DOCUMENT-BODY opt-plist)
|
|
|
|
(unless body-only
|
|
|
|
(org-lparse-end 'DOCUMENT-CONTENT))
|
|
|
|
|
|
|
|
(org-lparse-end 'EXPORT)
|
|
|
|
|
2011-09-01 07:02:06 -04:00
|
|
|
;; kill collection buffer
|
|
|
|
(when org-lparse-collect-buffer
|
|
|
|
(kill-buffer org-lparse-collect-buffer))
|
2011-09-01 14:11:26 -04:00
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
(goto-char (point-min))
|
|
|
|
(or (org-export-push-to-kill-ring
|
|
|
|
(upcase (symbol-name org-lparse-backend)))
|
|
|
|
(message "Exporting... done"))
|
|
|
|
|
|
|
|
(cond
|
|
|
|
((not to-buffer)
|
|
|
|
(let ((f (org-lparse-get 'SAVE-METHOD)))
|
|
|
|
(or (and f (functionp f) (funcall f filename opt-plist))
|
|
|
|
(save-buffer)))
|
2011-10-24 14:53:42 -04:00
|
|
|
(or (and (boundp 'org-lparse-other-backend)
|
|
|
|
org-lparse-other-backend
|
|
|
|
(not (equal org-lparse-backend org-lparse-other-backend))
|
|
|
|
(org-lparse-do-convert
|
|
|
|
buffer-file-name (symbol-name org-lparse-other-backend)))
|
2011-07-01 05:12:19 -04:00
|
|
|
(current-buffer)))
|
|
|
|
((eq to-buffer 'string)
|
|
|
|
(prog1 (buffer-substring (point-min) (point-max))
|
|
|
|
(kill-buffer (current-buffer))))
|
|
|
|
(t (current-buffer))))))
|
|
|
|
|
|
|
|
(defun org-lparse-format-table (lines olines)
|
2012-01-10 05:56:15 -05:00
|
|
|
"Returns backend-specific code for org-type and table-type tables."
|
2011-07-01 05:12:19 -04:00
|
|
|
(if (stringp lines)
|
|
|
|
(setq lines (org-split-string lines "\n")))
|
|
|
|
(if (string-match "^[ \t]*|" (car lines))
|
|
|
|
;; A normal org table
|
|
|
|
(org-lparse-format-org-table lines nil)
|
|
|
|
;; Table made by table.el
|
|
|
|
(or (org-lparse-format-table-table-using-table-generate-source
|
2011-08-27 16:31:40 -04:00
|
|
|
;; FIXME: Need to take care of this during merge
|
|
|
|
(if (eq org-lparse-backend 'xhtml) 'html org-lparse-backend)
|
|
|
|
olines
|
2011-07-01 05:12:19 -04:00
|
|
|
(not org-export-prefer-native-exporter-for-tables))
|
|
|
|
;; We are here only when table.el table has NO col or row
|
|
|
|
;; spanning and the user prefers using org's own converter for
|
|
|
|
;; exporting of such simple table.el tables.
|
|
|
|
(org-lparse-format-table-table lines))))
|
|
|
|
|
|
|
|
(defun org-lparse-table-get-colalign-info (lines)
|
2011-10-16 04:55:28 -04:00
|
|
|
(let ((col-cookies (org-find-text-property-in-string
|
2012-08-11 13:10:44 -04:00
|
|
|
'org-col-cookies (car lines))))
|
2011-10-16 04:55:28 -04:00
|
|
|
(when (and col-cookies org-table-clean-did-remove-column)
|
|
|
|
(setq col-cookies
|
|
|
|
(mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies)))
|
|
|
|
col-cookies))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defvar org-lparse-table-style)
|
|
|
|
(defvar org-lparse-table-ncols)
|
|
|
|
(defvar org-lparse-table-rownum)
|
|
|
|
(defvar org-lparse-table-is-styled)
|
|
|
|
(defvar org-lparse-table-begin-marker)
|
|
|
|
(defvar org-lparse-table-num-numeric-items-per-column)
|
|
|
|
(defvar org-lparse-table-colalign-info)
|
|
|
|
(defvar org-lparse-table-colalign-vector)
|
|
|
|
|
|
|
|
;; Following variables are defined in org-table.el
|
|
|
|
(defvar org-table-number-fraction)
|
|
|
|
(defvar org-table-number-regexp)
|
2011-08-31 13:53:03 -04:00
|
|
|
(defun org-lparse-org-table-to-list-table (lines &optional splice)
|
|
|
|
"Convert org-table to list-table.
|
|
|
|
LINES is a list of the form (ROW1 ROW2 ROW3 ...) where each
|
|
|
|
element is a `string' representing a single row of org-table.
|
|
|
|
Thus each ROW has vertical separators \"|\" separating the table
|
|
|
|
fields. A ROW could also be a row-group separator of the form
|
|
|
|
\"|---...|\". Return a list of the form (ROW1 ROW2 ROW3
|
|
|
|
...). ROW could either be symbol `:hrule' or a list of the
|
|
|
|
form (FIELD1 FIELD2 FIELD3 ...) as appropriate."
|
|
|
|
(let (line lines-1)
|
|
|
|
(cond
|
|
|
|
(splice
|
|
|
|
(while (setq line (pop lines))
|
|
|
|
(unless (string-match "^[ \t]*|-" line)
|
|
|
|
(push (org-split-string line "[ \t]*|[ \t]*") lines-1))))
|
|
|
|
(t
|
|
|
|
(while (setq line (pop lines))
|
|
|
|
(cond
|
|
|
|
((string-match "^[ \t]*|-" line)
|
|
|
|
(when lines
|
|
|
|
(push :hrule lines-1)))
|
|
|
|
(t
|
|
|
|
(push (org-split-string line "[ \t]*|[ \t]*") lines-1))))))
|
|
|
|
(nreverse lines-1)))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-09-08 15:08:31 -04:00
|
|
|
(defun org-lparse-insert-org-table (lines &optional splice)
|
2011-07-01 05:12:19 -04:00
|
|
|
"Format a org-type table into backend-specific code.
|
|
|
|
LINES is a list of lines. Optional argument SPLICE means, do not
|
|
|
|
insert header and surrounding <table> tags, just format the lines.
|
|
|
|
Optional argument NO-CSS means use XHTML attributes instead of CSS
|
|
|
|
for formatting. This is required for the DocBook exporter."
|
|
|
|
(require 'org-table)
|
|
|
|
;; Get rid of hlines at beginning and end
|
|
|
|
(if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
|
|
|
|
(setq lines (nreverse lines))
|
|
|
|
(if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
|
|
|
|
(setq lines (nreverse lines))
|
|
|
|
(when org-export-table-remove-special-lines
|
|
|
|
;; Check if the table has a marking column. If yes remove the
|
|
|
|
;; column and the special lines
|
|
|
|
(setq lines (org-table-clean-before-export lines)))
|
|
|
|
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
|
2012-03-30 16:33:10 -04:00
|
|
|
(short-caption (or (org-find-text-property-in-string
|
|
|
|
'org-caption-shortn (car lines)) caption))
|
2011-07-01 05:12:19 -04:00
|
|
|
(caption (and caption (org-xml-encode-org-text caption)))
|
2012-03-29 15:00:46 -04:00
|
|
|
(short-caption (and short-caption
|
2012-03-30 16:33:10 -04:00
|
|
|
(org-xml-encode-plain-text short-caption)))
|
2011-07-01 05:12:19 -04:00
|
|
|
(label (org-find-text-property-in-string 'org-label (car lines)))
|
|
|
|
(org-lparse-table-colalign-info (org-lparse-table-get-colalign-info lines))
|
|
|
|
(attributes (org-find-text-property-in-string 'org-attributes
|
|
|
|
(car lines)))
|
|
|
|
(head (and org-export-highlight-first-table-line
|
|
|
|
(delq nil (mapcar
|
|
|
|
(lambda (x) (string-match "^[ \t]*|-" x))
|
2011-08-31 15:42:15 -04:00
|
|
|
(cdr lines))))))
|
|
|
|
(setq lines (org-lparse-org-table-to-list-table lines splice))
|
2011-09-08 15:08:31 -04:00
|
|
|
(org-lparse-insert-list-table
|
2012-03-29 15:00:46 -04:00
|
|
|
lines splice caption label attributes head org-lparse-table-colalign-info
|
|
|
|
short-caption)))
|
2011-08-31 15:42:15 -04:00
|
|
|
|
2011-09-08 15:08:31 -04:00
|
|
|
(defun org-lparse-insert-list-table (lines &optional splice
|
2012-08-11 13:10:44 -04:00
|
|
|
caption label attributes head
|
|
|
|
org-lparse-table-colalign-info
|
|
|
|
short-caption)
|
2011-09-01 14:11:26 -04:00
|
|
|
(or (featurep 'org-table) ; required for
|
|
|
|
(require 'org-table)) ; `org-table-number-regexp'
|
2011-08-31 15:42:15 -04:00
|
|
|
(let* ((org-lparse-table-rownum -1) org-lparse-table-ncols i (cnt 0)
|
|
|
|
tbopen fields line
|
2011-07-01 05:12:19 -04:00
|
|
|
org-lparse-table-cur-rowgrp-is-hdr
|
|
|
|
org-lparse-table-rowgrp-open
|
|
|
|
org-lparse-table-num-numeric-items-per-column
|
|
|
|
org-lparse-table-colalign-vector n
|
|
|
|
org-lparse-table-rowgrp-info
|
|
|
|
org-lparse-table-begin-marker
|
|
|
|
(org-lparse-table-style 'org-table)
|
|
|
|
org-lparse-table-is-styled)
|
|
|
|
(cond
|
|
|
|
(splice
|
|
|
|
(setq org-lparse-table-is-styled nil)
|
|
|
|
(while (setq line (pop lines))
|
2011-08-31 13:53:03 -04:00
|
|
|
(insert (org-lparse-format-table-row line) "\n")))
|
2011-07-01 05:12:19 -04:00
|
|
|
(t
|
|
|
|
(setq org-lparse-table-is-styled t)
|
2012-03-29 15:00:46 -04:00
|
|
|
(org-lparse-begin 'TABLE caption label attributes short-caption)
|
2011-07-01 05:12:19 -04:00
|
|
|
(setq org-lparse-table-begin-marker (point))
|
|
|
|
(org-lparse-begin-table-rowgroup head)
|
|
|
|
(while (setq line (pop lines))
|
|
|
|
(cond
|
2011-08-31 13:53:03 -04:00
|
|
|
((equal line :hrule)
|
|
|
|
(org-lparse-begin-table-rowgroup))
|
2011-07-01 05:12:19 -04:00
|
|
|
(t
|
2011-08-31 13:53:03 -04:00
|
|
|
(insert (org-lparse-format-table-row line) "\n"))))
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-end 'TABLE-ROWGROUP)
|
|
|
|
(org-lparse-end-table)))))
|
|
|
|
|
|
|
|
(defun org-lparse-format-org-table (lines &optional splice)
|
|
|
|
(with-temp-buffer
|
2011-09-08 15:08:31 -04:00
|
|
|
(org-lparse-insert-org-table lines splice)
|
2011-07-01 05:12:19 -04:00
|
|
|
(buffer-substring-no-properties (point-min) (point-max))))
|
|
|
|
|
2011-08-31 14:05:29 -04:00
|
|
|
(defun org-lparse-format-list-table (lines &optional splice)
|
|
|
|
(with-temp-buffer
|
2011-09-08 15:08:31 -04:00
|
|
|
(org-lparse-insert-list-table lines splice)
|
2011-08-31 14:05:29 -04:00
|
|
|
(buffer-substring-no-properties (point-min) (point-max))))
|
|
|
|
|
2011-09-08 15:08:31 -04:00
|
|
|
(defun org-lparse-insert-table-table (lines)
|
2011-07-01 05:12:19 -04:00
|
|
|
"Format a table generated by table.el into backend-specific code.
|
|
|
|
This conversion does *not* use `table-generate-source' from table.el.
|
|
|
|
This has the advantage that Org-mode's HTML conversions can be used.
|
|
|
|
But it has the disadvantage, that no cell- or row-spanning is allowed."
|
|
|
|
(let (line field-buffer
|
|
|
|
(org-lparse-table-cur-rowgrp-is-hdr
|
|
|
|
org-export-highlight-first-table-line)
|
|
|
|
(caption nil)
|
2012-03-29 15:00:46 -04:00
|
|
|
(short-caption nil)
|
2011-07-01 05:12:19 -04:00
|
|
|
(attributes nil)
|
|
|
|
(label nil)
|
|
|
|
(org-lparse-table-style 'table-table)
|
|
|
|
(org-lparse-table-is-styled nil)
|
|
|
|
fields org-lparse-table-ncols i (org-lparse-table-rownum -1)
|
|
|
|
(empty (org-lparse-format 'SPACES 1)))
|
2012-03-29 15:00:46 -04:00
|
|
|
(org-lparse-begin 'TABLE caption label attributes short-caption)
|
2011-07-01 05:12:19 -04:00
|
|
|
(while (setq line (pop lines))
|
|
|
|
(cond
|
|
|
|
((string-match "^[ \t]*\\+-" line)
|
|
|
|
(when field-buffer
|
|
|
|
(let ((org-export-table-row-tags '("<tr>" . "</tr>"))
|
|
|
|
;; (org-export-html-table-use-header-tags-for-first-column nil)
|
|
|
|
)
|
|
|
|
(insert (org-lparse-format-table-row field-buffer empty)))
|
|
|
|
(setq org-lparse-table-cur-rowgrp-is-hdr nil)
|
|
|
|
(setq field-buffer nil)))
|
|
|
|
(t
|
|
|
|
;; Break the line into fields and store the fields
|
|
|
|
(setq fields (org-split-string line "[ \t]*|[ \t]*"))
|
|
|
|
(if field-buffer
|
|
|
|
(setq field-buffer (mapcar
|
|
|
|
(lambda (x)
|
|
|
|
(concat x (org-lparse-format 'LINE-BREAK)
|
|
|
|
(pop fields)))
|
|
|
|
field-buffer))
|
|
|
|
(setq field-buffer fields)))))
|
|
|
|
(org-lparse-end-table)))
|
|
|
|
|
|
|
|
(defun org-lparse-format-table-table (lines)
|
|
|
|
(with-temp-buffer
|
2011-09-08 15:08:31 -04:00
|
|
|
(org-lparse-insert-table-table lines)
|
2011-07-01 05:12:19 -04:00
|
|
|
(buffer-substring-no-properties (point-min) (point-max))))
|
|
|
|
|
2011-07-02 18:37:29 -04:00
|
|
|
(defvar table-source-languages) ; defined in table.el
|
2011-07-01 05:12:19 -04:00
|
|
|
(defun org-lparse-format-table-table-using-table-generate-source (backend
|
2012-08-11 13:10:44 -04:00
|
|
|
lines
|
|
|
|
&optional
|
|
|
|
spanned-only)
|
2011-07-01 05:12:19 -04:00
|
|
|
"Format a table into BACKEND, using `table-generate-source' from table.el.
|
|
|
|
Use SPANNED-ONLY to suppress exporting of simple table.el tables.
|
|
|
|
|
|
|
|
When SPANNED-ONLY is nil, all table.el tables are exported. When
|
|
|
|
SPANNED-ONLY is non-nil, only tables with either row or column
|
|
|
|
spans are exported.
|
|
|
|
|
|
|
|
This routine returns the generated source or nil as appropriate.
|
|
|
|
|
|
|
|
Refer docstring of `org-export-prefer-native-exporter-for-tables'
|
|
|
|
for further information."
|
|
|
|
(require 'table)
|
|
|
|
(with-current-buffer (get-buffer-create " org-tmp1 ")
|
|
|
|
(erase-buffer)
|
|
|
|
(insert (mapconcat 'identity lines "\n"))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (not (re-search-forward "|[^+]" nil t))
|
|
|
|
(error "Error processing table"))
|
|
|
|
(table-recognize-table)
|
|
|
|
(when (or (not spanned-only)
|
|
|
|
(let* ((dim (table-query-dimension))
|
|
|
|
(c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
|
|
|
|
(not (= (* c r) cells))))
|
|
|
|
(with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
|
|
|
|
(cond
|
|
|
|
((member backend table-source-languages)
|
|
|
|
(table-generate-source backend " org-tmp2 ")
|
|
|
|
(set-buffer " org-tmp2 ")
|
|
|
|
(buffer-substring (point-min) (point-max)))
|
|
|
|
(t
|
2012-08-11 13:10:44 -04:00
|
|
|
;; table.el doesn't support the given backend. Currently this
|
2011-07-01 05:12:19 -04:00
|
|
|
;; happens in case of odt export. Strip the table from the
|
2012-08-11 13:10:44 -04:00
|
|
|
;; generated document. A better alternative would be to embed
|
2011-07-01 05:12:19 -04:00
|
|
|
;; the table as ascii text in the output document.
|
|
|
|
(org-lparse-warn
|
|
|
|
(concat
|
|
|
|
"Found table.el-type table in the source org file. "
|
|
|
|
(format "table.el doesn't support %s backend. "
|
|
|
|
(upcase (symbol-name backend)))
|
|
|
|
"Skipping ahead ..."))
|
|
|
|
"")))))
|
|
|
|
|
|
|
|
(defun org-lparse-handle-time-stamps (s)
|
|
|
|
"Format time stamps in string S, or remove them."
|
|
|
|
(catch 'exit
|
|
|
|
(let (r b)
|
2011-11-13 01:15:24 -05:00
|
|
|
(when org-maybe-keyword-time-regexp
|
|
|
|
(while (string-match org-maybe-keyword-time-regexp s)
|
|
|
|
(or b (setq b (substring s 0 (match-beginning 0))))
|
|
|
|
(setq r (concat
|
|
|
|
r (substring s 0 (match-beginning 0)) " "
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY
|
2011-11-13 01:15:24 -05:00
|
|
|
(concat
|
|
|
|
(if (match-end 1)
|
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY
|
|
|
|
(match-string 1 s) "timestamp-kwd"))
|
|
|
|
" "
|
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY
|
|
|
|
(substring (org-translate-time (match-string 3 s)) 1 -1)
|
|
|
|
"timestamp"))
|
|
|
|
"timestamp-wrapper"))
|
|
|
|
s (substring s (match-end 0)))))
|
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
;; Line break if line started and ended with time stamp stuff
|
|
|
|
(if (not r)
|
|
|
|
s
|
|
|
|
(setq r (concat r s))
|
|
|
|
(unless (string-match "\\S-" (concat b s))
|
|
|
|
(setq r (concat r (org-lparse-format 'LINE-BREAK))))
|
|
|
|
r))))
|
|
|
|
|
|
|
|
(defun org-xml-encode-plain-text (s)
|
|
|
|
"Convert plain text characters to HTML equivalent.
|
|
|
|
Possible conversions are set in `org-export-html-protect-char-alist'."
|
|
|
|
(let ((cl (org-lparse-get 'PLAIN-TEXT-MAP)) c)
|
|
|
|
(while (setq c (pop cl))
|
|
|
|
(let ((start 0))
|
|
|
|
(while (string-match (car c) s start)
|
|
|
|
(setq s (replace-match (cdr c) t t s)
|
|
|
|
start (1+ (match-beginning 0))))))
|
|
|
|
s))
|
|
|
|
|
|
|
|
(defun org-xml-encode-org-text-skip-links (string)
|
|
|
|
"Prepare STRING for HTML export. Apply all active conversions.
|
2011-11-13 03:46:42 -05:00
|
|
|
If there are links in the string, don't modify these. If STRING
|
|
|
|
is nil, return nil."
|
|
|
|
(when string
|
|
|
|
(let* ((re (concat org-bracket-link-regexp "\\|"
|
|
|
|
(org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
|
|
|
|
m s l res)
|
|
|
|
(while (setq m (string-match re string))
|
|
|
|
(setq s (substring string 0 m)
|
|
|
|
l (match-string 0 string)
|
|
|
|
string (substring string (match-end 0)))
|
|
|
|
(push (org-xml-encode-org-text s) res)
|
|
|
|
(push l res))
|
|
|
|
(push (org-xml-encode-org-text string) res)
|
|
|
|
(apply 'concat (nreverse res)))))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-xml-encode-org-text (s)
|
|
|
|
"Apply all active conversions to translate special ASCII to HTML."
|
|
|
|
(setq s (org-xml-encode-plain-text s))
|
|
|
|
(if org-export-html-expand
|
|
|
|
(while (string-match "@<\\([^&]*\\)>" s)
|
|
|
|
(setq s (replace-match "<\\1>" t nil s))))
|
|
|
|
(if org-export-with-emphasize
|
|
|
|
(setq s (org-lparse-apply-char-styles s)))
|
|
|
|
(if org-export-with-special-strings
|
|
|
|
(setq s (org-lparse-convert-special-strings s)))
|
|
|
|
(if org-export-with-sub-superscripts
|
|
|
|
(setq s (org-lparse-apply-sub-superscript-styles s)))
|
|
|
|
(if org-export-with-TeX-macros
|
|
|
|
(let ((start 0) wd rep)
|
|
|
|
(while (setq start (string-match "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?"
|
|
|
|
s start))
|
|
|
|
(if (get-text-property (match-beginning 0) 'org-protected s)
|
|
|
|
(setq start (match-end 0))
|
|
|
|
(setq wd (match-string 1 s))
|
|
|
|
(if (setq rep (org-lparse-format 'ORG-ENTITY wd))
|
|
|
|
(setq s (replace-match rep t t s))
|
|
|
|
(setq start (+ start (length wd))))))))
|
|
|
|
s)
|
|
|
|
|
|
|
|
(defun org-lparse-convert-special-strings (string)
|
|
|
|
"Convert special characters in STRING to HTML."
|
|
|
|
(let ((all (org-lparse-get 'SPECIAL-STRING-REGEXPS))
|
|
|
|
e a re rpl start)
|
|
|
|
(while (setq a (pop all))
|
|
|
|
(setq re (car a) rpl (cdr a) start 0)
|
|
|
|
(while (string-match re string start)
|
|
|
|
(if (get-text-property (match-beginning 0) 'org-protected string)
|
|
|
|
(setq start (match-end 0))
|
|
|
|
(setq string (replace-match rpl t nil string)))))
|
|
|
|
string))
|
|
|
|
|
|
|
|
(defun org-lparse-apply-sub-superscript-styles (string)
|
|
|
|
"Apply subscript and superscript styles to STRING.
|
|
|
|
Use `org-export-with-sub-superscripts' to control application of
|
|
|
|
sub and superscript styles."
|
|
|
|
(let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
|
|
|
|
(while (string-match org-match-substring-regexp string s)
|
|
|
|
(cond
|
|
|
|
((and requireb (match-end 8)) (setq s (match-end 2)))
|
|
|
|
((get-text-property (match-beginning 2) 'org-protected string)
|
|
|
|
(setq s (match-end 2)))
|
|
|
|
(t
|
|
|
|
(setq s (match-end 1)
|
|
|
|
key (if (string= (match-string 2 string) "_")
|
|
|
|
'subscript 'superscript)
|
|
|
|
c (or (match-string 8 string)
|
|
|
|
(match-string 6 string)
|
|
|
|
(match-string 5 string))
|
|
|
|
string (replace-match
|
|
|
|
(concat (match-string 1 string)
|
|
|
|
(org-lparse-format 'FONTIFY c key))
|
|
|
|
t t string)))))
|
|
|
|
(while (string-match "\\\\\\([_^]\\)" string)
|
|
|
|
(setq string (replace-match (match-string 1 string) t t string)))
|
|
|
|
string))
|
|
|
|
|
|
|
|
(defvar org-lparse-char-styles
|
|
|
|
`(("*" bold)
|
|
|
|
("/" emphasis)
|
|
|
|
("_" underline)
|
|
|
|
("=" code)
|
|
|
|
("~" verbatim)
|
|
|
|
("+" strike))
|
|
|
|
"Map Org emphasis markers to char styles.
|
|
|
|
This is an alist where each element is of the
|
|
|
|
form (ORG-EMPHASIS-CHAR . CHAR-STYLE).")
|
|
|
|
|
|
|
|
(defun org-lparse-apply-char-styles (string)
|
|
|
|
"Apply char styles to STRING.
|
|
|
|
The variable `org-lparse-char-styles' controls how the Org
|
|
|
|
emphasis markers are interpreted."
|
|
|
|
(let ((s 0) rpl)
|
|
|
|
(while (string-match org-emph-re string s)
|
|
|
|
(if (not (equal
|
|
|
|
(substring string (match-beginning 3) (1+ (match-beginning 3)))
|
|
|
|
(substring string (match-beginning 4) (1+ (match-beginning 4)))))
|
|
|
|
(setq s (match-beginning 0)
|
|
|
|
rpl
|
|
|
|
(concat
|
|
|
|
(match-string 1 string)
|
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY (match-string 4 string)
|
|
|
|
(nth 1 (assoc (match-string 3 string)
|
|
|
|
org-lparse-char-styles)))
|
|
|
|
(match-string 5 string))
|
|
|
|
string (replace-match rpl t t string)
|
|
|
|
s (+ s (- (length rpl) 2)))
|
|
|
|
(setq s (1+ s))))
|
|
|
|
string))
|
|
|
|
|
|
|
|
(defun org-lparse-export-list-line (line pos struct prevs)
|
|
|
|
"Insert list syntax in export buffer. Return LINE, maybe modified.
|
|
|
|
|
|
|
|
POS is the item position or line position the line had before
|
|
|
|
modifications to buffer. STRUCT is the list structure. PREVS is
|
|
|
|
the alist of previous items."
|
|
|
|
(let* ((get-type
|
|
|
|
(function
|
|
|
|
;; Translate type of list containing POS to "d", "o" or
|
|
|
|
;; "u".
|
|
|
|
(lambda (pos struct prevs)
|
|
|
|
(let ((type (org-list-get-list-type pos struct prevs)))
|
|
|
|
(cond
|
|
|
|
((eq 'ordered type) "o")
|
|
|
|
((eq 'descriptive type) "d")
|
|
|
|
(t "u"))))))
|
|
|
|
(get-closings
|
|
|
|
(function
|
|
|
|
;; Return list of all items and sublists ending at POS, in
|
|
|
|
;; reverse order.
|
|
|
|
(lambda (pos)
|
|
|
|
(let (out)
|
|
|
|
(catch 'exit
|
|
|
|
(mapc (lambda (e)
|
|
|
|
(let ((end (nth 6 e))
|
|
|
|
(item (car e)))
|
|
|
|
(cond
|
|
|
|
((= end pos) (push item out))
|
|
|
|
((>= item pos) (throw 'exit nil)))))
|
|
|
|
struct))
|
|
|
|
out)))))
|
|
|
|
;; First close any previous item, or list, ending at POS.
|
|
|
|
(mapc (lambda (e)
|
|
|
|
(let* ((lastp (= (org-list-get-last-item e struct prevs) e))
|
|
|
|
(first-item (org-list-get-list-begin e struct prevs))
|
|
|
|
(type (funcall get-type first-item struct prevs)))
|
|
|
|
(org-lparse-end-paragraph)
|
|
|
|
;; Ending for every item
|
2011-08-31 12:53:46 -04:00
|
|
|
(org-lparse-end-list-item-1 type)
|
2011-07-01 05:12:19 -04:00
|
|
|
;; We're ending last item of the list: end list.
|
|
|
|
(when lastp
|
2011-08-08 02:01:17 -04:00
|
|
|
(org-lparse-end-list type)
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-begin-paragraph))))
|
|
|
|
(funcall get-closings pos))
|
|
|
|
(cond
|
|
|
|
;; At an item: insert appropriate tags in export buffer.
|
|
|
|
((assq pos struct)
|
|
|
|
(string-match
|
|
|
|
(concat "[ \t]*\\(\\S-+[ \t]*\\)"
|
2011-07-08 16:15:46 -04:00
|
|
|
"\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
|
2011-07-01 05:12:19 -04:00
|
|
|
"\\(?:\\(\\[[ X-]\\]\\)[ \t]+\\)?"
|
2011-07-08 16:20:45 -04:00
|
|
|
"\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?"
|
2011-07-01 05:12:19 -04:00
|
|
|
"\\(.*\\)") line)
|
|
|
|
(let* ((checkbox (match-string 3 line))
|
|
|
|
(desc-tag (or (match-string 4 line) "???"))
|
|
|
|
(body (or (match-string 5 line) ""))
|
|
|
|
(list-beg (org-list-get-list-begin pos struct prevs))
|
|
|
|
(firstp (= list-beg pos))
|
|
|
|
;; Always refer to first item to determine list type, in
|
|
|
|
;; case list is ill-formed.
|
|
|
|
(type (funcall get-type list-beg struct prevs))
|
|
|
|
(counter (let ((count-tmp (org-list-get-counter pos struct)))
|
|
|
|
(cond
|
|
|
|
((not count-tmp) nil)
|
|
|
|
((string-match "[A-Za-z]" count-tmp)
|
|
|
|
(- (string-to-char (upcase count-tmp)) 64))
|
|
|
|
((string-match "[0-9]+" count-tmp)
|
|
|
|
count-tmp)))))
|
|
|
|
(when firstp
|
|
|
|
(org-lparse-end-paragraph)
|
2011-08-08 02:01:17 -04:00
|
|
|
(org-lparse-begin-list type))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(let ((arg (cond ((equal type "d") desc-tag)
|
|
|
|
((equal type "o") counter))))
|
2011-08-31 12:53:46 -04:00
|
|
|
(org-lparse-begin-list-item type arg))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
;; If line had a checkbox, some additional modification is required.
|
|
|
|
(when checkbox
|
|
|
|
(setq body
|
|
|
|
(concat
|
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY (concat
|
|
|
|
"["
|
|
|
|
(cond
|
|
|
|
((string-match "X" checkbox) "X")
|
|
|
|
((string-match " " checkbox)
|
|
|
|
(org-lparse-format 'SPACES 1))
|
|
|
|
(t "-"))
|
|
|
|
"]")
|
|
|
|
'code)
|
|
|
|
" "
|
|
|
|
body)))
|
|
|
|
;; Return modified line
|
|
|
|
body))
|
|
|
|
;; At a list ender: go to next line (side-effects only).
|
|
|
|
((equal "ORG-LIST-END-MARKER" line) (throw 'nextline nil))
|
|
|
|
;; Not at an item: return line unchanged (side-effects only).
|
|
|
|
(t line))))
|
|
|
|
|
|
|
|
(defun org-lparse-bind-local-variables (opt-plist)
|
|
|
|
(mapc (lambda (x)
|
|
|
|
(set (make-local-variable (nth 2 x))
|
|
|
|
(plist-get opt-plist (car x))))
|
|
|
|
org-export-plist-vars))
|
|
|
|
|
|
|
|
(defvar org-lparse-table-rowgrp-open)
|
|
|
|
(defvar org-lparse-table-cur-rowgrp-is-hdr)
|
|
|
|
(defvar org-lparse-footnote-number)
|
|
|
|
(defvar org-lparse-footnote-definitions)
|
2011-09-01 07:02:06 -04:00
|
|
|
(defvar org-lparse-output-buffer nil
|
|
|
|
"Buffer to which `org-do-lparse' writes to.
|
|
|
|
This buffer contains the contents of the to-be-created exported
|
|
|
|
document.")
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defcustom org-lparse-debug nil
|
2011-07-20 05:32:53 -04:00
|
|
|
"Enable or Disable logging of `org-lparse' callbacks.
|
|
|
|
The parameters passed to the backend-registered ENTITY-CONTROL
|
|
|
|
and ENTITY-FORMAT callbacks are logged as comment strings in the
|
|
|
|
exported buffer. (org-lparse-format 'COMMENT fmt args) is used
|
|
|
|
for logging. Customize this variable only if you are an expert
|
|
|
|
user. Valid values of this variable are:
|
|
|
|
nil : Disable logging
|
|
|
|
control : Log all invocations of `org-lparse-begin' and
|
|
|
|
`org-lparse-end' callbacks.
|
|
|
|
format : Log invocations of `org-lparse-format' callbacks.
|
|
|
|
t : Log all invocations of `org-lparse-begin', `org-lparse-end'
|
|
|
|
and `org-lparse-format' callbacks,"
|
|
|
|
:group 'org-lparse
|
|
|
|
:type '(choice
|
|
|
|
(const :tag "Disable" nil)
|
|
|
|
(const :tag "Format callbacks" format)
|
|
|
|
(const :tag "Control callbacks" control)
|
|
|
|
(const :tag "Format and Control callbacks" t)))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-lparse-begin (entity &rest args)
|
2011-08-04 16:31:19 -04:00
|
|
|
"Begin ENTITY in current buffer. ARGS is entity specific.
|
2011-07-01 05:12:19 -04:00
|
|
|
ENTITY can be one of PARAGRAPH, LIST, LIST-ITEM etc.
|
|
|
|
|
|
|
|
Use (org-lparse-begin 'LIST \"o\") to begin a list in current
|
|
|
|
buffer.
|
|
|
|
|
|
|
|
See `org-xhtml-entity-control-callbacks-alist' for more
|
|
|
|
information."
|
|
|
|
(when (and (member org-lparse-debug '(t control))
|
|
|
|
(not (eq entity 'DOCUMENT-CONTENT)))
|
|
|
|
(insert (org-lparse-format 'COMMENT "%s BEGIN %S" entity args)))
|
|
|
|
|
|
|
|
(let ((f (cadr (assoc entity org-lparse-entity-control-callbacks-alist))))
|
|
|
|
(unless f (error "Unknown entity: %s" entity))
|
|
|
|
(apply f args)))
|
|
|
|
|
|
|
|
(defun org-lparse-end (entity &rest args)
|
2011-08-04 16:31:19 -04:00
|
|
|
"Close ENTITY in current buffer. ARGS is entity specific.
|
2011-07-01 05:12:19 -04:00
|
|
|
ENTITY can be one of PARAGRAPH, LIST, LIST-ITEM
|
|
|
|
etc.
|
|
|
|
|
|
|
|
Use (org-lparse-end 'LIST \"o\") to close a list in current
|
|
|
|
buffer.
|
|
|
|
|
|
|
|
See `org-xhtml-entity-control-callbacks-alist' for more
|
|
|
|
information."
|
|
|
|
(when (and (member org-lparse-debug '(t control))
|
|
|
|
(not (eq entity 'DOCUMENT-CONTENT)))
|
|
|
|
(insert (org-lparse-format 'COMMENT "%s END %S" entity args)))
|
|
|
|
|
|
|
|
(let ((f (caddr (assoc entity org-lparse-entity-control-callbacks-alist))))
|
|
|
|
(unless f (error "Unknown entity: %s" entity))
|
|
|
|
(apply f args)))
|
|
|
|
|
|
|
|
(defun org-lparse-begin-paragraph (&optional style)
|
|
|
|
"Insert <p>, but first close previous paragraph if any."
|
|
|
|
(org-lparse-end-paragraph)
|
|
|
|
(org-lparse-begin 'PARAGRAPH style)
|
|
|
|
(setq org-lparse-par-open t))
|
|
|
|
|
|
|
|
(defun org-lparse-end-paragraph ()
|
|
|
|
"Close paragraph if there is one open."
|
|
|
|
(when org-lparse-par-open
|
|
|
|
(org-lparse-end 'PARAGRAPH)
|
|
|
|
(setq org-lparse-par-open nil)))
|
|
|
|
|
2011-08-31 12:53:46 -04:00
|
|
|
(defun org-lparse-end-list-item-1 (&optional type)
|
2011-07-01 05:12:19 -04:00
|
|
|
"Close <li> if necessary."
|
|
|
|
(org-lparse-end-paragraph)
|
2011-08-31 12:53:46 -04:00
|
|
|
(org-lparse-end-list-item (or type "u")))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2013-01-06 12:29:05 -05:00
|
|
|
(org-define-obsolete-function-alias
|
2012-09-27 18:12:53 -04:00
|
|
|
'org-lparse-preprocess-after-blockquote-hook
|
|
|
|
'org-lparse-preprocess-after-blockquote
|
|
|
|
"24.3")
|
|
|
|
|
|
|
|
(defun org-lparse-preprocess-after-blockquote ()
|
2011-10-28 18:12:30 -04:00
|
|
|
"Treat `org-lparse-special-blocks' specially."
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward
|
|
|
|
"^[ \t]*#\\+\\(begin\\|end\\)_\\(\\S-+\\)[ \t]*\\(.*\\)$" nil t)
|
|
|
|
(when (member (downcase (match-string 2)) org-lparse-special-blocks)
|
|
|
|
(replace-match
|
|
|
|
(if (equal (downcase (match-string 1)) "begin")
|
|
|
|
(format "ORG-%s-START %s" (upcase (match-string 2))
|
|
|
|
(match-string 3))
|
|
|
|
(format "ORG-%s-END %s" (upcase (match-string 2))
|
|
|
|
(match-string 3))) t t))))
|
2011-09-01 05:33:52 -04:00
|
|
|
|
2013-01-06 12:29:05 -05:00
|
|
|
(org-define-obsolete-function-alias
|
2012-09-27 18:12:53 -04:00
|
|
|
'org-lparse-strip-experimental-blocks-maybe-hook
|
|
|
|
'org-lparse-strip-experimental-blocks-maybe
|
|
|
|
"24.3")
|
2011-09-01 05:33:52 -04:00
|
|
|
|
2012-09-27 18:12:53 -04:00
|
|
|
(defun org-lparse-strip-experimental-blocks-maybe ()
|
2011-10-28 18:12:30 -04:00
|
|
|
"Strip \"list-table\" and \"annotation\" blocks.
|
|
|
|
Stripping happens only when the exported backend is not one of
|
|
|
|
\"odt\" or \"xhtml\"."
|
|
|
|
(when (not org-lparse-backend)
|
|
|
|
(message "Stripping following blocks - %S" org-lparse-special-blocks)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
(while
|
|
|
|
(re-search-forward
|
|
|
|
"^[ \t]*#\\+begin_\\(\\S-+\\)\\([ \t]+.*\\)?\n\\([^\000]*?\\)\n[ \t]*#\\+end_\\1\\>.*"
|
|
|
|
nil t)
|
|
|
|
(when (member (match-string 1) org-lparse-special-blocks)
|
|
|
|
(replace-match "" t t))))))
|
|
|
|
|
2011-09-01 05:33:52 -04:00
|
|
|
(defvar org-lparse-list-table-p nil
|
2011-10-28 18:12:30 -04:00
|
|
|
"Non-nil if `org-do-lparse' is within a list-table.")
|
2011-09-01 05:33:52 -04:00
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
(defvar org-lparse-dyn-current-environment nil)
|
2011-10-28 18:12:30 -04:00
|
|
|
(defun org-lparse-begin-environment (style &optional env-options-plist)
|
2011-09-01 05:33:52 -04:00
|
|
|
(case style
|
|
|
|
(list-table
|
2011-10-28 18:12:30 -04:00
|
|
|
(setq org-lparse-list-table-p t))
|
2011-12-10 10:09:07 -05:00
|
|
|
(t (setq org-lparse-dyn-current-environment style)
|
|
|
|
(org-lparse-begin 'ENVIRONMENT style env-options-plist))))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
2011-10-28 18:12:30 -04:00
|
|
|
(defun org-lparse-end-environment (style &optional env-options-plist)
|
2011-09-01 05:33:52 -04:00
|
|
|
(case style
|
|
|
|
(list-table
|
|
|
|
(setq org-lparse-list-table-p nil))
|
2011-12-10 10:09:07 -05:00
|
|
|
(t (org-lparse-end 'ENVIRONMENT style env-options-plist)
|
|
|
|
(setq org-lparse-dyn-current-environment nil))))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-lparse-current-environment-p (style)
|
|
|
|
(eq org-lparse-dyn-current-environment style))
|
|
|
|
|
|
|
|
(defun org-lparse-begin-footnote-definition (n)
|
2011-09-01 07:02:06 -04:00
|
|
|
(org-lparse-begin-collect)
|
2011-07-01 05:12:19 -04:00
|
|
|
(setq org-lparse-insert-tag-with-newlines nil)
|
|
|
|
(org-lparse-begin 'FOOTNOTE-DEFINITION n))
|
|
|
|
|
|
|
|
(defun org-lparse-end-footnote-definition (n)
|
|
|
|
(org-lparse-end 'FOOTNOTE-DEFINITION n)
|
|
|
|
(setq org-lparse-insert-tag-with-newlines 'both)
|
2011-09-01 07:02:06 -04:00
|
|
|
(let ((footnote-def (org-lparse-end-collect)))
|
2012-03-01 08:41:53 -05:00
|
|
|
;; Cleanup newlines in footnote definition. This ensures that a
|
|
|
|
;; transcoded line is never (wrongly) broken in to multiple lines.
|
|
|
|
(let ((pos 0))
|
|
|
|
(while (string-match "[\r\n]+" footnote-def pos)
|
|
|
|
(setq pos (1+ (match-beginning 0)))
|
|
|
|
(setq footnote-def (replace-match " " t t footnote-def))))
|
2011-09-01 07:02:06 -04:00
|
|
|
(push (cons n footnote-def) org-lparse-footnote-definitions)))
|
|
|
|
|
|
|
|
(defvar org-lparse-collect-buffer nil
|
|
|
|
"An auxiliary buffer named \"*Org Lparse Collect*\".
|
|
|
|
`org-do-lparse' uses this as output buffer while collecting
|
|
|
|
footnote definitions and table-cell contents of list-tables. See
|
|
|
|
`org-lparse-begin-collect' and `org-lparse-end-collect'.")
|
|
|
|
|
|
|
|
(defvar org-lparse-collect-count nil
|
|
|
|
"Count number of calls to `org-lparse-begin-collect'.
|
|
|
|
Use this counter to catch chained collections if they ever
|
|
|
|
happen.")
|
|
|
|
|
|
|
|
(defun org-lparse-begin-collect ()
|
|
|
|
"Temporarily switch to `org-lparse-collect-buffer'.
|
|
|
|
Also erase it's contents."
|
|
|
|
(unless (zerop org-lparse-collect-count)
|
|
|
|
(error "FIXME (org-lparse.el): Encountered chained collections"))
|
|
|
|
(incf org-lparse-collect-count)
|
|
|
|
(unless org-lparse-collect-buffer
|
|
|
|
(setq org-lparse-collect-buffer
|
|
|
|
(get-buffer-create "*Org Lparse Collect*")))
|
|
|
|
(set-buffer org-lparse-collect-buffer)
|
|
|
|
(erase-buffer))
|
|
|
|
|
|
|
|
(defun org-lparse-end-collect ()
|
|
|
|
"Switch to `org-lparse-output-buffer'.
|
|
|
|
Return contents of `org-lparse-collect-buffer' as a `string'."
|
|
|
|
(assert (> org-lparse-collect-count 0))
|
|
|
|
(decf org-lparse-collect-count)
|
|
|
|
(prog1 (buffer-string)
|
|
|
|
(erase-buffer)
|
|
|
|
(set-buffer org-lparse-output-buffer)))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-lparse-format (entity &rest args)
|
|
|
|
"Format ENTITY in backend-specific way and return it.
|
|
|
|
ARGS is specific to entity being formatted.
|
|
|
|
|
|
|
|
Use (org-lparse-format 'HEADING \"text\" 1) to format text as
|
|
|
|
level 1 heading.
|
|
|
|
|
|
|
|
See `org-xhtml-entity-format-callbacks-alist' for more information."
|
|
|
|
(when (and (member org-lparse-debug '(t format))
|
|
|
|
(not (equal entity 'COMMENT)))
|
|
|
|
(insert (org-lparse-format 'COMMENT "%s: %S" entity args)))
|
|
|
|
(cond
|
|
|
|
((consp entity)
|
|
|
|
(let ((text (pop args)))
|
|
|
|
(apply 'org-lparse-format 'TAGS entity text args)))
|
|
|
|
(t
|
|
|
|
(let ((f (cdr (assoc entity org-lparse-entity-format-callbacks-alist))))
|
|
|
|
(unless f (error "Unknown entity: %s" entity))
|
|
|
|
(apply f args)))))
|
|
|
|
|
|
|
|
(defun org-lparse-insert (entity &rest args)
|
|
|
|
(insert (apply 'org-lparse-format entity args)))
|
|
|
|
|
|
|
|
(defun org-lparse-prepare-toc (lines level-offset opt-plist umax-toc)
|
|
|
|
(let* ((quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
|
|
|
|
(org-min-level (org-get-min-level lines level-offset))
|
|
|
|
(org-last-level org-min-level)
|
|
|
|
level)
|
|
|
|
(with-temp-buffer
|
|
|
|
(org-lparse-bind-local-variables opt-plist)
|
|
|
|
(erase-buffer)
|
2011-11-19 07:43:39 -05:00
|
|
|
(org-lparse-begin 'TOC (nth 3 (plist-get opt-plist :lang-words)) umax-toc)
|
2011-07-01 05:12:19 -04:00
|
|
|
(setq
|
|
|
|
lines
|
|
|
|
(mapcar
|
|
|
|
#'(lambda (line)
|
|
|
|
(when (and (string-match org-todo-line-regexp line)
|
|
|
|
(not (get-text-property 0 'org-protected line))
|
|
|
|
(<= (setq level (org-tr-level
|
|
|
|
(- (match-end 1) (match-beginning 1)
|
|
|
|
level-offset)))
|
|
|
|
umax-toc))
|
|
|
|
(let ((txt (save-match-data
|
|
|
|
(org-xml-encode-org-text-skip-links
|
|
|
|
(org-export-cleanup-toc-line
|
|
|
|
(match-string 3 line)))))
|
|
|
|
(todo (and
|
|
|
|
org-export-mark-todo-in-toc
|
|
|
|
(or (and (match-beginning 2)
|
|
|
|
(not (member (match-string 2 line)
|
|
|
|
org-done-keywords)))
|
|
|
|
(and (= level umax-toc)
|
|
|
|
(org-search-todo-below
|
|
|
|
line lines level)))))
|
|
|
|
tags)
|
|
|
|
;; Check for targets
|
|
|
|
(while (string-match org-any-target-regexp line)
|
|
|
|
(setq line
|
|
|
|
(replace-match
|
|
|
|
(let ((org-lparse-encode-pending t))
|
|
|
|
(org-lparse-format 'FONTIFY
|
2012-08-11 13:10:44 -04:00
|
|
|
(match-string 1 line) "target"))
|
2011-07-01 05:12:19 -04:00
|
|
|
t t line)))
|
|
|
|
(when (string-match
|
|
|
|
(org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
|
|
|
|
(setq tags (match-string 1 txt)
|
|
|
|
txt (replace-match "" t nil txt)))
|
|
|
|
(when (string-match quote-re0 txt)
|
|
|
|
(setq txt (replace-match "" t t txt)))
|
|
|
|
(while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt)
|
|
|
|
(setq txt (replace-match "" t t txt)))
|
|
|
|
(org-lparse-format
|
|
|
|
'TOC-ITEM
|
|
|
|
(let* ((snumber (org-section-number level))
|
|
|
|
(href (replace-regexp-in-string
|
|
|
|
"\\." "-" (format "sec-%s" snumber)))
|
|
|
|
(href
|
|
|
|
(or
|
|
|
|
(cdr (assoc
|
|
|
|
href org-export-preferred-target-alist))
|
|
|
|
href))
|
|
|
|
(href (org-solidify-link-text href)))
|
|
|
|
(org-lparse-format 'TOC-ENTRY snumber todo txt tags href))
|
|
|
|
level org-last-level)
|
|
|
|
(setq org-last-level level)))
|
|
|
|
line)
|
|
|
|
lines))
|
|
|
|
(org-lparse-end 'TOC)
|
|
|
|
(setq org-lparse-toc (buffer-string))))
|
|
|
|
lines)
|
|
|
|
|
|
|
|
(defun org-lparse-format-table-row (fields &optional text-for-empty-fields)
|
2011-09-02 04:57:31 -04:00
|
|
|
(if org-lparse-table-ncols
|
|
|
|
;; second and subsequent rows of the table
|
|
|
|
(when (and org-lparse-list-table-p
|
|
|
|
(> (length fields) org-lparse-table-ncols))
|
|
|
|
(error "Table row has %d columns but header row claims %d columns"
|
|
|
|
(length fields) org-lparse-table-ncols))
|
2011-07-01 05:12:19 -04:00
|
|
|
;; first row of the table
|
|
|
|
(setq org-lparse-table-ncols (length fields))
|
|
|
|
(when org-lparse-table-is-styled
|
|
|
|
(setq org-lparse-table-num-numeric-items-per-column
|
|
|
|
(make-vector org-lparse-table-ncols 0))
|
|
|
|
(setq org-lparse-table-colalign-vector
|
|
|
|
(make-vector org-lparse-table-ncols nil))
|
|
|
|
(let ((c -1))
|
|
|
|
(while (< (incf c) org-lparse-table-ncols)
|
2011-10-16 04:55:28 -04:00
|
|
|
(let* ((col-cookie (cdr (assoc (1+ c) org-lparse-table-colalign-info)))
|
|
|
|
(align (nth 0 col-cookie)))
|
2011-07-01 05:12:19 -04:00
|
|
|
(setf (aref org-lparse-table-colalign-vector c)
|
|
|
|
(cond
|
2011-10-16 04:55:28 -04:00
|
|
|
((string= align "l") "left")
|
|
|
|
((string= align "r") "right")
|
Remove useless (t nil) sexps at the end of some (cond ...) constructs
* org.el (org-compute-latex-and-specials-regexp)
(org-paste-subtree, org-sort-entries, org-store-link)
(org-open-at-point, org-file-remote-p, org-add-log-setup)
(org-set-tags-to, org-fast-tag-selection)
(org-diary-sexp-entry): Ditto.
* org-agenda.el (org-agenda-get-blocks, org-cmp-priority)
(org-cmp-effort, org-cmp-todo-state, org-cmp-alpha)
(org-cmp-tag, org-cmp-time): Remove useless (t nil) sexps at
the end of (cond ...) constructs.
* org-mobile.el (org-mobile-create-index-file): Ditto.
* org-lparse.el (org-lparse-format-table-row): Ditto.
* org-list.el (org-sort-list): Ditto.
* org-id.el (org-id-get): Ditto.
* org-html.el (org-export-html-preprocess): Ditto.
* org-exp.el (org-default-export-plist)
(org-table-clean-before-export): Ditto.
(t nil) in (cond (...) (...) (t nil)) has no other meaning that to
remind the developer that the cond sexp returns nil in case no condition
is matched. For several (cond ...) constructs this is obvious from reading
the code. For others, the reminder might be useful and we leave it.
See the discussion about this on emacs-devel:
http://thread.gmane.org/gmane.emacs.devel/152664
2012-08-19 08:42:54 -04:00
|
|
|
((string= align "c") "center"))))))))
|
2011-07-01 05:12:19 -04:00
|
|
|
(incf org-lparse-table-rownum)
|
|
|
|
(let ((i -1))
|
|
|
|
(org-lparse-format
|
|
|
|
'TABLE-ROW
|
|
|
|
(mapconcat
|
|
|
|
(lambda (x)
|
|
|
|
(when (and (string= x "") text-for-empty-fields)
|
|
|
|
(setq x text-for-empty-fields))
|
|
|
|
(incf i)
|
2011-10-16 04:55:28 -04:00
|
|
|
(let (col-cookie horiz-span)
|
|
|
|
(when org-lparse-table-is-styled
|
|
|
|
(when (and (< i org-lparse-table-ncols)
|
|
|
|
(string-match org-table-number-regexp x))
|
|
|
|
(incf (aref org-lparse-table-num-numeric-items-per-column i)))
|
|
|
|
(setq col-cookie (cdr (assoc (1+ i) org-lparse-table-colalign-info))
|
|
|
|
horiz-span (nth 1 col-cookie)))
|
|
|
|
(org-lparse-format
|
|
|
|
'TABLE-CELL x org-lparse-table-rownum i (or horiz-span 0))))
|
2011-07-01 05:12:19 -04:00
|
|
|
fields "\n"))))
|
|
|
|
|
|
|
|
(defun org-lparse-get (what &optional opt-plist)
|
|
|
|
"Query for value of WHAT for the current backend `org-lparse-backend'.
|
|
|
|
See also `org-lparse-backend-get'."
|
|
|
|
(if (boundp 'org-lparse-backend)
|
|
|
|
(org-lparse-backend-get (symbol-name org-lparse-backend) what opt-plist)
|
|
|
|
(error "org-lparse-backend is not bound yet")))
|
|
|
|
|
|
|
|
(defun org-lparse-backend-get (backend what &optional opt-plist)
|
|
|
|
"Query BACKEND for value of WHAT.
|
|
|
|
Dispatch the call to `org-<backend>-user-get'. If that throws an
|
|
|
|
error, dispatch the call to `org-<backend>-get'. See
|
|
|
|
`org-xhtml-get' for all known settings queried for by
|
|
|
|
`org-lparse' during the course of export."
|
|
|
|
(assert (stringp backend) t)
|
|
|
|
(unless (org-lparse-backend-is-native-p backend)
|
|
|
|
(error "Unknown native backend %s" backend))
|
|
|
|
(let ((backend-get-method (intern (format "org-%s-get" backend)))
|
|
|
|
(backend-user-get-method (intern (format "org-%s-user-get" backend))))
|
|
|
|
(cond
|
|
|
|
((functionp backend-get-method)
|
|
|
|
(condition-case nil
|
|
|
|
(funcall backend-user-get-method what opt-plist)
|
|
|
|
(error (funcall backend-get-method what opt-plist))))
|
|
|
|
(t
|
|
|
|
(error "Native backend %s doesn't define %s" backend backend-get-method)))))
|
|
|
|
|
|
|
|
(defun org-lparse-insert-tag (tag &rest args)
|
|
|
|
(when (member org-lparse-insert-tag-with-newlines '(lead both))
|
|
|
|
(insert "\n"))
|
|
|
|
(insert (apply 'format tag args))
|
|
|
|
(when (member org-lparse-insert-tag-with-newlines '(trail both))
|
|
|
|
(insert "\n")))
|
|
|
|
|
|
|
|
(defun org-lparse-get-targets-from-title (title)
|
|
|
|
(let* ((target (org-get-text-property-any 0 'target title))
|
|
|
|
(extra-targets (assoc target org-export-target-aliases))
|
|
|
|
(target (or (cdr (assoc target org-export-preferred-target-alist))
|
|
|
|
target)))
|
|
|
|
(cons target (remove target extra-targets))))
|
|
|
|
|
|
|
|
(defun org-lparse-suffix-from-snumber (snumber)
|
|
|
|
(let* ((snu (replace-regexp-in-string "\\." "-" snumber))
|
|
|
|
(href (cdr (assoc (concat "sec-" snu)
|
|
|
|
org-export-preferred-target-alist))))
|
|
|
|
(org-solidify-link-text (or href snu))))
|
|
|
|
|
|
|
|
(defun org-lparse-begin-level (level title umax head-count)
|
|
|
|
"Insert a new LEVEL in HTML export.
|
|
|
|
When TITLE is nil, just close all open levels."
|
|
|
|
(org-lparse-end-level level umax)
|
|
|
|
(unless title (error "Why is heading nil"))
|
|
|
|
(let* ((targets (org-lparse-get-targets-from-title title))
|
|
|
|
(target (car targets)) (extra-targets (cdr targets))
|
|
|
|
(target (and target (org-solidify-link-text target)))
|
|
|
|
(extra-class (org-get-text-property-any 0 'html-container-class title))
|
|
|
|
snumber tags level1 class)
|
|
|
|
(when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title)
|
|
|
|
(setq tags (and org-export-with-tags (match-string 1 title)))
|
|
|
|
(setq title (replace-match "" t t title)))
|
|
|
|
(if (> level umax)
|
|
|
|
(progn
|
|
|
|
(if (aref org-levels-open (1- level))
|
2011-08-31 12:53:46 -04:00
|
|
|
(org-lparse-end-list-item-1)
|
2011-07-01 05:12:19 -04:00
|
|
|
(aset org-levels-open (1- level) t)
|
|
|
|
(org-lparse-end-paragraph)
|
2011-08-08 02:01:17 -04:00
|
|
|
(org-lparse-begin-list 'unordered))
|
2011-08-31 12:53:46 -04:00
|
|
|
(org-lparse-begin-list-item
|
|
|
|
'unordered target (org-lparse-format
|
|
|
|
'HEADLINE title extra-targets tags)))
|
2011-07-01 05:12:19 -04:00
|
|
|
(aset org-levels-open (1- level) t)
|
|
|
|
(setq snumber (org-section-number level))
|
|
|
|
(setq level1 (+ level (or (org-lparse-get 'TOPLEVEL-HLEVEL) 1) -1))
|
|
|
|
(unless (= head-count 1)
|
|
|
|
(org-lparse-end-outline-text-or-outline))
|
|
|
|
(org-lparse-begin-outline-and-outline-text
|
|
|
|
level1 snumber title tags target extra-targets extra-class)
|
|
|
|
(org-lparse-begin-paragraph))))
|
|
|
|
|
|
|
|
(defun org-lparse-end-level (level umax)
|
|
|
|
(org-lparse-end-paragraph)
|
|
|
|
(loop for l from org-level-max downto level
|
|
|
|
do (when (aref org-levels-open (1- l))
|
|
|
|
;; Terminate one level in HTML export
|
|
|
|
(if (<= l umax)
|
|
|
|
(org-lparse-end-outline-text-or-outline)
|
2011-08-31 12:53:46 -04:00
|
|
|
(org-lparse-end-list-item-1)
|
2011-08-08 02:01:17 -04:00
|
|
|
(org-lparse-end-list 'unordered))
|
2011-07-01 05:12:19 -04:00
|
|
|
(aset org-levels-open (1- l) nil))))
|
|
|
|
|
|
|
|
(defvar org-lparse-outline-text-open)
|
|
|
|
(defun org-lparse-begin-outline-and-outline-text (level1 snumber title tags
|
2012-08-11 13:10:44 -04:00
|
|
|
target extra-targets
|
|
|
|
extra-class)
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-begin
|
|
|
|
'OUTLINE level1 snumber title tags target extra-targets extra-class)
|
|
|
|
(org-lparse-begin-outline-text level1 snumber extra-class))
|
|
|
|
|
|
|
|
(defun org-lparse-end-outline-text-or-outline ()
|
|
|
|
(cond
|
|
|
|
(org-lparse-outline-text-open
|
|
|
|
(org-lparse-end 'OUTLINE-TEXT)
|
|
|
|
(setq org-lparse-outline-text-open nil))
|
|
|
|
(t (org-lparse-end 'OUTLINE))))
|
|
|
|
|
|
|
|
(defun org-lparse-begin-outline-text (level1 snumber extra-class)
|
|
|
|
(assert (not org-lparse-outline-text-open) t)
|
|
|
|
(setq org-lparse-outline-text-open t)
|
|
|
|
(org-lparse-begin 'OUTLINE-TEXT level1 snumber extra-class))
|
|
|
|
|
|
|
|
(defun org-lparse-html-list-type-to-canonical-list-type (ltype)
|
|
|
|
(cdr (assoc ltype '(("o" . ordered)
|
|
|
|
("u" . unordered)
|
|
|
|
("d" . description)))))
|
|
|
|
|
2011-09-01 14:11:26 -04:00
|
|
|
;; following vars are bound during `org-do-lparse'
|
|
|
|
(defvar org-lparse-list-stack)
|
|
|
|
(defvar org-lparse-list-table:table-row)
|
|
|
|
(defvar org-lparse-list-table:lines)
|
|
|
|
|
|
|
|
;; Notes on LIST-TABLES
|
|
|
|
;; ====================
|
2011-10-28 18:12:30 -04:00
|
|
|
;; Lists withing "list-table" blocks (as shown below)
|
2011-09-01 14:11:26 -04:00
|
|
|
;;
|
|
|
|
;; #+begin_list-table
|
|
|
|
;; - Row 1
|
|
|
|
;; - 1.1
|
|
|
|
;; - 1.2
|
|
|
|
;; - 1.3
|
|
|
|
;; - Row 2
|
|
|
|
;; - 2.1
|
|
|
|
;; - 2.2
|
|
|
|
;; - 2.3
|
|
|
|
;; #+end_list-table
|
|
|
|
;;
|
|
|
|
;; will be exported as though it were a table as shown below.
|
|
|
|
;;
|
|
|
|
;; | Row 1 | 1.1 | 1.2 | 1.3 |
|
|
|
|
;; | Row 2 | 2.1 | 2.2 | 2.3 |
|
|
|
|
;;
|
|
|
|
;; Note that org-tables are NOT multi-line and each line is mapped to
|
|
|
|
;; a unique row in the exported document. So if an exported table
|
|
|
|
;; needs to contain a single paragraph (with copious text) it needs to
|
2012-08-11 13:10:44 -04:00
|
|
|
;; be typed up in a single line. Editing such long lines using the
|
2011-09-01 14:11:26 -04:00
|
|
|
;; table editor will be a cumbersome task. Furthermore inclusion of
|
|
|
|
;; multi-paragraph text in a table cell is well-nigh impossible.
|
|
|
|
;;
|
|
|
|
;; LIST-TABLEs are meant to circumvent the above problems with
|
|
|
|
;; org-tables.
|
|
|
|
;;
|
|
|
|
;; Note that in the example above the list items could be paragraphs
|
|
|
|
;; themselves and the list can be arbitrarily deep.
|
|
|
|
;;
|
|
|
|
;; Inspired by following thread:
|
|
|
|
;; https://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01101.html
|
|
|
|
|
2011-08-08 02:01:17 -04:00
|
|
|
(defun org-lparse-begin-list (ltype)
|
Add support for indented tables in ODT export
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
2012-01-16 15:55:47 -05:00
|
|
|
(push ltype org-lparse-list-stack)
|
|
|
|
(let ((list-level (length org-lparse-list-stack)))
|
|
|
|
(cond
|
|
|
|
((not org-lparse-list-table-p)
|
|
|
|
(org-lparse-begin 'LIST ltype))
|
|
|
|
;; process LIST-TABLE
|
|
|
|
((= 1 list-level)
|
|
|
|
;; begin LIST-TABLE
|
|
|
|
(setq org-lparse-list-table:lines nil)
|
|
|
|
(setq org-lparse-list-table:table-row nil))
|
|
|
|
((= 2 list-level)
|
|
|
|
(ignore))
|
|
|
|
(t
|
|
|
|
(org-lparse-begin 'LIST ltype)))))
|
2011-08-08 02:01:17 -04:00
|
|
|
|
|
|
|
(defun org-lparse-end-list (ltype)
|
Add support for indented tables in ODT export
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
2012-01-16 15:55:47 -05:00
|
|
|
(pop org-lparse-list-stack)
|
|
|
|
(let ((list-level (length org-lparse-list-stack)))
|
|
|
|
(cond
|
|
|
|
((not org-lparse-list-table-p)
|
|
|
|
(org-lparse-end 'LIST ltype))
|
|
|
|
;; process LIST-TABLE
|
|
|
|
((= 0 list-level)
|
|
|
|
;; end LIST-TABLE
|
|
|
|
(insert (org-lparse-format-list-table
|
|
|
|
(nreverse org-lparse-list-table:lines))))
|
|
|
|
((= 1 list-level)
|
|
|
|
(ignore))
|
|
|
|
(t
|
|
|
|
(org-lparse-end 'LIST ltype)))))
|
2011-08-08 02:01:17 -04:00
|
|
|
|
2011-08-31 12:53:46 -04:00
|
|
|
(defun org-lparse-begin-list-item (ltype &optional arg headline)
|
Add support for indented tables in ODT export
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
2012-01-16 15:55:47 -05:00
|
|
|
(let ((list-level (length org-lparse-list-stack)))
|
|
|
|
(cond
|
|
|
|
((not org-lparse-list-table-p)
|
|
|
|
(org-lparse-begin 'LIST-ITEM ltype arg headline))
|
|
|
|
;; process LIST-TABLE
|
|
|
|
((= 1 list-level)
|
|
|
|
;; begin TABLE-ROW for LIST-TABLE
|
|
|
|
(setq org-lparse-list-table:table-row nil)
|
|
|
|
(org-lparse-begin-list-table:table-cell))
|
|
|
|
((= 2 list-level)
|
|
|
|
;; begin TABLE-CELL for LIST-TABLE
|
|
|
|
(org-lparse-begin-list-table:table-cell))
|
|
|
|
(t
|
|
|
|
(org-lparse-begin 'LIST-ITEM ltype arg headline)))))
|
2011-08-31 12:53:46 -04:00
|
|
|
|
|
|
|
(defun org-lparse-end-list-item (ltype)
|
Add support for indented tables in ODT export
* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries. These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.
* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified. If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified. If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count. Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.
* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed. Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New. List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.
OpenDocument doesn't permit tables to occur in the middle of a
list. Use list continuations and indented sections to typeset
indented tables.
Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html
2012-01-16 15:55:47 -05:00
|
|
|
(let ((list-level (length org-lparse-list-stack)))
|
|
|
|
(cond
|
|
|
|
((not org-lparse-list-table-p)
|
|
|
|
(org-lparse-end 'LIST-ITEM ltype))
|
|
|
|
;; process LIST-TABLE
|
|
|
|
((= 1 list-level)
|
|
|
|
;; end TABLE-ROW for LIST-TABLE
|
|
|
|
(org-lparse-end-list-table:table-cell)
|
|
|
|
(push (nreverse org-lparse-list-table:table-row)
|
|
|
|
org-lparse-list-table:lines))
|
|
|
|
((= 2 list-level)
|
|
|
|
;; end TABLE-CELL for LIST-TABLE
|
|
|
|
(org-lparse-end-list-table:table-cell))
|
|
|
|
(t
|
|
|
|
(org-lparse-end 'LIST-ITEM ltype)))))
|
2011-09-01 14:11:26 -04:00
|
|
|
|
|
|
|
(defvar org-lparse-list-table:table-cell-open)
|
|
|
|
(defun org-lparse-begin-list-table:table-cell ()
|
|
|
|
(org-lparse-end-list-table:table-cell)
|
|
|
|
(setq org-lparse-list-table:table-cell-open t)
|
|
|
|
(org-lparse-begin-collect)
|
|
|
|
(org-lparse-begin-paragraph))
|
|
|
|
|
|
|
|
(defun org-lparse-end-list-table:table-cell ()
|
|
|
|
(when org-lparse-list-table:table-cell-open
|
|
|
|
(setq org-lparse-list-table:table-cell-open nil)
|
|
|
|
(org-lparse-end-paragraph)
|
|
|
|
(push (org-lparse-end-collect)
|
|
|
|
org-lparse-list-table:table-row)))
|
2011-08-31 12:53:46 -04:00
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
(defvar org-lparse-table-rowgrp-info)
|
|
|
|
(defun org-lparse-begin-table-rowgroup (&optional is-header-row)
|
|
|
|
(push (cons (1+ org-lparse-table-rownum) :start) org-lparse-table-rowgrp-info)
|
|
|
|
(org-lparse-begin 'TABLE-ROWGROUP is-header-row))
|
|
|
|
|
|
|
|
(defun org-lparse-end-table ()
|
|
|
|
(when org-lparse-table-is-styled
|
|
|
|
;; column groups
|
|
|
|
(unless (car org-table-colgroup-info)
|
|
|
|
(setq org-table-colgroup-info
|
|
|
|
(cons :start (cdr org-table-colgroup-info))))
|
|
|
|
|
|
|
|
;; column alignment
|
|
|
|
(let ((c -1))
|
|
|
|
(mapc
|
|
|
|
(lambda (x)
|
|
|
|
(incf c)
|
|
|
|
(setf (aref org-lparse-table-colalign-vector c)
|
|
|
|
(or (aref org-lparse-table-colalign-vector c)
|
|
|
|
(if (> (/ (float x) (1+ org-lparse-table-rownum))
|
|
|
|
org-table-number-fraction)
|
|
|
|
"right" "left"))))
|
|
|
|
org-lparse-table-num-numeric-items-per-column)))
|
|
|
|
(org-lparse-end 'TABLE))
|
|
|
|
|
|
|
|
(defvar org-lparse-encode-pending nil)
|
|
|
|
|
|
|
|
(defun org-lparse-format-tags (tag text prefix suffix &rest args)
|
|
|
|
(cond
|
|
|
|
((consp tag)
|
|
|
|
(concat prefix (apply 'format (car tag) args) text suffix
|
|
|
|
(format (cdr tag))))
|
|
|
|
((stringp tag) ; singleton tag
|
|
|
|
(concat prefix (apply 'format tag args) text))))
|
|
|
|
|
|
|
|
(defun org-xml-fix-class-name (kwd) ; audit callers of this function
|
|
|
|
"Turn todo keyword into a valid class name.
|
|
|
|
Replaces invalid characters with \"_\"."
|
|
|
|
(save-match-data
|
|
|
|
(while (string-match "[^a-zA-Z0-9_]" kwd)
|
|
|
|
(setq kwd (replace-match "_" t t kwd))))
|
|
|
|
kwd)
|
|
|
|
|
|
|
|
(defun org-lparse-format-todo (todo)
|
|
|
|
(org-lparse-format 'FONTIFY
|
|
|
|
(concat
|
|
|
|
(ignore-errors (org-lparse-get 'TODO-KWD-CLASS-PREFIX))
|
|
|
|
(org-xml-fix-class-name todo))
|
|
|
|
(list (if (member todo org-done-keywords) "done" "todo")
|
|
|
|
todo)))
|
|
|
|
|
|
|
|
(defun org-lparse-format-extra-targets (extra-targets)
|
|
|
|
(if (not extra-targets) ""
|
2012-08-11 13:10:44 -04:00
|
|
|
(mapconcat (lambda (x)
|
|
|
|
(setq x (org-solidify-link-text
|
|
|
|
(if (org-uuidgen-p x) (concat "ID-" x) x)))
|
|
|
|
(org-lparse-format 'ANCHOR "" x))
|
|
|
|
extra-targets "")))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-lparse-format-org-tags (tags)
|
|
|
|
(if (not tags) ""
|
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY (mapconcat
|
|
|
|
(lambda (x)
|
|
|
|
(org-lparse-format
|
|
|
|
'FONTIFY x
|
|
|
|
(concat
|
|
|
|
(ignore-errors (org-lparse-get 'TAG-CLASS-PREFIX))
|
|
|
|
(org-xml-fix-class-name x))))
|
|
|
|
(org-split-string tags ":")
|
|
|
|
(org-lparse-format 'SPACES 1)) "tag")))
|
|
|
|
|
|
|
|
(defun org-lparse-format-section-number (&optional snumber level)
|
|
|
|
(and org-export-with-section-numbers
|
2011-07-02 18:37:29 -04:00
|
|
|
(not org-lparse-body-only) snumber level
|
2011-07-01 05:12:19 -04:00
|
|
|
(org-lparse-format 'FONTIFY snumber (format "section-number-%d" level))))
|
|
|
|
|
|
|
|
(defun org-lparse-warn (msg)
|
2011-07-08 06:28:35 -04:00
|
|
|
(if (not org-lparse-use-flashy-warning)
|
|
|
|
(message msg)
|
|
|
|
(put-text-property 0 (length msg) 'face 'font-lock-warning-face msg)
|
|
|
|
(message msg)
|
|
|
|
(sleep-for 3)))
|
2011-07-01 05:12:19 -04:00
|
|
|
|
|
|
|
(defun org-xml-format-href (s)
|
|
|
|
"Make sure the S is valid as a href reference in an XHTML document."
|
|
|
|
(save-match-data
|
|
|
|
(let ((start 0))
|
|
|
|
(while (string-match "&" s start)
|
|
|
|
(setq start (+ (match-beginning 0) 3)
|
|
|
|
s (replace-match "&" t t s)))))
|
|
|
|
s)
|
|
|
|
|
|
|
|
(defun org-xml-format-desc (s)
|
|
|
|
"Make sure the S is valid as a description in a link."
|
|
|
|
(if (and s (not (get-text-property 1 'org-protected s)))
|
|
|
|
(save-match-data
|
|
|
|
(org-xml-encode-org-text s))
|
|
|
|
s))
|
|
|
|
|
|
|
|
(provide 'org-lparse)
|
|
|
|
|
2012-10-02 02:50:46 -04:00
|
|
|
;; Local variables:
|
|
|
|
;; generated-autoload-file: "org-loaddefs.el"
|
|
|
|
;; End:
|
|
|
|
|
2011-07-01 05:12:19 -04:00
|
|
|
;;; org-lparse.el ends here
|