Move new export framework files into core

* contrib/README: Remove references to new export framework.
* contrib/lisp/org-e-ascii.el: Removed file.
* contrib/lisp/org-e-beamer.el: Removed file.
* contrib/lisp/org-e-confluence.el: Removed file.
* contrib/lisp/org-e-groff.el: Removed file.
* contrib/lisp/org-e-html.el: Removed file.
* contrib/lisp/org-e-icalendar.el: Removed file.
* contrib/lisp/org-e-latex.el: Removed file.
* contrib/lisp/org-e-man.el: Removed file.
* contrib/lisp/org-e-odt.el: Removed file.
* contrib/lisp/org-e-publish.el: Removed file.
* contrib/lisp/org-e-texinfo.el: Removed file.
* contrib/lisp/org-export.el: Removed file.
* contrib/lisp/org-koma-letter.el: Removed file.
* contrib/lisp/org-md.el: Removed file.
* contrib/lisp/ox-confluence.el: New file.
* contrib/lisp/ox-groff.el: New file.
* contrib/lisp/ox-koma-letter.el: New file.
* lisp/ox-ascii.el: New file.
* lisp/ox-beamer.el: New file.
* lisp/ox-html.el: New file.
* lisp/ox-icalendar.el: New file.
* lisp/ox-jsinfo.el: New file.
* lisp/ox-latex.el: New file.
* lisp/ox-man.el: New file.
* lisp/ox-md.el: New file.
* lisp/ox-odt.el: New file.
* lisp/ox-publish.el: New file.
* lisp/ox-texinfo.el: New file.
* lisp/ox.el: New file.
* mk/org-fixup.el (org-make-org-loaddefs): Install new export
  framework and back-end files.
* testing/lisp/test-org-export.el: Removed file.
* testing/lisp/test-ox.el: New file.
This commit is contained in:
Nicolas Goaziou 2013-01-27 23:11:34 +01:00
parent 33c4f6233d
commit 8dd2bfc291
19 changed files with 4626 additions and 4217 deletions

View File

@ -27,7 +27,6 @@ org-eval.el --- The <lisp> tag, adapted from Muse
org-eval-light.el --- Evaluate in-buffer code on demand
org-exp-bibtex.el --- Export citations to LaTeX and HTML
org-expiry.el --- Expiry mechanism for Org entries
org-export.el --- Generic Export Engine For Org
org-export-generic.el --- Export framework for configurable backends
org-git-link.el --- Provide org links to specific file version
org-interactive-query.el --- Interactive modification of tags query
@ -55,21 +54,6 @@ org-velocity.el --- something like Notational Velocity for Org
org-wikinodes.el --- CamelCase wiki-like links for Org
EXPORT ENGINE AND BACKENDS (emacs-lisp code)
============================================
org-export.el --- the new export engine
org-e-latex.el --- LaTeX export backend
org-e-ascii.el --- ASCII export backend
org-e-beamer.el --- Beamer export backend
org-e-groff.el --- Groff export backend
org-e-html.el --- HTML export backend
org-e-man.el --- man pages export backend
org-e-odt.el --- ODT export backend
org-e-texinfo.el --- TeXinfo export backend
org-md.el --- MarkDown export backend
BABEL
=====
library-of-babel.org --- Documentation for the library of babel

View File

@ -1,4 +1,4 @@
;;; org-e-confluence --- Confluence Wiki Back-End for Org Export Engine
;;; ox-confluence --- Confluence Wiki Back-End for Org Export Engine
;; Copyright (C) 2012 Sébastien Delafond
@ -22,58 +22,58 @@
;;; Commentary:
;;
;; org-confluence.el lets you convert Org files to confluence files using
;; the org-export.el experimental engine.
;; ox-confluence.el lets you convert Org files to confluence files
;; using the ox.el export engine.
;;
;; Put this file into your load-path and the following into your ~/.emacs:
;; (require 'org-confluence)
;; (require 'ox-confluence)
;;
;; Export Org files to confluence:
;; M-x org-e-confluence-export-as-confluence RET
;; M-x org-confluence-export-as-confluence RET
;;
;;; Code:
(require 'org-export)
(require 'org-e-ascii)
(require 'ox)
(require 'ox-ascii)
;; Define the backend itself
(org-export-define-derived-backend e-confluence e-ascii
:translate-alist ((bold . org-e-confluence-bold)
(example-block . org-e-confluence-example-block)
(fixed-width . org-e-confluence-fixed-width)
(footnote-definition . org-e-confluence-empty)
(footnote-reference . org-e-confluence-empty)
(headline . org-e-confluence-headline)
(italic . org-e-confluence-italic)
(link . org-e-confluence-link)
(section . org-e-confluence-section)
(src-block . org-e-confluence-src-block)
(strike-through . org-e-confluence-strike-through)
(table . org-e-confluence-table)
(table-cell . org-e-confluence-table-cell)
(table-row . org-e-confluence-table-row)
(template . org-e-confluence-template)
(underline . org-e-confluence-underline)))
(org-export-define-derived-backend confluence ascii
:translate-alist ((bold . org-confluence-bold)
(example-block . org-confluence-example-block)
(fixed-width . org-confluence-fixed-width)
(footnote-definition . org-confluence-empty)
(footnote-reference . org-confluence-empty)
(headline . org-confluence-headline)
(italic . org-confluence-italic)
(link . org-confluence-link)
(section . org-confluence-section)
(src-block . org-confluence-src-block)
(strike-through . org-confluence-strike-through)
(table . org-confluence-table)
(table-cell . org-confluence-table-cell)
(table-row . org-confluence-table-row)
(template . org-confluence-template)
(underline . org-confluence-underline)))
;; All the functions we use
(defun org-e-confluence-bold (bold contents info)
(defun org-confluence-bold (bold contents info)
(format "*%s*" contents))
(defun org-e-confluence-empty (empy contents info)
(defun org-confluence-empty (empy contents info)
"")
(defun org-e-confluence-example-block (example-block contents info)
(defun org-confluence-example-block (example-block contents info)
;; FIXME: provide a user-controlled variable for theme
(let ((content (org-export-format-code-default example-block info)))
(org-e-confluence--block "none" "Confluence" content)))
(org-confluence--block "none" "Confluence" content)))
(defun org-e-confluence-italic (italic contents info)
(defun org-confluence-italic (italic contents info)
(format "_%s_" contents))
(defun org-e-confluence-fixed-width (fixed-width contents info)
(defun org-confluence-fixed-width (fixed-width contents info)
(format "\{\{%s\}\}" contents))
(defun org-e-confluence-headline (headline contents info)
(defun org-confluence-headline (headline contents info)
(let ((low-level-rank (org-export-low-level-p headline info))
(text (org-export-data (org-element-property :title headline)
info))
@ -83,7 +83,7 @@
(if (org-string-nw-p contents) contents
""))))
(defun org-e-confluence-link (link desc info)
(defun org-confluence-link (link desc info)
(let ((raw-link (org-element-property :raw-link link)))
(concat "["
(when (org-string-nw-p desc) (format "%s|" desc))
@ -93,45 +93,45 @@
(t
raw-link))
"]")))
(defun org-e-confluence-section (section contents info)
(defun org-confluence-section (section contents info)
contents)
(defun org-e-confluence-src-block (src-block contents info)
(defun org-confluence-src-block (src-block contents info)
;; FIXME: provide a user-controlled variable for theme
(let* ((lang (org-element-property :language src-block))
(language (if (string= lang "sh") "bash" ;; FIXME: provide a mapping of some sort
lang))
(content (org-export-format-code-default src-block info)))
(org-e-confluence--block language "Emacs" content)))
(org-confluence--block language "Emacs" content)))
(defun org-e-confluence-strike-through (strike-through contents info)
(defun org-confluence-strike-through (strike-through contents info)
(format "-%s-" contents))
(defun org-e-confluence-table (table contents info)
(defun org-confluence-table (table contents info)
contents)
(defun org-e-confluence-table-row (table-row contents info)
(defun org-confluence-table-row (table-row contents info)
(concat
(if (org-string-nw-p contents) (format "|%s" contents)
"")
(when (org-export-table-row-ends-header-p table-row info)
"|")))
(defun org-e-confluence-table-cell (table-cell contents info)
(defun org-confluence-table-cell (table-cell contents info)
(let ((table-row (org-export-get-parent table-cell)))
(concat
(when (org-export-table-row-starts-header-p table-row info)
"|")
contents "|")))
(defun org-e-confluence-template (contents info)
(defun org-confluence-template (contents info)
(let ((depth (plist-get info :with-toc)))
(concat (when depth "\{toc\}\n\n") contents)))
(defun org-e-confluence-underline (underline contents info)
(defun org-confluence-underline (underline contents info)
(format "+%s+" contents))
(defun org-e-confluence--block (language theme contents)
(defun org-confluence--block (language theme contents)
(concat "\{code:theme=" theme
(when language (format "|language=%s" language))
"}\n"
@ -139,7 +139,7 @@
"\{code\}\n"))
;; main interactive entrypoint
(defun org-e-confluence-export-as-confluence
(defun org-confluence-export-as-confluence
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a text buffer.
@ -178,14 +178,14 @@ is non-nil."
(insert output)
(goto-char (point-min))
(text-mode)
(org-export-add-to-stack (current-buffer) 'e-confluence)))
`(org-export-as 'e-confluence ,subtreep ,visible-only ,body-only
(org-export-add-to-stack (current-buffer) 'confluence)))
`(org-export-as 'confluence ,subtreep ,visible-only ,body-only
',ext-plist))
(let ((outbuf (org-export-to-buffer
'e-confluence "*Org E-Confluence Export*"
'confluence "*Org E-Confluence Export*"
subtreep visible-only body-only ext-plist)))
(with-current-buffer outbuf (text-mode))
(when org-export-show-temporary-export-buffer
(switch-to-buffer-other-window outbuf)))))
(provide 'org-e-confluence)
(provide 'ox-confluence)

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
;;; org-koma-letter.el --- KOMA Scrlttr2 Back-End for Org Export Engine
;;; ox-koma-letter.el --- KOMA Scrlttr2 Back-End for Org Export Engine
;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
@ -29,7 +29,7 @@
;; `org-koma-letter-export-to-latex' ("tex" file) and
;; `org-koma-letter-export-to-pdf' ("pdf" file).
;;
;; On top of buffer keywords supported by `e-latex' back-end (see
;; On top of buffer keywords supported by `latex' back-end (see
;; `org-e-latex-options-alist'), this back-end introduces the
;; following keywords: "CLOSING" (see `org-koma-letter-closing'),
;; "FROM_ADDRESS" (see `org-koma-letter-from-address'), "LCO" (see
@ -42,7 +42,7 @@
;; `org-e-latex-classes' in order to use the KOMA Scrlttr2 class. For
;; example, you can use the following code:
;;
;; (add-to-list 'org-e-latex-classes
;; (add-to-list 'org-latex-classes
;; '("my-letter"
;; "\\documentclass\[%
;; DIV=14,
@ -65,7 +65,7 @@
;;; Code:
(require 'org-e-latex)
(require 'ox-latex)
;;; User-Configurable Variables
@ -109,7 +109,7 @@
;;; Define Back-End
(org-export-define-derived-backend koma-letter e-latex
(org-export-define-derived-backend koma-letter latex
:options-alist
((:closing "CLOSING" nil org-koma-letter-closing)
(:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline)
@ -164,7 +164,7 @@ channel."
;; Handle specifically BEAMER and TOC (headlines only) keywords.
;; Otherwise, fallback to `e-latex' back-end.
(if (equal key "KOMA-LETTER") value
(org-export-with-backend 'e-latex keyword contents info))))
(org-export-with-backend 'latex keyword contents info))))
;;;; Template
@ -213,7 +213,8 @@ holding export options."
"\\begin{document}\n\n"
(format "\\setkomavar{subject}{%s}\n\n"
(org-export-data (plist-get info :title) info))
(format "\\begin{letter}{%%\n%s}\n\n" (or (plist-get info :to-address) "no address given"))
(format "\\begin{letter}{%%\n%s}\n\n"
(or (plist-get info :to-address) "no address given"))
;; Opening.
(format "\\opening{%s}\n\n" (plist-get info :opening))
;; Letter body.
@ -365,5 +366,5 @@ Return PDF file's name."
nil subtreep visible-only body-only ext-plist))))
(provide 'org-koma-letter)
;;; org-koma-letter.el ends here
(provide 'ox-koma-letter)
;;; ox-koma-letter.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
;;; org-e-beamer.el --- Beamer Back-End for Org Export Engine
;;; ox-beamer.el --- Beamer Back-End for Org Export Engine
;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
@ -26,24 +26,29 @@
;; document.
;;
;; Depending on the desired output format, three commands are provided
;; for export: `org-e-beamer-export-as-latex' (temporary buffer),
;; `org-e-beamer-export-to-latex' ("tex" file) and
;; `org-e-beamer-export-to-pdf' ("pdf" file).
;; for export: `org-beamer-export-as-latex' (temporary buffer),
;; `org-beamer-export-to-latex' ("tex" file) and
;; `org-beamer-export-to-pdf' ("pdf" file).
;;
;; On top of buffer keywords and options items supported by `e-latex'
;; back-end (see `org-e-latex-options-alist'), this back-end
;; introduces the following keywords: "BEAMER_THEME",
;; "BEAMER_COLOR_THEME", "BEAMER_FONT_THEME", "BEAMER_INNER_THEME" and
;; "BEAMER_OUTER_THEME". All accept options in square brackets.
;; This back-end supports every buffer keyword, attribute and options
;; items (see `org-latex-options-alist') already supported by `latex'
;; back-end. As such, it is suggested to add an entry in
;; `org-latex-classes' variable which is appropriate for Beamer
;; export.
;;
;; On top of this, the `beamer' back-end also introduces the following
;; keywords: "BEAMER_THEME", "BEAMER_COLOR_THEME",
;; "BEAMER_FONT_THEME", "BEAMER_INNER_THEME" and "BEAMER_OUTER_THEME".
;; All accept options in square brackets.
;;
;; Moreover, headlines now fall into three categories: sectioning
;; elements, frames and blocks.
;;
;; - Like `e-latex' back-end sectioning elements are still set through
;; `org-e-latex-classes' variable.
;; - Like `latex' back-end sectioning elements are still set through
;; `org-latex-classes' variable.
;;
;; - Headlines become frames when their level is equal to
;; `org-e-beamer-frame-level' (or "H" value in the OPTIONS line).
;; `org-beamer-frame-level' (or "H" value in the OPTIONS line).
;; Though, if an headline in the current tree has a "BEAMER_env"
;; (see below) property set to either "frame" or "fullframe", its
;; level overrides the variable. A "fullframe" is a frame with an
@ -51,8 +56,8 @@
;;
;; - All frames' children become block environments. Special block
;; types can be enforced by setting headline's "BEAMER_env" property
;; to an appropriate value (see `org-e-beamer-environments-default'
;; for supported value and `org-e-beamer-environments-extra' for
;; to an appropriate value (see `org-beamer-environments-default'
;; for supported value and `org-beamer-environments-extra' for
;; adding more).
;;
;; - As a special case, if the "BEAMER_env" property is set to either
@ -86,25 +91,25 @@
;; among `bold', `item', `link', `radio-target' and `target' will
;; control its overlay specifications.
;;
;; On the minor mode side, `org-e-beamer-select-environment' (bound by
;; default to "C-c C-b") and `org-e-beamer-insert-options-template'
;; are the two entry points.
;; On the minor mode side, `org-beamer-select-environment' (bound by
;; default to "C-c C-b") and `org-beamer-insert-options-template' are
;; the two entry points.
;;; Code:
(require 'org-e-latex)
(require 'ox-latex)
;;; User-Configurable Variables
(defgroup org-export-e-beamer nil
(defgroup org-export-beamer nil
"Options specific for using the beamer class in LaTeX export."
:tag "Org Beamer"
:group 'org-export
:version "24.2")
(defcustom org-e-beamer-frame-level 1
(defcustom org-beamer-frame-level 1
"The level at which headlines become frames.
Headlines at a lower level will be translated into a sectioning
@ -121,36 +126,36 @@ appendix or a note.
This integer is relative to the minimal level of an headline
within the parse tree, defined as 1."
:group 'org-export-e-beamer
:group 'org-export-beamer
:type 'integer)
(defcustom org-e-beamer-frame-default-options ""
(defcustom org-beamer-frame-default-options ""
"Default options string to use for frames.
For example, it could be set to \"allowframebreaks\"."
:group 'org-export-e-beamer
:group 'org-export-beamer
:type '(string :tag "[options]"))
(defcustom org-e-beamer-column-view-format
(defcustom org-beamer-column-view-format
"%45ITEM %10BEAMER_env(Env) %10BEAMER_act(Act) %4BEAMER_col(Col) %8BEAMER_opt(Opt)"
"Column view format that should be used to fill the template."
:group 'org-export-e-beamer
:group 'org-export-beamer
:type '(choice
(const :tag "Do not insert Beamer column view format" nil)
(string :tag "Beamer column view format")))
(defcustom org-e-beamer-theme "default"
(defcustom org-beamer-theme "default"
"Default theme used in Beamer presentations."
:group 'org-export-e-beamer
:group 'org-export-beamer
:type '(choice
(const :tag "Do not insert a Beamer theme" nil)
(string :tag "Beamer theme")))
(defcustom org-e-beamer-environments-extra nil
(defcustom org-beamer-environments-extra nil
"Environments triggered by tags in Beamer export.
Each entry has 4 elements:
name Name of the environment
key Selection key for `org-e-beamer-select-environment'
key Selection key for `org-beamer-select-environment'
open The opening template for the environment, with the following escapes
%a the action/overlay specification
%A the default action/overlay specification
@ -159,7 +164,7 @@ open The opening template for the environment, with the following escapes
%H if there is headline text, that text in {} braces
%U if there is headline text, that text in [] brackets
close The closing string of the environment."
:group 'org-export-e-beamer
:group 'org-export-beamer
:type '(repeat
(list
(string :tag "Environment")
@ -167,26 +172,26 @@ close The closing string of the environment."
(string :tag "Begin")
(string :tag "End"))))
(defcustom org-e-beamer-outline-frame-title "Outline"
(defcustom org-beamer-outline-frame-title "Outline"
"Default title of a frame containing an outline."
:group 'org-export-e-beamer
:group 'org-export-beamer
:type '(string :tag "Outline frame title"))
(defcustom org-e-beamer-outline-frame-options ""
(defcustom org-beamer-outline-frame-options ""
"Outline frame options appended after \\begin{frame}.
You might want to put e.g. \"allowframebreaks=0.9\" here."
:group 'org-export-e-beamer
:group 'org-export-beamer
:type '(string :tag "Outline frame options"))
;;; Internal Variables
(defconst org-e-beamer-column-widths
(defconst org-beamer-column-widths
"0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
"The column widths that should be installed as allowed property values.")
(defconst org-e-beamer-environments-special
(defconst org-beamer-environments-special
'(("againframe" "A")
("appendix" "x")
("column" "c")
@ -198,11 +203,11 @@ You might want to put e.g. \"allowframebreaks=0.9\" here."
("noteNH" "N"))
"Alist of environments treated in a special way by the back-end.
Keys are environment names, as strings, values are bindings used
in `org-e-beamer-select-environment'. Environments listed here,
in `org-beamer-select-environment'. Environments listed here,
along with their binding, are hard coded and cannot be modified
through `org-e-beamer-environments-extra' variable.")
through `org-beamer-environments-extra' variable.")
(defconst org-e-beamer-environments-default
(defconst org-beamer-environments-default
'(("block" "b" "\\begin{block}%a{%h}" "\\end{block}")
("alertblock" "a" "\\begin{alertblock}%a{%h}" "\\end{alertblock}")
("verse" "v" "\\begin{verse}%a %% %h" "\\end{verse}")
@ -217,9 +222,9 @@ through `org-e-beamer-environments-extra' variable.")
("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
"Environments triggered by properties in Beamer export.
These are the defaults - for user definitions, see
`org-e-beamer-environments-extra'.")
`org-beamer-environments-extra'.")
(defconst org-e-beamer-verbatim-elements
(defconst org-beamer-verbatim-elements
'(code example-block fixed-width inline-src-block src-block verbatim)
"List of element or object types producing verbatim text.
This is used internally to determine when a frame should have the
@ -229,7 +234,7 @@ This is used internally to determine when a frame should have the
;;; Internal functions
(defun org-e-beamer--normalize-argument (argument type)
(defun org-beamer--normalize-argument (argument type)
"Return ARGUMENT string with proper boundaries.
TYPE is a symbol among the following:
@ -251,11 +256,11 @@ TYPE is a symbol among the following:
(format "[%s]" argument)))
(otherwise argument))))
(defun org-e-beamer--element-has-overlay-p (element)
(defun org-beamer--element-has-overlay-p (element)
"Non-nil when ELEMENT has an overlay specified.
An element has an overlay specification when it starts with an
`e-beamer' export-snippet whose value is between angular
brackets. Return overlay specification, as a string, or nil."
`beamer' export-snippet whose value is between angular brackets.
Return overlay specification, as a string, or nil."
(let ((first-object (car (org-element-contents element))))
(when (eq (org-element-type first-object) 'export-snippet)
(let ((value (org-element-property :value first-object)))
@ -265,35 +270,35 @@ brackets. Return overlay specification, as a string, or nil."
;;; Define Back-End
(org-export-define-derived-backend e-beamer e-latex
(org-export-define-derived-backend beamer latex
:export-block "BEAMER"
:menu-entry
(?l 1
((?B "As TEX buffer (Beamer)" org-e-beamer-export-as-latex)
(?b "As TEX file (Beamer)" org-e-beamer-export-to-latex)
(?P "As PDF file (Beamer)" org-e-beamer-export-to-pdf)
((?B "As TEX buffer (Beamer)" org-beamer-export-as-latex)
(?b "As TEX file (Beamer)" org-beamer-export-to-latex)
(?P "As PDF file (Beamer)" org-beamer-export-to-pdf)
(?O "As PDF file and open (Beamer)"
(lambda (a s v b)
(if a (org-e-beamer-export-to-pdf t s v b)
(org-open-file (org-e-beamer-export-to-pdf nil s v b)))))))
(if a (org-beamer-export-to-pdf t s v b)
(org-open-file (org-beamer-export-to-pdf nil s v b)))))))
:options-alist
((:beamer-theme "BEAMER_THEME" nil org-e-beamer-theme)
((:beamer-theme "BEAMER_THEME" nil org-beamer-theme)
(:beamer-color-theme "BEAMER_COLOR_THEME" nil nil t)
(:beamer-font-theme "BEAMER_FONT_THEME" nil nil t)
(:beamer-inner-theme "BEAMER_INNER_THEME" nil nil t)
(:beamer-outer-theme "BEAMER_OUTER_THEME" nil nil t)
(:headline-levels nil "H" org-e-beamer-frame-level))
:translate-alist ((bold . org-e-beamer-bold)
(export-block . org-e-beamer-export-block)
(export-snippet . org-e-beamer-export-snippet)
(headline . org-e-beamer-headline)
(item . org-e-beamer-item)
(keyword . org-e-beamer-keyword)
(link . org-e-beamer-link)
(plain-list . org-e-beamer-plain-list)
(radio-target . org-e-beamer-radio-target)
(target . org-e-beamer-target)
(template . org-e-beamer-template)))
(:headline-levels nil "H" org-beamer-frame-level))
:translate-alist ((bold . org-beamer-bold)
(export-block . org-beamer-export-block)
(export-snippet . org-beamer-export-snippet)
(headline . org-beamer-headline)
(item . org-beamer-item)
(keyword . org-beamer-keyword)
(link . org-beamer-link)
(plain-list . org-beamer-plain-list)
(radio-target . org-beamer-radio-target)
(target . org-beamer-target)
(template . org-beamer-template)))
@ -301,18 +306,18 @@ brackets. Return overlay specification, as a string, or nil."
;;;; Bold
(defun org-e-beamer-bold (bold contents info)
(defun org-beamer-bold (bold contents info)
"Transcode BLOCK object into Beamer code.
CONTENTS is the text being bold. INFO is a plist used as
a communication channel."
(format "\\alert%s{%s}"
(or (org-e-beamer--element-has-overlay-p bold) "")
(or (org-beamer--element-has-overlay-p bold) "")
contents))
;;;; Export Block
(defun org-e-beamer-export-block (export-block contents info)
(defun org-beamer-export-block (export-block contents info)
"Transcode an EXPORT-BLOCK element into Beamer code.
CONTENTS is nil. INFO is a plist used as a communication
channel."
@ -322,16 +327,16 @@ channel."
;;;; Export Snippet
(defun org-e-beamer-export-snippet (export-snippet contents info)
(defun org-beamer-export-snippet (export-snippet contents info)
"Transcode an EXPORT-SNIPPET object into Beamer code.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(let ((backend (org-export-snippet-backend export-snippet))
(value (org-element-property :value export-snippet)))
;; Only "e-latex" and "e-beamer" snippets are retained.
(cond ((eq backend 'e-latex) value)
;; Ignore "e-beamer" snippets specifying overlays.
((and (eq backend 'e-beamer)
;; Only "latex" and "beamer" snippets are retained.
(cond ((eq backend 'latex) value)
;; Ignore "beamer" snippets specifying overlays.
((and (eq backend 'beamer)
(or (org-export-get-previous-element export-snippet info)
(not (string-match "\\`<.*>\\'" value))))
value))))
@ -340,19 +345,19 @@ channel."
;;;; Headline
;;
;; The main function to translate an headline is
;; `org-e-beamer-headline'.
;; `org-beamer-headline'.
;;
;; Depending on the level at which an headline is considered as
;; a frame (given by `org-e-beamer--frame-level'), the headline is
;; either a section (`org-e-beamer--format-section'), a frame
;; (`org-e-beamer--format-frame') or a block
;; (`org-e-beamer--format-block').
;; a frame (given by `org-beamer--frame-level'), the headline is
;; either a section (`org-beamer--format-section'), a frame
;; (`org-beamer--format-frame') or a block
;; (`org-beamer--format-block').
;;
;; `org-e-beamer-headline' also takes care of special environments
;; `org-beamer-headline' also takes care of special environments
;; like "ignoreheading", "note", "noteNH", "appendix" and
;; "againframe".
(defun org-e-beamer--get-label (headline info)
(defun org-beamer--get-label (headline info)
"Return label for HEADLINE, as a string.
INFO is a plist used as a communication channel.
@ -369,7 +374,7 @@ function assumes HEADLINE will be treated as a frame."
(org-export-get-headline-number headline info)
"-")))))
(defun org-e-beamer--frame-level (headline info)
(defun org-beamer--frame-level (headline info)
"Return frame level in subtree containing HEADLINE.
INFO is a plist used as a communication channel."
(or
@ -387,23 +392,22 @@ INFO is a plist used as a communication channel."
(and env (member (downcase env) '("frame" "fullframe"))
(org-export-get-relative-level headline info)))
;; 3. Look for "frame" environment in sub-tree.
(org-element-map
headline 'headline
(lambda (hl)
(let ((env (org-element-property :beamer-env hl)))
(when (and env (member (downcase env) '("frame" "fullframe")))
(org-export-get-relative-level hl info))))
info 'first-match)
(org-element-map headline 'headline
(lambda (hl)
(let ((env (org-element-property :beamer-env hl)))
(when (and env (member (downcase env) '("frame" "fullframe")))
(org-export-get-relative-level hl info))))
info 'first-match)
;; 4. No "frame" environment in tree: use default value.
(plist-get info :headline-levels)))
(defun org-e-beamer--format-section (headline contents info)
(defun org-beamer--format-section (headline contents info)
"Format HEADLINE as a sectioning part.
CONTENTS holds the contents of the headline. INFO is a plist
used as a communication channel."
;; Use `e-latex' back-end output, inserting overlay specifications
;; Use `latex' back-end output, inserting overlay specifications
;; if possible.
(let ((latex-headline (org-export-with-backend 'e-latex headline contents info))
(let ((latex-headline (org-export-with-backend 'latex headline contents info))
(mode-specs (org-element-property :beamer-act headline)))
(if (and mode-specs
(string-match "\\`\\\\\\(.*?\\)\\(?:\\*\\|\\[.*\\]\\)?{"
@ -413,14 +417,14 @@ used as a communication channel."
nil nil latex-headline 1)
latex-headline)))
(defun org-e-beamer--format-frame (headline contents info)
(defun org-beamer--format-frame (headline contents info)
"Format HEADLINE as a frame.
CONTENTS holds the contents of the headline. INFO is a plist
used as a communication channel."
(let ((fragilep
;; FRAGILEP is non-nil when HEADLINE contains an element
;; among `org-e-beamer-verbatim-elements'.
(org-element-map headline org-e-beamer-verbatim-elements 'identity
;; among `org-beamer-verbatim-elements'.
(org-element-map headline org-beamer-verbatim-elements 'identity
info 'first-match)))
(concat "\\begin{frame}"
;; Overlay specification, if any. When surrounded by
@ -430,15 +434,15 @@ used as a communication channel."
(cond
((not action) "")
((string-match "\\`\\[.*\\]\\'" action )
(org-e-beamer--normalize-argument action 'defaction))
(t (org-e-beamer--normalize-argument action 'action))))
(org-beamer--normalize-argument action 'defaction))
(t (org-beamer--normalize-argument action 'action))))
;; Options, if any.
(let* ((beamer-opt (org-element-property :beamer-opt headline))
(options
;; Collect options from default value and headline's
;; properties. Also add a label for links.
(append
(org-split-string org-e-beamer-frame-default-options ",")
(org-split-string org-beamer-frame-default-options ",")
(and beamer-opt
(org-split-string
;; Remove square brackets if user provided
@ -452,9 +456,9 @@ used as a communication channel."
(string-match "\\(^\\|,\\)label=" beamer-opt))
(list
(format "label=%s"
(org-e-beamer--get-label headline info)))))))
(org-beamer--get-label headline info)))))))
;; Change options list into a string.
(org-e-beamer--normalize-argument
(org-beamer--normalize-argument
(mapconcat
'identity
(if (or (not fragilep) (member "fragile" options)) options
@ -479,7 +483,7 @@ used as a communication channel."
(replace-regexp-in-string "\\`\n*" "\\& " contents))
"\\end{frame}")))
(defun org-e-beamer--format-block (headline contents info)
(defun org-beamer--format-block (headline contents info)
"Format HEADLINE as a block.
CONTENTS holds the contents of the headline. INFO is a plist
used as a communication channel."
@ -498,13 +502,13 @@ used as a communication channel."
(t (downcase env)))))
(env-format (unless (member environment '("column" "columns"))
(assoc environment
(append org-e-beamer-environments-special
org-e-beamer-environments-extra
org-e-beamer-environments-default))))
(append org-beamer-environments-special
org-beamer-environments-extra
org-beamer-environments-default))))
(title (org-export-data (org-element-property :title headline) info))
(options (let ((options (org-element-property :beamer-opt headline)))
(if (not options) ""
(org-e-beamer--normalize-argument options 'option))))
(org-beamer--normalize-argument options 'option))))
;; Start a "columns" environment when explicitly requested or
;; when there is no previous headline or the previous
;; headline do not have a BEAMER_column property.
@ -559,10 +563,10 @@ used as a communication channel."
((not action) (list (cons "a" "") (cons "A" "")))
((string-match "\\`\\[.*\\]\\'" action)
(list
(cons "A" (org-e-beamer--normalize-argument action 'defaction))
(cons "A" (org-beamer--normalize-argument action 'defaction))
(cons "a" "")))
(t
(list (cons "a" (org-e-beamer--normalize-argument action 'action))
(list (cons "a" (org-beamer--normalize-argument action 'action))
(cons "A" "")))))
(list (cons "o" options)
(cons "h" title)
@ -575,13 +579,13 @@ used as a communication channel."
(when column-width "\\end{column}\n")
(when end-columns-p "\\end{columns}"))))
(defun org-e-beamer-headline (headline contents info)
(defun org-beamer-headline (headline contents info)
"Transcode HEADLINE element into Beamer code.
CONTENTS is the contents of the headline. INFO is a plist used
as a communication channel."
(unless (org-element-property :footnote-section-p headline)
(let ((level (org-export-get-relative-level headline info))
(frame-level (org-e-beamer--frame-level headline info))
(frame-level (org-beamer--frame-level headline info))
(environment (let ((env (org-element-property :beamer-env headline)))
(if (stringp env) (downcase env) "block"))))
(cond
@ -595,14 +599,14 @@ as a communication channel."
;; Overlay specification.
(let ((overlay (org-element-property :beamer-act headline)))
(when overlay
(org-e-beamer--normalize-argument
(org-beamer--normalize-argument
overlay
(if (string-match "^\\[.*\\]$" overlay) 'defaction
'action))))
;; Options.
(let ((options (org-element-property :beamer-opt headline)))
(when options
(org-e-beamer--normalize-argument options 'option)))
(org-beamer--normalize-argument options 'option)))
;; Resolve reference provided by "BEAMER_ref"
;; property. This is done by building a minimal fake
;; link and calling the appropriate resolve function,
@ -621,7 +625,7 @@ as a communication channel."
(org-export-resolve-id-link link info))))
;; Now use user-defined label provided in TARGET
;; headline, or fallback to standard one.
(format "{%s}" (org-e-beamer--get-label target info)))))))
(format "{%s}" (org-beamer--get-label target info)))))))
;; Case 2: Creation of an appendix is requested.
((equal environment "appendix")
(concat "\\appendix"
@ -644,25 +648,25 @@ as a communication channel."
(org-trim contents))))
;; Case 5: HEADLINE is a frame.
((= level frame-level)
(org-e-beamer--format-frame headline contents info))
(org-beamer--format-frame headline contents info))
;; Case 6: Regular section, extracted from
;; `org-e-latex-classes'.
;; `org-latex-classes'.
((< level frame-level)
(org-e-beamer--format-section headline contents info))
(org-beamer--format-section headline contents info))
;; Case 7: Otherwise, HEADLINE is a block.
(t (org-e-beamer--format-block headline contents info))))))
(t (org-beamer--format-block headline contents info))))))
;;;; Item
(defun org-e-beamer-item (item contents info)
(defun org-beamer-item (item contents info)
"Transcode an ITEM element into Beamer code.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let ((action (let ((first-element (car (org-element-contents item))))
(and (eq (org-element-type first-element) 'paragraph)
(org-e-beamer--element-has-overlay-p first-element))))
(output (org-export-with-backend 'e-latex item contents info)))
(org-beamer--element-has-overlay-p first-element))))
(output (org-export-with-backend 'latex item contents info)))
(if (not action) output
;; If the item starts with a paragraph and that paragraph starts
;; with an export snippet specifying an overlay, insert it after
@ -672,14 +676,14 @@ contextual information."
;;;; Keyword
(defun org-e-beamer-keyword (keyword contents info)
(defun org-beamer-keyword (keyword contents info)
"Transcode a KEYWORD element into Beamer code.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(let ((key (org-element-property :key keyword))
(value (org-element-property :value keyword)))
;; Handle specifically BEAMER and TOC (headlines only) keywords.
;; Otherwise, fallback to `e-latex' back-end.
;; Otherwise, fallback to `latex' back-end.
(cond
((equal key "BEAMER") value)
((and (equal key "TOC") (string-match "\\<headlines\\>" value))
@ -693,12 +697,12 @@ channel."
(when (wholenump depth) (format "\\setcounter{tocdepth}{%s}\n" depth))
"\\tableofcontents" options "\n"
"\\end{frame}")))
(t (org-export-with-backend 'e-latex keyword contents info)))))
(t (org-export-with-backend 'latex keyword contents info)))))
;;;; Link
(defun org-e-beamer-link (link contents info)
(defun org-beamer-link (link contents info)
"Transcode a LINK object into Beamer code.
CONTENTS is the description part of the link. INFO is a plist
used as a communication channel."
@ -710,7 +714,7 @@ used as a communication channel."
(let ((destination (org-export-resolve-radio-link link info)))
(when destination
(format "\\hyperlink%s{%s}{%s}"
(or (org-e-beamer--element-has-overlay-p link) "")
(or (org-beamer--element-has-overlay-p link) "")
(org-export-solidify-link-text path)
(org-export-data (org-element-contents destination) info)))))
((and (member type '("custom-id" "fuzzy" "id"))
@ -729,18 +733,18 @@ used as a communication channel."
(if (and (plist-get info :section-numbers) (not contents))
(format "\\ref{%s}" label)
(format "\\hyperlink%s{%s}{%s}"
(or (org-e-beamer--element-has-overlay-p link) "")
(or (org-beamer--element-has-overlay-p link) "")
label
contents))))
(target
(let ((path (org-export-solidify-link-text path)))
(if (not contents) (format "\\ref{%s}" path)
(format "\\hyperlink%s{%s}{%s}"
(or (org-e-beamer--element-has-overlay-p link) "")
(or (org-beamer--element-has-overlay-p link) "")
path
contents))))))))
;; Otherwise, use `e-latex' back-end.
(t (org-export-with-backend 'e-latex link contents info)))))
;; Otherwise, use `latex' back-end.
(t (org-export-with-backend 'latex link contents info)))))
;;;; Plain List
@ -748,7 +752,7 @@ used as a communication channel."
;; Plain lists support `:environment', `:overlay' and `:options'
;; attributes.
(defun org-e-beamer-plain-list (plain-list contents info)
(defun org-beamer-plain-list (plain-list contents info)
"Transcode a PLAIN-LIST element into Beamer code.
CONTENTS is the contents of the list. INFO is a plist holding
contextual information."
@ -759,16 +763,16 @@ contextual information."
((eq type 'ordered) "enumerate")
((eq type 'descriptive) "description")
(t "itemize")))))
(org-e-latex--wrap-label
(org-latex--wrap-label
plain-list
(format "\\begin{%s}%s%s\n%s\\end{%s}"
latex-type
;; Default overlay specification, if any.
(org-e-beamer--normalize-argument
(org-beamer--normalize-argument
(format "%s" (or (plist-get attributes :overlay) ""))
'defaction)
;; Second optional argument depends on the list type.
(org-e-beamer--normalize-argument
(org-beamer--normalize-argument
(format "%s" (or (plist-get attributes :options) ""))
'option)
;; Eventually insert contents and close environment.
@ -778,12 +782,12 @@ contextual information."
;;;; Radio Target
(defun org-e-beamer-radio-target (radio-target text info)
(defun org-beamer-radio-target (radio-target text info)
"Transcode a RADIO-TARGET object into Beamer code.
TEXT is the text of the target. INFO is a plist holding
contextual information."
(format "\\hypertarget%s{%s}{%s}"
(or (org-e-beamer--element-has-overlay-p radio-target) "")
(or (org-beamer--element-has-overlay-p radio-target) "")
(org-export-solidify-link-text
(org-element-property :value radio-target))
text))
@ -791,7 +795,7 @@ contextual information."
;;;; Target
(defun org-e-beamer-target (target contents info)
(defun org-beamer-target (target contents info)
"Transcode a TARGET object into Beamer code.
CONTENTS is nil. INFO is a plist holding contextual
information."
@ -801,10 +805,10 @@ information."
;;;; Template
;;
;; Template used is similar to the one used in `e-latex' back-end,
;; Template used is similar to the one used in `latex' back-end,
;; excepted for the table of contents and Beamer themes.
(defun org-e-beamer-template (contents info)
(defun org-beamer-template (contents info)
"Return complete document string after Beamer conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
@ -817,7 +821,7 @@ holding export options."
(let ((class (plist-get info :latex-class))
(class-options (plist-get info :latex-class-options)))
(org-element-normalize-string
(let* ((header (nth 1 (assoc class org-e-latex-classes)))
(let* ((header (nth 1 (assoc class org-latex-classes)))
(document-class-string
(and (stringp header)
(if (not class-options) header
@ -825,8 +829,8 @@ holding export options."
"^[ \t]*\\\\documentclass\\(\\(\\[.*\\]\\)?\\)"
class-options header t nil 1)))))
(when document-class-string
(org-e-latex--guess-babel-language
(org-e-latex--guess-inputenc
(org-latex--guess-babel-language
(org-latex--guess-inputenc
(org-splice-latex-header
document-class-string
org-export-latex-default-packages-alist ; defined in org.el
@ -868,9 +872,17 @@ holding export options."
(author (format "\\author{%s}\n" author))
(t "\\author{}\n")))
;; 6. Date.
(let ((date (and (plist-get info :with-date)
(org-export-data (plist-get info :date) info))))
(format "\\date{%s}\n" (or date "")))
(let ((date (and (plist-get info :with-date) (plist-get info :date))))
(format "\\date{%s}\n"
(cond ((not date) "")
;; If `:date' consists in a single timestamp and
;; `:date-format' is provided, apply it.
((and (plist-get info :date-format)
(not (cdr date))
(eq (org-element-type (car date)) 'timestamp))
(org-timestamp-format
(car date) (plist-get info :date-format)))
(t (org-export-data date info)))))
;; 7. Title
(format "\\title{%s}\n" title)
;; 8. Hyperref options.
@ -885,19 +897,19 @@ holding export options."
;; 10. Title command.
(org-element-normalize-string
(cond ((string= "" title) nil)
((not (stringp org-e-latex-title-command)) nil)
((not (stringp org-latex-title-command)) nil)
((string-match "\\(?:[^%]\\|^\\)%s"
org-e-latex-title-command)
(format org-e-latex-title-command title))
(t org-e-latex-title-command)))
org-latex-title-command)
(format org-latex-title-command title))
(t org-latex-title-command)))
;; 11. Table of contents.
(let ((depth (plist-get info :with-toc)))
(when depth
(concat
(format "\\begin{frame}%s{%s}\n"
(org-e-beamer--normalize-argument
org-e-beamer-outline-frame-options 'option)
org-e-beamer-outline-frame-title)
(org-beamer--normalize-argument
org-beamer-outline-frame-options 'option)
org-beamer-outline-frame-title)
(when (wholenump depth)
(format "\\setcounter{tocdepth}{%d}\n" depth))
"\\tableofcontents\n"
@ -919,26 +931,26 @@ holding export options."
;;; Minor Mode
(defvar org-e-beamer-mode-map (make-sparse-keymap)
"The keymap for `org-e-beamer-mode'.")
(define-key org-e-beamer-mode-map "\C-c\C-b" 'org-e-beamer-select-environment)
(defvar org-beamer-mode-map (make-sparse-keymap)
"The keymap for `org-beamer-mode'.")
(define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-select-environment)
;;;###autoload
(define-minor-mode org-e-beamer-mode
(define-minor-mode org-beamer-mode
"Support for editing Beamer oriented Org mode files."
nil " Bm" 'org-e-beamer-mode-map)
nil " Bm" 'org-beamer-mode-map)
(when (fboundp 'font-lock-add-keywords)
(font-lock-add-keywords
'org-mode
'((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-e-beamer-tag prepend))
'((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
'prepend))
(defface org-e-beamer-tag '((t (:box (:line-width 1 :color grey40))))
(defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
"The special face for beamer tags."
:group 'org-export-e-beamer)
:group 'org-export-beamer)
(defun org-e-beamer-property-changed (property value)
(defun org-beamer-property-changed (property value)
"Track the BEAMER_env property with tags.
PROPERTY is the name of the modified property. VALUE is its new
value."
@ -955,33 +967,33 @@ value."
((equal property "BEAMER_col")
(org-toggle-tag "BMCOL" (if (org-string-nw-p value) 'on 'off)))))
(add-hook 'org-property-changed-functions 'org-e-beamer-property-changed)
(add-hook 'org-property-changed-functions 'org-beamer-property-changed)
(defun org-e-beamer-allowed-property-values (property)
(defun org-beamer-allowed-property-values (property)
"Supply allowed values for PROPERTY."
(cond
((and (equal property "BEAMER_env")
(not (org-entry-get nil (concat property "_ALL") 'inherit)))
;; If no allowed values for BEAMER_env have been defined,
;; supply all defined environments
(mapcar 'car (append org-e-beamer-environments-special
org-e-beamer-environments-extra
org-e-beamer-environments-default)))
(mapcar 'car (append org-beamer-environments-special
org-beamer-environments-extra
org-beamer-environments-default)))
((and (equal property "BEAMER_col")
(not (org-entry-get nil (concat property "_ALL") 'inherit)))
;; If no allowed values for BEAMER_col have been defined,
;; supply some
(org-split-string org-e-beamer-column-widths " "))))
(org-split-string org-beamer-column-widths " "))))
(add-hook 'org-property-allowed-value-functions
'org-e-beamer-allowed-property-values)
'org-beamer-allowed-property-values)
;;; Commands
;;;###autoload
(defun org-e-beamer-export-as-latex
(defun org-beamer-export-as-latex
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer as a Beamer buffer.
@ -1008,30 +1020,30 @@ EXT-PLIST, when provided, is a property list with external
parameters overriding Org default settings, but still inferior to
file-local settings.
Export is done in a buffer named \"*Org E-BEAMER Export*\", which
Export is done in a buffer named \"*Org BEAMER Export*\", which
will be displayed when `org-export-show-temporary-export-buffer'
is non-nil."
(interactive)
(if async
(org-export-async-start
(lambda (output)
(with-current-buffer (get-buffer-create "*Org E-BEAMER Export*")
(with-current-buffer (get-buffer-create "*Org BEAMER Export*")
(erase-buffer)
(insert output)
(goto-char (point-min))
(LaTeX-mode)
(org-export-add-to-stack (current-buffer) 'e-beamer)))
`(org-export-as 'e-beamer ,subtreep ,visible-only ,body-only
(org-export-add-to-stack (current-buffer) 'beamer)))
`(org-export-as 'beamer ,subtreep ,visible-only ,body-only
',ext-plist))
(let ((outbuf (org-export-to-buffer
'e-beamer "*Org E-BEAMER Export*"
'beamer "*Org BEAMER Export*"
subtreep visible-only body-only ext-plist)))
(with-current-buffer outbuf (LaTeX-mode))
(when org-export-show-temporary-export-buffer
(switch-to-buffer-other-window outbuf)))))
;;;###autoload
(defun org-e-beamer-export-to-latex
(defun org-beamer-export-to-latex
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer as a Beamer presentation (tex).
@ -1063,16 +1075,16 @@ Return output file's name."
(let ((outfile (org-export-output-file-name ".tex" subtreep)))
(if async
(org-export-async-start
(lambda (f) (org-export-add-to-stack f 'e-beamer))
(lambda (f) (org-export-add-to-stack f 'beamer))
`(expand-file-name
(org-export-to-file
'e-beamer ,outfile ,subtreep ,visible-only ,body-only
'beamer ,outfile ,subtreep ,visible-only ,body-only
',ext-plist)))
(org-export-to-file
'e-beamer outfile subtreep visible-only body-only ext-plist))))
'beamer outfile subtreep visible-only body-only ext-plist))))
;;;###autoload
(defun org-e-beamer-export-to-pdf
(defun org-beamer-export-to-pdf
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer as a Beamer presentation (PDF).
@ -1104,18 +1116,18 @@ Return PDF file's name."
(if async
(let ((outfile (org-export-output-file-name ".tex" subtreep)))
(org-export-async-start
(lambda (f) (org-export-add-to-stack f 'e-beamer))
(lambda (f) (org-export-add-to-stack f 'beamer))
`(expand-file-name
(org-e-latex-compile
(org-latex-compile
(org-export-to-file
'e-beamer ,outfile ,subtreep ,visible-only ,body-only
'beamer ,outfile ,subtreep ,visible-only ,body-only
',ext-plist)))))
(org-e-latex-compile
(org-e-beamer-export-to-latex
(org-latex-compile
(org-beamer-export-to-latex
nil subtreep visible-only body-only ext-plist))))
;;;###autoload
(defun org-e-beamer-select-environment ()
(defun org-beamer-select-environment ()
"Select the environment to be used by beamer for this entry.
While this uses (for convenience) a tag selection interface, the
result of this command will be that the BEAMER_env *property* of
@ -1124,11 +1136,11 @@ the entry is set.
In addition to this, the command will also set a tag as a visual
aid, but the tag does not have any semantic meaning."
(interactive)
;; Make sure `org-e-beamer-environments-special' has a higher
;; priority than `org-e-beamer-environments-extra'.
(let* ((envs (append org-e-beamer-environments-special
org-e-beamer-environments-extra
org-e-beamer-environments-default))
;; Make sure `org-beamer-environments-special' has a higher
;; priority than `org-beamer-environments-extra'.
(let* ((envs (append org-beamer-environments-special
org-beamer-environments-extra
org-beamer-environments-default))
(org-tag-alist
(append '((:startgroup))
(mapcar (lambda (e) (cons (concat "B_" (car e))
@ -1163,7 +1175,7 @@ aid, but the tag does not have any semantic meaning."
(t (org-entry-delete nil "BEAMER_env"))))))
;;;###autoload
(defun org-e-beamer-insert-options-template (&optional kind)
(defun org-beamer-insert-options-template (&optional kind)
"Insert a settings template, to make sure users do this right."
(interactive (progn
(message "Current [s]ubtree or [g]lobal?")
@ -1176,19 +1188,18 @@ aid, but the tag does not have any semantic meaning."
(org-entry-put nil "EXPORT_LaTeX_CLASS" "beamer")
(org-entry-put nil "EXPORT_LaTeX_CLASS_OPTIONS" "[presentation]")
(org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
(when org-e-beamer-column-view-format
(org-entry-put nil "COLUMNS" org-e-beamer-column-view-format))
(org-entry-put nil "BEAMER_col_ALL" org-e-beamer-column-widths))
(when org-beamer-column-view-format
(org-entry-put nil "COLUMNS" org-beamer-column-view-format))
(org-entry-put nil "BEAMER_col_ALL" org-beamer-column-widths))
(insert "#+LaTeX_CLASS: beamer\n")
(insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
(when org-e-beamer-theme
(insert "#+BEAMER_THEME: " org-e-beamer-theme "\n"))
(when org-e-beamer-column-view-format
(insert "#+COLUMNS: " org-e-beamer-column-view-format "\n"))
(insert "#+PROPERTY: BEAMER_col_ALL " org-e-beamer-column-widths "\n")))
(when org-beamer-theme (insert "#+BEAMER_THEME: " org-beamer-theme "\n"))
(when org-beamer-column-view-format
(insert "#+COLUMNS: " org-beamer-column-view-format "\n"))
(insert "#+PROPERTY: BEAMER_col_ALL " org-beamer-column-widths "\n")))
;;;###autoload
(defun org-e-beamer-publish-to-latex (plist filename pub-dir)
(defun org-beamer-publish-to-latex (plist filename pub-dir)
"Publish an Org file to a Beamer presentation (LaTeX).
FILENAME is the filename of the Org file to be published. PLIST
@ -1196,10 +1207,10 @@ is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-e-publish-org-to 'e-beamer filename ".tex" plist pub-dir))
(org-publish-org-to 'beamer filename ".tex" plist pub-dir))
;;;###autoload
(defun org-e-beamer-publish-to-pdf (plist filename pub-dir)
(defun org-beamer-publish-to-pdf (plist filename pub-dir)
"Publish an Org file to a Beamer presentation (PDF, via LaTeX).
FILENAME is the filename of the Org file to be published. PLIST
@ -1207,13 +1218,18 @@ is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
;; Unlike to `org-e-beamer-publish-to-latex', PDF file is generated
;; in working directory and then moved to publishing directory.
(org-e-publish-attachment
;; Unlike to `org-beamer-publish-to-latex', PDF file is generated in
;; working directory and then moved to publishing directory.
(org-publish-attachment
plist
(org-e-latex-compile (org-e-publish-org-to 'e-beamer filename ".tex" plist))
(org-latex-compile (org-publish-org-to 'beamer filename ".tex" plist))
pub-dir))
(provide 'org-e-beamer)
;;; org-e-beamer.el ends here
(provide 'ox-beamer)
;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:
;;; ox-beamer.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
;;; org-e-icalendar.el --- iCalendar Back-End for Org Export Engine
;;; ox-icalendar.el --- iCalendar Back-End for Org Export Engine
;; Copyright (C) 2004-2012 Free Software Foundation, Inc.
@ -26,14 +26,14 @@
;; exporter.
;;
;; It provides three commands for export, depending on the chosen
;; source and desired output: `org-e-icalendar-export-to-ics' (current
;; file), `org-e-icalendar-export-agenda-files' (agenda files into
;; separate calendars) and `org-e-icalendar-combined-agenda-file'
;; source and desired output: `org-icalendar-export-to-ics' (current
;; file), `org-icalendar-export-agenda-files' (agenda files into
;; separate calendars) and `org-icalendar-combined-agenda-file'
;; (agenda files into one combined calendar).
;;
;; It also provides the `org-e-icalendar-export-current-agenda'
;; function, which will create a calendar file from current agenda
;; view. It is meant to be called through `org-agenda-write'.
;; It also provides `org-icalendar-export-current-agenda' function,
;; which will create a calendar file from current agenda view. It is
;; meant to be called through `org-agenda-write'.
;;
;; This back-end introduces a new keyword, ICALENDAR_EXCLUDE_TAGS,
;; which allows to specify a different set of exclude tags from other
@ -43,26 +43,26 @@
;;; Code:
(require 'org-e-ascii)
(require 'ox-ascii)
(declare-function org-bbdb-anniv-export-ical "org-bbdb" nil)
;;; User-Configurable Variables
(defgroup org-export-e-icalendar nil
(defgroup org-export-icalendar nil
"Options specific for iCalendar export back-end."
:tag "Org iCalendar"
:group 'org-export)
(defcustom org-e-icalendar-combined-agenda-file "~/org.ics"
(defcustom org-icalendar-combined-agenda-file "~/org.ics"
"The file name for the iCalendar file covering all agenda files.
This file is created with the command \\[org-e-icalendar-combine-agenda-files].
This file is created with the command \\[org-icalendar-combine-agenda-files].
The file name should be absolute. It will be overwritten without warning."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type 'file)
(defcustom org-e-icalendar-alarm-time 0
(defcustom org-icalendar-alarm-time 0
"Number of minutes for triggering an alarm for exported timed events.
A zero value (the default) turns off the definition of an alarm trigger
@ -71,36 +71,36 @@ for timed events. If non-zero, alarms are created.
- a single alarm per entry is defined
- The alarm will go off N minutes before the event
- only a DISPLAY action is defined."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:version "24.1"
:type 'integer)
(defcustom org-e-icalendar-combined-name "OrgMode"
(defcustom org-icalendar-combined-name "OrgMode"
"Calendar name for the combined iCalendar representing all agenda files."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type 'string)
(defcustom org-e-icalendar-combined-description ""
(defcustom org-icalendar-combined-description ""
"Calendar description for the combined iCalendar (all agenda files)."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type 'string)
(defcustom org-e-icalendar-exclude-tags nil
(defcustom org-icalendar-exclude-tags nil
"Tags that exclude a tree from export.
This variable allows to specify different exclude tags from other
back-ends. It can also be set with the ICAL_EXCLUDE_TAGS
keyword."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(repeat (string :tag "Tag")))
(defcustom org-e-icalendar-use-deadline '(event-if-not-todo todo-due)
(defcustom org-icalendar-use-deadline '(event-if-not-todo todo-due)
"Contexts where iCalendar export should use a deadline time stamp.
This is a list with several symbols in it. Valid symbol are:
`event-if-todo' Deadlines in TODO entries become calendar events.
`event-if-not-todo' Deadlines in non-TODO entries become calendar events.
`todo-due' Use deadlines in TODO entries as due-dates"
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(set :greedy t
(const :tag "Deadlines in non-TODO entries become events"
event-if-not-todo)
@ -109,7 +109,7 @@ This is a list with several symbols in it. Valid symbol are:
(const :tag "Deadlines in TODO entries become due-dates"
todo-due)))
(defcustom org-e-icalendar-use-scheduled '(todo-start)
(defcustom org-icalendar-use-scheduled '(todo-start)
"Contexts where iCalendar export should use a scheduling time stamp.
This is a list with several symbols in it. Valid symbol are:
@ -118,7 +118,7 @@ This is a list with several symbols in it. Valid symbol are:
`todo-start' Scheduling time stamps in TODO entries become start date.
Some calendar applications show TODO entries only after
that date."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(set :greedy t
(const :tag
"SCHEDULED timestamps in non-TODO entries become events"
@ -128,7 +128,7 @@ This is a list with several symbols in it. Valid symbol are:
(const :tag "SCHEDULED in TODO entries become start date"
todo-start)))
(defcustom org-e-icalendar-categories '(local-tags category)
(defcustom org-icalendar-categories '(local-tags category)
"Items that should be entered into the \"categories\" field.
This is a list of symbols, the following are valid:
@ -136,7 +136,7 @@ This is a list of symbols, the following are valid:
`todo-state' The todo state, if any
`local-tags' The tags, defined in the current line
`all-tags' All tags, including inherited ones."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(repeat
(choice
(const :tag "The file or tree category" category)
@ -144,7 +144,7 @@ This is a list of symbols, the following are valid:
(const :tag "Tags defined in current line" local-tags)
(const :tag "All tags, including inherited ones" all-tags))))
(defcustom org-e-icalendar-with-timestamps 'active
(defcustom org-icalendar-with-timestamps 'active
"Non-nil means make an event from plain time stamps.
It can be set to `active', `inactive', t or nil, in order to make
@ -153,14 +153,14 @@ inactive ones, all of them or none.
This variable has precedence over `org-export-with-timestamps'.
It can also be set with the #+OPTIONS line, e.g. \"<:t\"."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(choice
(const :tag "All timestamps" t)
(const :tag "Only active timestamps" active)
(const :tag "Only inactive timestamps" inactive)
(const :tag "No timestamp" nil)))
(defcustom org-e-icalendar-include-todo nil
(defcustom org-icalendar-include-todo nil
"Non-nil means create VTODO components from TODO items.
Valid values are:
@ -168,7 +168,7 @@ nil don't include any task.
t include tasks that are not in DONE state.
`unblocked' include all TODO items that are not blocked.
`all' include both done and not done items."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(choice
(const :tag "None" nil)
(const :tag "Unfinished" t)
@ -177,31 +177,31 @@ t include tasks that are not in DONE state.
(repeat :tag "Specific TODO keywords"
(string :tag "Keyword"))))
(defcustom org-e-icalendar-include-bbdb-anniversaries nil
(defcustom org-icalendar-include-bbdb-anniversaries nil
"Non-nil means a combined iCalendar file should include anniversaries.
The anniversaries are defined in the BBDB database."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type 'boolean)
(defcustom org-e-icalendar-include-sexps t
(defcustom org-icalendar-include-sexps t
"Non-nil means export to iCalendar files should also cover sexp entries.
These are entries like in the diary, but directly in an Org mode
file."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type 'boolean)
(defcustom org-e-icalendar-include-body t
(defcustom org-icalendar-include-body t
"Amount of text below headline to be included in iCalendar export.
This is a number of characters that should maximally be included.
Properties, scheduling and clocking lines will always be removed.
The text will be inserted into the DESCRIPTION field."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(choice
(const :tag "Nothing" nil)
(const :tag "Everything" t)
(integer :tag "Max characters")))
(defcustom org-e-icalendar-store-UID nil
(defcustom org-icalendar-store-UID nil
"Non-nil means store any created UIDs in properties.
The iCalendar standard requires that all entries have a unique identifier.
@ -214,29 +214,29 @@ synchronization services.
This variable is not turned on by default because we want to avoid creating
a property drawer in every entry if people are only playing with this feature,
or if they are only using it locally."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type 'boolean)
(defcustom org-e-icalendar-timezone (getenv "TZ")
(defcustom org-icalendar-timezone (getenv "TZ")
"The time zone string for iCalendar export.
When nil or the empty string, use output
from (current-time-zone)."
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:type '(choice
(const :tag "Unspecified" nil)
(string :tag "Time zone")))
(defcustom org-e-icalendar-date-time-format ":%Y%m%dT%H%M%S"
(defcustom org-icalendar-date-time-format ":%Y%m%dT%H%M%S"
"Format-string for exporting icalendar DATE-TIME.
See `format-time-string' for a full documentation. The only
difference is that `org-e-icalendar-timezone' is used for %Z.
difference is that `org-icalendar-timezone' is used for %Z.
Interesting value are:
- \":%Y%m%dT%H%M%S\" for local time
- \";TZID=%Z:%Y%m%dT%H%M%S\" for local time with explicit timezone
- \":%Y%m%dT%H%M%SZ\" for time expressed in Universal Time"
:group 'org-export-e-icalendar
:group 'org-export-icalendar
:version "24.1"
:type '(choice
(const :tag "Local time" ":%Y%m%dT%H%M%S")
@ -244,7 +244,7 @@ Interesting value are:
(const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
(string :tag "Explicit format")))
(defvar org-e-icalendar-after-save-hook nil
(defvar org-icalendar-after-save-hook nil
"Hook run after an iCalendar file has been saved.
This hook is run with the name of the file as argument. A good
way to use this is to tell a desktop calendar application to
@ -254,37 +254,37 @@ re-read the iCalendar file.")
;;; Define Back-End
(org-export-define-derived-backend e-icalendar e-ascii
(org-export-define-derived-backend icalendar ascii
:translate-alist ((clock . ignore)
(headline . org-e-icalendar-entry)
(headline . org-icalendar-entry)
(inlinetask . ignore)
(planning . ignore)
(section . ignore)
(template . org-e-icalendar-template))
(template . org-icalendar-template))
:options-alist
((:exclude-tags
"ICALENDAR_EXCLUDE_TAGS" nil org-e-icalendar-exclude-tags split)
(:with-timestamps nil "<" org-e-icalendar-with-timestamps)
(:with-vtodo nil nil org-e-icalendar-include-todo)
"ICALENDAR_EXCLUDE_TAGS" nil org-icalendar-exclude-tags split)
(:with-timestamps nil "<" org-icalendar-with-timestamps)
(:with-vtodo nil nil org-icalendar-include-todo)
;; The following property will be non-nil when export has been
;; started from org-agenda-mode. In this case, any entry without
;; a non-nil "ICALENDAR_MARK" property will be ignored.
(:icalendar-agenda-view nil nil nil))
:filters-alist
((:filter-headline . org-e-icalendar-clear-blank-lines))
((:filter-headline . org-icalendar-clear-blank-lines))
:menu-entry
(?c "Export to iCalendar"
((?f "Current file" org-e-icalendar-export-to-ics)
((?f "Current file" org-icalendar-export-to-ics)
(?a "All agenda files"
(lambda (a s v b) (org-e-icalendar-export-agenda-files a)))
(lambda (a s v b) (org-icalendar-export-agenda-files a)))
(?c "Combine all agenda files"
(lambda (a s v b) (org-e-icalendar-combine-agenda-files a))))))
(lambda (a s v b) (org-icalendar-combine-agenda-files a))))))
;;; Internal Functions
(defun org-e-icalendar-create-uid (file &optional bell)
(defun org-icalendar-create-uid (file &optional bell)
"Set ID property on headlines missing it in FILE.
When optional argument BELL is non-nil, inform the user with
a message if the file was modified."
@ -303,7 +303,7 @@ a message if the file was modified."
(message "ID properties created in file \"%s\"" file)
(sit-for 2))))
(defun org-e-icalendar-blocked-headline-p (headline info)
(defun org-icalendar-blocked-headline-p (headline info)
"Non-nil when HEADLINE is considered to be blocked.
INFO is a plist used as a communication channel.
@ -319,10 +319,9 @@ An headline is blocked when either:
done first or is a child of a blocked grandparent entry."
(or
;; Check if any child is not done.
(org-element-map
headline 'headline
(lambda (hl) (eq (org-element-property :todo-type hl) 'todo))
info 'first-match)
(org-element-map headline 'headline
(lambda (hl) (eq (org-element-property :todo-type hl) 'todo))
info 'first-match)
;; Check :ORDERED: node property.
(catch 'blockedp
(let ((current headline))
@ -340,13 +339,13 @@ An headline is blocked when either:
(org-export-get-genealogy headline))
nil))))
(defun org-e-icalendar-use-UTC-date-time-p ()
"Non-nil when `org-e-icalendar-date-time-format' requires UTC time."
(char-equal (elt org-e-icalendar-date-time-format
(1- (length org-e-icalendar-date-time-format))) ?Z))
(defun org-icalendar-use-UTC-date-time-p ()
"Non-nil when `org-icalendar-date-time-format' requires UTC time."
(char-equal (elt org-icalendar-date-time-format
(1- (length org-icalendar-date-time-format))) ?Z))
(defvar org-agenda-default-appointment-duration) ; From org-agenda.el.
(defun org-e-icalendar-convert-timestamp (timestamp keyword &optional end utc)
(defun org-icalendar-convert-timestamp (timestamp keyword &optional end utc)
"Convert TIMESTAMP to iCalendar format.
TIMESTAMP is a timestamp object. KEYWORD is added in front of
@ -358,7 +357,7 @@ or the day by one (if it does not contain a time) when no
explicit ending time is specified.
When optional argument UTC is non-nil, time will be expressed in
Universal Time, ignoring `org-e-icalendar-date-time-format'.
Universal Time, ignoring `org-icalendar-date-time-format'.
This is mandatory for \"DTSTAMP\" property."
(let* ((year-start (org-element-property :year-start timestamp))
(year-end (org-element-property :year-end timestamp))
@ -396,16 +395,16 @@ This is mandatory for \"DTSTAMP\" property."
(cond (utc ":%Y%m%dT%H%M%SZ")
((not with-time-p) ";VALUE=DATE:%Y%m%d")
(t (replace-regexp-in-string "%Z"
org-e-icalendar-timezone
org-e-icalendar-date-time-format
org-icalendar-timezone
org-icalendar-date-time-format
t)))
;; Convert timestamp into internal time in order to use
;; `format-time-string' and fix any mistake (i.e. MI >= 60).
(encode-time 0 mi h d m y)
(or utc (and with-time-p (org-e-icalendar-use-UTC-date-time-p)))))))
(or utc (and with-time-p (org-icalendar-use-UTC-date-time-p)))))))
(defun org-e-icalendar-get-categories (entry info)
"Return categories according to `org-e-icalendar-categories'.
(defun org-icalendar-get-categories (entry info)
"Return categories according to `org-icalendar-categories'.
ENTRY is an headline or an inlinetask element. INFO is a plist
used as a communication channel."
(mapconcat
@ -427,11 +426,11 @@ used as a communication channel."
(setq categories
(append (nreverse (org-export-get-tags entry info nil t))
categories)))))
org-e-icalendar-categories)
org-icalendar-categories)
;; Return list of categories, following specified order.
(nreverse categories))) ","))
(defun org-e-icalendar-transcode-diary-sexp (sexp uid summary)
(defun org-icalendar-transcode-diary-sexp (sexp uid summary)
"Transcode a diary sexp into iCalendar format.
SEXP is the diary sexp being transcoded, as a string. UID is the
unique identifier for the entry. SUMMARY defines a short summary
@ -445,7 +444,7 @@ or subject for the event."
(insert sexp "\n"))
(org-diary-to-ical-string (current-buffer))))))
(defun org-e-icalendar-cleanup-string (s)
(defun org-icalendar-cleanup-string (s)
"Cleanup string S according to RFC 5545."
(when s
;; Protect "\", "," and ";" characters. and replace newline
@ -455,7 +454,7 @@ or subject for the event."
(replace-regexp-in-string "[\\,;]" "\\\&" s)
nil t)))
(defun org-e-icalendar-fold-string (s)
(defun org-icalendar-fold-string (s)
"Fold string S according to RFC 5545."
(org-element-normalize-string
(mapconcat
@ -481,7 +480,7 @@ or subject for the event."
;;; Filters
(defun org-e-icalendar-clear-blank-lines (headline back-end info)
(defun org-icalendar-clear-blank-lines (headline back-end info)
"Remove trailing blank lines in HEADLINE export.
HEADLINE is a string representing a transcoded headline.
BACK-END and INFO are ignored."
@ -493,16 +492,16 @@ BACK-END and INFO are ignored."
;;;; Headline and Inlinetasks
;; The main function is `org-e-icalendar-entry', which extracts
;; The main function is `org-icalendar-entry', which extracts
;; information from an headline or an inlinetask (summary,
;; description...) and then delegates code generation to
;; `org-e-icalendar--vtodo' and `org-e-icalendar--vevent', depending
;; `org-icalendar--vtodo' and `org-icalendar--vevent', depending
;; on the component needed.
;; Obviously, `org-e-icalendar--valarm' handles alarms, which can
;; Obviously, `org-icalendar--valarm' handles alarms, which can
;; happen within a VTODO component.
(defun org-e-icalendar-entry (entry contents info)
(defun org-icalendar-entry (entry contents info)
"Transcode ENTRY element into iCalendar format.
ENTRY is either an headline or an inlinetask. CONTENTS is
@ -530,43 +529,43 @@ inlinetask within the section."
(not (org-element-property :icalendar-mark entry)))
(let ((todo-type (org-element-property :todo-type entry))
(uid (or (org-element-property :id entry) (org-id-new)))
(summary (org-e-icalendar-cleanup-string
(summary (org-icalendar-cleanup-string
(or (org-element-property :summary entry)
(org-export-data
(org-element-property :title entry) info))))
(loc (org-e-icalendar-cleanup-string
(loc (org-icalendar-cleanup-string
(org-element-property :location entry)))
;; Build description of the entry from associated
;; section (headline) or contents (inlinetask).
(desc
(org-e-icalendar-cleanup-string
(org-icalendar-cleanup-string
(or (org-element-property :description entry)
(let ((contents (org-export-data inside info)))
(cond
((not (org-string-nw-p contents)) nil)
((wholenump org-e-icalendar-include-body)
((wholenump org-icalendar-include-body)
(let ((contents (org-trim contents)))
(substring
contents 0 (min (length contents)
org-e-icalendar-include-body))))
(org-e-icalendar-include-body (org-trim contents)))))))
(cat (org-e-icalendar-get-categories entry info)))
org-icalendar-include-body))))
(org-icalendar-include-body (org-trim contents)))))))
(cat (org-icalendar-get-categories entry info)))
(concat
;; Events: Delegate to `org-e-icalendar--vevent' to
;; Events: Delegate to `org-icalendar--vevent' to
;; generate "VEVENT" component from scheduled, deadline,
;; or any timestamp in the entry.
(let ((deadline (org-element-property :deadline entry)))
(and deadline
(memq (if todo-type 'event-if-todo 'event-if-not-todo)
org-e-icalendar-use-deadline)
(org-e-icalendar--vevent
org-icalendar-use-deadline)
(org-icalendar--vevent
entry deadline (concat "DL-" uid)
(concat "DL: " summary) loc desc cat)))
(let ((scheduled (org-element-property :scheduled entry)))
(and scheduled
(memq (if todo-type 'event-if-todo 'event-if-not-todo)
org-e-icalendar-use-scheduled)
(org-e-icalendar--vevent
org-icalendar-use-scheduled)
(org-icalendar--vevent
entry scheduled (concat "SC-" uid)
(concat "S: " summary) loc desc cat)))
;; When collecting plain timestamps from an headline and
@ -575,58 +574,56 @@ inlinetask within the section."
(let ((counter 0))
(mapconcat
'identity
(org-element-map
(cons (org-element-property :title entry)
(org-element-contents inside))
'timestamp
(lambda (ts)
(let ((uid (format "TS%d-%s" (incf counter) uid)))
(org-e-icalendar--vevent entry ts uid summary loc desc cat)))
info nil (and (eq type 'headline) 'inlinetask))
(org-element-map (cons (org-element-property :title entry)
(org-element-contents inside))
'timestamp
(lambda (ts)
(let ((uid (format "TS%d-%s" (incf counter) uid)))
(org-icalendar--vevent entry ts uid summary loc desc cat)))
info nil (and (eq type 'headline) 'inlinetask))
""))
;; Task: First check if it is appropriate to export it.
;; If so, call `org-e-icalendar--vtodo' to transcode it
;; If so, call `org-icalendar--vtodo' to transcode it
;; into a "VTODO" component.
(when (and todo-type
(case (plist-get info :with-vtodo)
(all t)
(unblocked
(and (eq type 'headline)
(not (org-e-icalendar-blocked-headline-p
(not (org-icalendar-blocked-headline-p
entry info))))
('t (eq todo-type 'todo))))
(org-e-icalendar--vtodo entry uid summary loc desc cat))
(org-icalendar--vtodo entry uid summary loc desc cat))
;; Diary-sexp: Collect every diary-sexp element within
;; ENTRY and its title, and transcode them. If ENTRY is
;; an headline, skip inlinetasks: they will be handled
;; separately.
(when org-e-icalendar-include-sexps
(when org-icalendar-include-sexps
(let ((counter 0))
(mapconcat 'identity
(org-element-map
(cons (org-element-property :title entry)
(org-element-contents inside))
'diary-sexp
(lambda (sexp)
(org-e-icalendar-transcode-diary-sexp
(org-element-property :value sexp)
(format "DS%d-%s" (incf counter) uid)
summary))
info nil (and (eq type 'headline) 'inlinetask))
(cons (org-element-property :title entry)
(org-element-contents inside))
'diary-sexp
(lambda (sexp)
(org-icalendar-transcode-diary-sexp
(org-element-property :value sexp)
(format "DS%d-%s" (incf counter) uid)
summary))
info nil (and (eq type 'headline) 'inlinetask))
""))))))
;; If ENTRY is an headline, call current function on every
;; inlinetask within it. In agenda export, this is independent
;; from the mark (or lack thereof) on the entry.
(when (eq type 'headline)
(mapconcat 'identity
(org-element-map
inside 'inlinetask
(lambda (task) (org-e-icalendar-entry task nil info))
info) ""))
(org-element-map inside 'inlinetask
(lambda (task) (org-icalendar-entry task nil info))
info) ""))
;; Don't forget components from inner entries.
contents))))
(defun org-e-icalendar--vevent
(defun org-icalendar--vevent
(entry timestamp uid summary location description categories)
"Create a VEVENT component.
@ -639,15 +636,15 @@ description of the event. CATEGORIES defines the categories the
event belongs to.
Return VEVENT component as a string."
(org-e-icalendar-fold-string
(org-icalendar-fold-string
(if (eq (org-element-property :type timestamp) 'diary)
(org-e-icalendar-transcode-diary-sexp
(org-icalendar-transcode-diary-sexp
(org-element-property :raw-value timestamp) uid summary)
(concat "BEGIN:VEVENT\n"
(org-e-icalendar-convert-timestamp timestamp "DTSTAMP" nil t) "\n"
(org-icalendar-convert-timestamp timestamp "DTSTAMP" nil t) "\n"
"UID:" uid "\n"
(org-e-icalendar-convert-timestamp timestamp "DTSTART") "\n"
(org-e-icalendar-convert-timestamp timestamp "DTEND" t) "\n"
(org-icalendar-convert-timestamp timestamp "DTSTART") "\n"
(org-icalendar-convert-timestamp timestamp "DTEND" t) "\n"
;; RRULE.
(when (org-element-property :repeater-type timestamp)
(format "RRULE:FREQ=%s;INTERVAL=%d\n"
@ -661,10 +658,10 @@ Return VEVENT component as a string."
(format "DESCRIPTION:%s\n" description))
"CATEGORIES:" categories "\n"
;; VALARM.
(org-e-icalendar--valarm entry timestamp summary)
(org-icalendar--valarm entry timestamp summary)
"END:VEVENT"))))
(defun org-e-icalendar--vtodo
(defun org-icalendar--vtodo
(entry uid summary location description categories)
"Create a VTODO component.
@ -675,7 +672,7 @@ the task. DESCRIPTION provides the complete description of the
task. CATEGORIES defines the categories the task belongs to.
Return VTODO component as a string."
(let ((start (or (and (memq 'todo-start org-e-icalendar-use-scheduled)
(let ((start (or (and (memq 'todo-start org-icalendar-use-scheduled)
(org-element-property :scheduled entry))
;; If we can't use a scheduled time for some
;; reason, start task now.
@ -687,14 +684,14 @@ Return VTODO component as a string."
:day-start (nth 3 now)
:month-start (nth 4 now)
:year-start (nth 5 now)))))))
(org-e-icalendar-fold-string
(org-icalendar-fold-string
(concat "BEGIN:VTODO\n"
"UID:TODO-" uid "\n"
(org-e-icalendar-convert-timestamp start "DTSTAMP" nil t) "\n"
(org-e-icalendar-convert-timestamp start "DTSTART") "\n"
(and (memq 'todo-due org-e-icalendar-use-deadline)
(org-icalendar-convert-timestamp start "DTSTAMP" nil t) "\n"
(org-icalendar-convert-timestamp start "DTSTART") "\n"
(and (memq 'todo-due org-icalendar-use-deadline)
(org-element-property :deadline entry)
(concat (org-e-icalendar-convert-timestamp
(concat (org-icalendar-convert-timestamp
(org-element-property :deadline entry) "DUE")
"\n"))
"SUMMARY:" summary "\n"
@ -715,7 +712,7 @@ Return VTODO component as a string."
"COMPLETED"))
"END:VTODO"))))
(defun org-e-icalendar--valarm (entry timestamp summary)
(defun org-icalendar--valarm (entry timestamp summary)
"Create a VALARM component.
ENTRY is the calendar entry triggering the alarm. TIMESTAMP is
@ -733,7 +730,7 @@ Return VALARM component as a string, or nil if it isn't allowed."
(let ((warntime
(org-element-property :appt-warntime entry)))
(if warntime (string-to-number warntime) 0))))
(and (or (> alarm-time 0) (> org-e-icalendar-alarm-time 0))
(and (or (> alarm-time 0) (> org-icalendar-alarm-time 0))
(org-element-property :hour-start timestamp)
(format "BEGIN:VALARM
ACTION:DISPLAY
@ -741,16 +738,16 @@ DESCRIPTION:%s
TRIGGER:-P0DT0H%dM0S
END:VALARM\n"
summary
(if (zerop alarm-time) org-e-icalendar-alarm-time alarm-time)))))
(if (zerop alarm-time) org-icalendar-alarm-time alarm-time)))))
;;;; Template
(defun org-e-icalendar-template (contents info)
(defun org-icalendar-template (contents info)
"Return complete document string after iCalendar conversion.
CONTENTS is the transcoded contents string. INFO is a plist used
as a communication channel."
(org-e-icalendar--vcalendar
(org-icalendar--vcalendar
;; Name.
(if (not (plist-get info :input-file)) (buffer-name (buffer-base-buffer))
(file-name-nondirectory
@ -759,13 +756,13 @@ as a communication channel."
(if (not (plist-get info :with-author)) ""
(org-export-data (plist-get info :author) info))
;; Timezone.
(if (org-string-nw-p org-e-icalendar-timezone) org-e-icalendar-timezone
(if (org-string-nw-p org-icalendar-timezone) org-icalendar-timezone
(cadr (current-time-zone)))
;; Description.
(org-export-data (plist-get info :title) info)
contents))
(defun org-e-icalendar--vcalendar (name owner tz description contents)
(defun org-icalendar--vcalendar (name owner tz description contents)
"Create a VCALENDAR component.
NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving,
respectively, the name of the calendar, its owner, the timezone
@ -777,10 +774,10 @@ PRODID:-//%s//Emacs with Org mode//EN
X-WR-TIMEZONE:%s
X-WR-CALDESC:%s
CALSCALE:GREGORIAN\n"
(org-e-icalendar-cleanup-string name)
(org-e-icalendar-cleanup-string owner)
(org-e-icalendar-cleanup-string tz)
(org-e-icalendar-cleanup-string description))
(org-icalendar-cleanup-string name)
(org-icalendar-cleanup-string owner)
(org-icalendar-cleanup-string tz)
(org-icalendar-cleanup-string description))
contents
"END:VCALENDAR\n"))
@ -789,7 +786,7 @@ CALSCALE:GREGORIAN\n"
;;; Interactive Functions
;;;###autoload
(defun org-e-icalendar-export-to-ics
(defun org-icalendar-export-to-ics
(&optional async subtreep visible-only body-only)
"Export current buffer to an iCalendar file.
@ -815,29 +812,29 @@ between \"BEGIN:VCALENDAR\" and \"END:VCALENDAR\".
Return ICS file name."
(interactive)
(let ((file (buffer-file-name (buffer-base-buffer))))
(when (and file org-e-icalendar-store-UID)
(org-e-icalendar-create-uid file 'warn-user)))
(when (and file org-icalendar-store-UID)
(org-icalendar-create-uid file 'warn-user)))
;; Export part. Since this back-end is backed up by `e-ascii',
;; ensure links will not be collected at the end of sections.
(let ((outfile (org-export-output-file-name ".ics" subtreep)))
(if async
(org-export-async-start
(lambda (f)
(org-export-add-to-stack f 'e-icalendar)
(run-hook-with-args 'org-e-icalendar-after-save-hook f))
`(let ((org-e-ascii-links-to-notes nil))
(org-export-add-to-stack f 'icalendar)
(run-hook-with-args 'org-icalendar-after-save-hook f))
`(let ((org-ascii-links-to-notes nil))
(expand-file-name
(org-export-to-file
'e-icalendar ,outfile ,subtreep ,visible-only ,body-only
'icalendar ,outfile ,subtreep ,visible-only ,body-only
'(:ascii-charset utf-8)))))
(let ((org-e-ascii-links-to-notes nil))
(org-export-to-file 'e-icalendar outfile subtreep visible-only body-only
(let ((org-ascii-links-to-notes nil))
(org-export-to-file 'icalendar outfile subtreep visible-only body-only
'(:ascii-charset utf-8)))
(run-hook-with-args 'org-e-icalendar-after-save-hook outfile)
(run-hook-with-args 'org-icalendar-after-save-hook outfile)
outfile)))
;;;###autoload
(defun org-e-icalendar-export-agenda-files (&optional async)
(defun org-icalendar-export-agenda-files (&optional async)
"Export all agenda files to iCalendar files.
When optional argument ASYNC is non-nil, export happens in an
external process."
@ -854,7 +851,7 @@ external process."
`(let (output-files)
(mapc (lambda (file)
(with-current-buffer (org-get-agenda-file-buffer file)
(push (expand-file-name (org-e-icalendar-export-to-ics))
(push (expand-file-name (org-icalendar-export-to-ics))
output-files)))
',files)
output-files)))
@ -865,12 +862,12 @@ external process."
(catch 'nextfile
(org-check-agenda-file file)
(with-current-buffer (org-get-agenda-file-buffer file)
(org-e-icalendar-export-to-ics))))
(org-icalendar-export-to-ics))))
files)
(org-release-buffers org-agenda-new-buffers)))))
;;;###autoload
(defun org-e-icalendar-combine-agenda-files (&optional async)
(defun org-icalendar-combine-agenda-files (&optional async)
"Combine all agenda files into a single iCalendar file.
A non-nil optional argument ASYNC means the process should happen
@ -878,28 +875,30 @@ asynchronously. The resulting file should be accessible through
the `org-export-stack' interface.
The file is stored under the name chosen in
`org-e-icalendar-combined-agenda-file'."
`org-icalendar-combined-agenda-file'."
(interactive)
(if async
(let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
(org-export-async-start
(lambda (dummy)
(org-export-add-to-stack
(expand-file-name org-e-icalendar-combined-agenda-file)
'e-icalendar))
`(apply 'org-e-icalendar--combine-files nil ',files)))
(apply 'org-e-icalendar--combine-files nil (org-agenda-files t))))
(expand-file-name org-icalendar-combined-agenda-file)
'icalendar))
`(apply 'org-icalendar--combine-files nil ',files)))
(apply 'org-icalendar--combine-files nil (org-agenda-files t))))
(defun org-e-icalendar-export-current-agenda ()
"Export current agenda view to an iCalendar file.
The file is stored under the name
`org-e-icalendar-combined-agenda-file'. This function assumes
major mode for current buffer is `org-agenda-mode'."
(apply 'org-e-icalendar--combine-files
(org-create-marker-find-array (org-agenda-collect-markers))
(org-agenda-files nil 'ifmode)))
(declare-function org-agenda-collect-markers "org-agenda" ())
(declare-function org-create-marker-find-array "org-agenda" (marker-list))
(defun org-icalendar-export-current-agenda (file)
"Export current agenda view to an iCalendar FILE.
This function assumes major mode for current buffer is
`org-agenda-mode'."
(let ((org-icalendar-combined-agenda-file file))
(apply 'org-icalendar--combine-files
(org-create-marker-find-array (org-agenda-collect-markers))
(org-agenda-files nil 'ifmode))))
(defun org-e-icalendar--combine-files (restriction &rest files)
(defun org-icalendar--combine-files (restriction &rest files)
"Combine entries from multiple files into an iCalendar file.
RESTRICTION, when non-nil, is an alist where key is a file name
and value a list of buffer positions pointing to entries that
@ -909,19 +908,19 @@ files to build the calendar from."
(org-agenda-prepare-buffers files)
(unwind-protect
(progn
(with-temp-file org-e-icalendar-combined-agenda-file
(with-temp-file org-icalendar-combined-agenda-file
(insert
(org-e-icalendar--vcalendar
(org-icalendar--vcalendar
;; Name.
org-e-icalendar-combined-name
org-icalendar-combined-name
;; Owner.
user-full-name
;; Timezone.
(if (org-string-nw-p org-e-icalendar-timezone)
org-e-icalendar-timezone
(if (org-string-nw-p org-icalendar-timezone)
org-icalendar-timezone
(cadr (current-time-zone)))
;; Description.
org-e-icalendar-combined-description
org-icalendar-combined-description
;; Contents.
(concat
;; Agenda contents.
@ -931,8 +930,8 @@ files to build the calendar from."
(org-check-agenda-file file)
(with-current-buffer (org-get-agenda-file-buffer file)
;; Create ID if necessary.
(when org-e-icalendar-store-UID
(org-e-icalendar-create-uid file))
(when org-icalendar-store-UID
(org-icalendar-create-uid file))
(let ((marks (cdr (assoc (expand-file-name file)
restriction))))
(unless (and restriction (not marks))
@ -950,21 +949,25 @@ files to build the calendar from."
(sort marks '>))
org-export-before-processing-hook)))
(org-export-as
'e-icalendar nil nil t
'icalendar nil nil t
(list :ascii-charset 'utf-8
:icalendar-agenda-view restriction))))))))
files "")
;; BBDB anniversaries.
(when (and org-e-icalendar-include-bbdb-anniversaries
(when (and org-icalendar-include-bbdb-anniversaries
(require 'org-bbdb nil t))
(with-temp-buffer
(org-bbdb-anniv-export-ical)
(buffer-string)))))))
(run-hook-with-args 'org-e-icalendar-after-save-hook
org-e-icalendar-combined-agenda-file))
(run-hook-with-args 'org-icalendar-after-save-hook
org-icalendar-combined-agenda-file))
(org-release-buffers org-agenda-new-buffers)))
(provide 'org-e-icalendar)
(provide 'ox-icalendar)
;;; org-e-icalendar.el ends here
;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:
;;; ox-icalendar.el ends here

260
lisp/ox-jsinfo.el Normal file
View File

@ -0,0 +1,260 @@
;;; ox-jsinfo.el --- Org HTML Export Extension for org-info.js
;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;;
;; This file is part of GNU Emacs.
;;
;; 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/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;; This file implements the support for Sebastian Rose's JavaScript
;; org-info.js to display an Org mode file exported to HTML in an
;; Info-like way, or using folding similar to the outline structure of
;; Org mode itself.
;; Documentation for using this module is in the Org manual. The
;; script itself is documented by Sebastian Rose in a file distributed
;; with the script. FIXME: Accurate pointers!
;;; Code:
(require 'ox-html)
(add-to-list 'org-export-filter-options-functions 'org-infojs-install-script)
(defgroup org-export-infojs nil
"Options specific for using org-info.js in HTML export."
:tag "Org Export HTML INFOJS"
:group 'org-export-html)
(defcustom org-export-html-use-infojs 'when-configured
"Non-nil when Sebastian Rose's Java Script org-info.js should be active.
This option can be nil or t to never or always use the script.
It can also be the symbol `when-configured', meaning that the
script will be linked into the export file if and only if there
is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
`org-infojs-options'."
:group 'org-export-html
:group 'org-export-infojs
:type '(choice
(const :tag "Never" nil)
(const :tag "When configured in buffer" when-configured)
(const :tag "Always" t)))
(defconst org-infojs-opts-table
'((path PATH "http://orgmode.org/org-info.js")
(view VIEW "info")
(toc TOC :with-toc)
(ftoc FIXED_TOC "0")
(tdepth TOC_DEPTH "max")
(sdepth SECTION_DEPTH "max")
(mouse MOUSE_HINT "underline")
(buttons VIEW_BUTTONS "0")
(ltoc LOCAL_TOC "1")
(up LINK_UP :html-link-up)
(home LINK_HOME :html-link-home))
"JavaScript options, long form for script, default values.")
(defvar org-infojs-options)
(when (and (boundp 'org-infojs-options)
(assq 'runs org-infojs-options))
(setq org-infojs-options (delq (assq 'runs org-infojs-options)
org-infojs-options)))
(defcustom org-infojs-options
(mapcar (lambda (x) (cons (car x) (nth 2 x))) org-infojs-opts-table)
"Options settings for the INFOJS JavaScript.
Each of the options must have an entry in `org-export-html/infojs-opts-table'.
The value can either be a string that will be passed to the script, or
a property. This property is then assumed to be a property that is defined
by the Export/Publishing setup of Org.
The `sdepth' and `tdepth' parameters can also be set to \"max\", which
means to use the maximum value consistent with other options."
:group 'org-export-infojs
:type
`(set :greedy t :inline t
,@(mapcar
(lambda (x)
(list 'cons (list 'const (car x))
'(choice
(symbol :tag "Publishing/Export property")
(string :tag "Value"))))
org-infojs-opts-table)))
(defcustom org-infojs-template
"<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
/**
*
* @source: %SCRIPT_PATH
*
* @licstart The following is the entire license notice for the
* JavaScript code in %SCRIPT_PATH.
*
* Copyright (C) 2012-2013 Sebastian Rose
*
*
* The JavaScript code in this tag is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend The above is the entire license notice
* for the JavaScript code in %SCRIPT_PATH.
*
*/
</script>
<script type=\"text/javascript\">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
%MANAGER_OPTIONS
org_html_manager.setup(); // activate after the parameters are set
/*]]>*///-->
</script>"
"The template for the export style additions when org-info.js is used.
Option settings will replace the %MANAGER-OPTIONS cookie."
:group 'org-infojs
:type 'string)
(defun org-infojs-install-script (exp-plist backend)
"Install script in export options when appropriate.
EXP-PLIST is a plist containing export options. BACKEND is the
export back-end currently used."
(unless (or (not (org-export-derived-backend-p backend 'html))
(not org-export-html-use-infojs)
(and (eq org-export-html-use-infojs 'when-configured)
(or (not (plist-get exp-plist :infojs-opt))
(string-match "\\<view:nil\\>"
(plist-get exp-plist :infojs-opt)))))
(let* ((template org-infojs-template)
(ptoc (plist-get exp-plist :with-toc))
(hlevels (plist-get exp-plist :headline-levels))
(sdepth hlevels)
(tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels))
(options (plist-get exp-plist :infojs-opt))
(table org-infojs-opts-table)
style)
(dolist (entry table)
(let* ((opt (car entry))
(var (nth 1 entry))
;; Compute default values for script option OPT from
;; `org-infojs-options' variable.
(default
(let ((default (cdr (assq opt org-infojs-options))))
(if (and (symbolp default) (not (memq default '(t nil))))
(plist-get exp-plist default)
default)))
;; Value set through INFOJS_OPT keyword has precedence
;; over the default one.
(val (if (and options
(string-match (format "\\<%s:\\(\\S-+\\)" opt)
options))
(match-string 1 options)
default)))
(case opt
(path (setq template
(replace-regexp-in-string
"%SCRIPT_PATH" val template t t)))
(sdepth (when (integerp (read val))
(setq sdepth (min (read val) sdepth))))
(tdepth (when (integerp (read val))
(setq tdepth (min (read val) tdepth))))
(otherwise (setq val
(cond
((or (eq val t) (equal val "t")) "1")
((or (eq val nil) (equal val "nil")) "0")
((stringp val) val)
(t (format "%s" val))))
(push (cons var val) style)))))
;; Now we set the depth of the *generated* TOC to SDEPTH,
;; because the toc will actually determine the splitting. How
;; much of the toc will actually be displayed is governed by the
;; TDEPTH option.
(setq exp-plist (plist-put exp-plist :with-toc sdepth))
;; The table of contents should not show more sections than we
;; generate.
(setq tdepth (min tdepth sdepth))
(push (cons "TOC_DEPTH" tdepth) style)
;; Build style string.
(setq style (mapconcat
(lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
(car x)
(cdr x)))
style "\n"))
(when (and style (> (length style) 0))
(and (string-match "%MANAGER_OPTIONS" template)
(setq style (replace-match style t t template))
(setq exp-plist
(plist-put
exp-plist :html-style-extra
(concat (or (plist-get exp-plist :html-style-extra) "")
"\n"
style)))))
;; This script absolutely needs the table of contents, so we
;; change that setting.
(unless (plist-get exp-plist :with-toc)
(setq exp-plist (plist-put exp-plist :with-toc t)))
;; Return the modified property list.
exp-plist)))
(provide 'ox-infojs)
(provide 'ox-jsinfo)
;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:
;;; ox-jsinfo.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
;; org-e-man.el --- Man Back-End For Org Export Engine
;; ox-man.el --- Man Back-End for Org Export Engine
;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
@ -26,18 +26,17 @@
;;
;; To test it, run
;;
;; M-: (org-export-to-buffer 'e-man "*Test e-Man*") RET
;; M-: (org-export-to-buffer 'man "*Test Man*") RET
;;
;; in an org-mode buffer then switch to the buffer to see the Man
;; export. See contrib/lisp/org-export.el for more details on how
;; this exporter works.
;; export. See ox.el for more details on how this exporter works.
;;
;; It introduces one new buffer keywords:
;; "MAN_CLASS_OPTIONS".
;;; Code:
(require 'org-export)
(require 'ox)
(eval-when-compile (require 'cl))
@ -49,68 +48,66 @@
;;; Define Back-End
(org-export-define-backend e-man
((babel-call . org-e-man-babel-call)
(bold . org-e-man-bold)
(center-block . org-e-man-center-block)
(clock . org-e-man-clock)
(code . org-e-man-code)
(comment . org-e-man-comment)
(comment-block . org-e-man-comment-block)
(drawer . org-e-man-drawer)
(dynamic-block . org-e-man-dynamic-block)
(entity . org-e-man-entity)
(example-block . org-e-man-example-block)
(export-block . org-e-man-export-block)
(export-snippet . org-e-man-export-snippet)
(fixed-width . org-e-man-fixed-width)
(footnote-definition . org-e-man-footnote-definition)
(footnote-reference . org-e-man-footnote-reference)
(headline . org-e-man-headline)
(horizontal-rule . org-e-man-horizontal-rule)
(inline-babel-call . org-e-man-inline-babel-call)
(inline-src-block . org-e-man-inline-src-block)
(inlinetask . org-e-man-inlinetask)
(italic . org-e-man-italic)
(item . org-e-man-item)
(keyword . org-e-man-keyword)
(man-environment . org-e-man-man-environment)
(man-fragment . org-e-man-man-fragment)
(line-break . org-e-man-line-break)
(link . org-e-man-link)
(paragraph . org-e-man-paragraph)
(plain-list . org-e-man-plain-list)
(plain-text . org-e-man-plain-text)
(planning . org-e-man-planning)
(property-drawer . org-e-man-property-drawer)
(quote-block . org-e-man-quote-block)
(quote-section . org-e-man-quote-section)
(radio-target . org-e-man-radio-target)
(section . org-e-man-section)
(special-block . org-e-man-special-block)
(src-block . org-e-man-src-block)
(statistics-cookie . org-e-man-statistics-cookie)
(strike-through . org-e-man-strike-through)
(subscript . org-e-man-subscript)
(superscript . org-e-man-superscript)
(table . org-e-man-table)
(table-cell . org-e-man-table-cell)
(table-row . org-e-man-table-row)
(target . org-e-man-target)
(template . org-e-man-template)
(timestamp . org-e-man-timestamp)
(underline . org-e-man-underline)
(verbatim . org-e-man-verbatim)
(verse-block . org-e-man-verse-block))
(org-export-define-backend man
((babel-call . org-man-babel-call)
(bold . org-man-bold)
(center-block . org-man-center-block)
(clock . org-man-clock)
(code . org-man-code)
(comment . org-man-comment)
(comment-block . org-man-comment-block)
(drawer . org-man-drawer)
(dynamic-block . org-man-dynamic-block)
(entity . org-man-entity)
(example-block . org-man-example-block)
(export-block . org-man-export-block)
(export-snippet . org-man-export-snippet)
(fixed-width . org-man-fixed-width)
(footnote-definition . org-man-footnote-definition)
(footnote-reference . org-man-footnote-reference)
(headline . org-man-headline)
(horizontal-rule . org-man-horizontal-rule)
(inline-babel-call . org-man-inline-babel-call)
(inline-src-block . org-man-inline-src-block)
(inlinetask . org-man-inlinetask)
(italic . org-man-italic)
(item . org-man-item)
(keyword . org-man-keyword)
(line-break . org-man-line-break)
(link . org-man-link)
(paragraph . org-man-paragraph)
(plain-list . org-man-plain-list)
(plain-text . org-man-plain-text)
(planning . org-man-planning)
(property-drawer . org-man-property-drawer)
(quote-block . org-man-quote-block)
(quote-section . org-man-quote-section)
(radio-target . org-man-radio-target)
(section . org-man-section)
(special-block . org-man-special-block)
(src-block . org-man-src-block)
(statistics-cookie . org-man-statistics-cookie)
(strike-through . org-man-strike-through)
(subscript . org-man-subscript)
(superscript . org-man-superscript)
(table . org-man-table)
(table-cell . org-man-table-cell)
(table-row . org-man-table-row)
(target . org-man-target)
(template . org-man-template)
(timestamp . org-man-timestamp)
(underline . org-man-underline)
(verbatim . org-man-verbatim)
(verse-block . org-man-verse-block))
:export-block "MAN"
:menu-entry
(?m "Export to MAN"
((?m "As MAN file" org-e-man-export-to-man)
(?p "As PDF file" org-e-man-export-to-pdf)
((?m "As MAN file" org-man-export-to-man)
(?p "As PDF file" org-man-export-to-pdf)
(?o "As PDF file and open"
(lambda (a s v b)
(if a (org-e-man-export-to-pdf t s v b)
(org-open-file (org-e-man-export-to-pdf nil s v b)))))))
(if a (org-man-export-to-pdf t s v b)
(org-open-file (org-man-export-to-pdf nil s v b)))))))
:options-alist
((:man-class "MAN_CLASS" nil nil t)
(:man-class-options "MAN_CLASS_OPTIONS" nil nil t)
@ -120,31 +117,31 @@
;;; User Configurable Variables
(defgroup org-export-e-man nil
(defgroup org-export-man nil
"Options for exporting Org mode files to Man."
:tag "Org Export Man"
:group 'org-export)
;;; Tables
(defcustom org-e-man-tables-centered t
(defcustom org-man-tables-centered t
"When non-nil, tables are exported in a center environment."
:group 'org-export-e-man
:group 'org-export-man
:type 'boolean)
(defcustom org-e-man-tables-verbatim nil
(defcustom org-man-tables-verbatim nil
"When non-nil, tables are exported verbatim."
:group 'org-export-e-man
:group 'org-export-man
:type 'boolean)
(defcustom org-e-man-table-scientific-notation "%sE%s"
(defcustom org-man-table-scientific-notation "%sE%s"
"Format string to display numbers in scientific notation.
The format should have \"%s\" twice, for mantissa and exponent
\(i.e. \"%s\\\\times10^{%s}\").
When nil, no transformation is made."
:group 'org-export-e-man
:group 'org-export-man
:type '(choice
(string :tag "Format string")
(const :tag "No formatting")))
@ -153,13 +150,13 @@ When nil, no transformation is made."
;;; Inlinetasks
;; Src blocks
(defcustom org-e-man-source-highlight nil
(defcustom org-man-source-highlight nil
"Use GNU source highlight to embellish source blocks "
:group 'org-export-e-man
:group 'org-export-man
:type 'boolean)
(defcustom org-e-man-source-highlight-langs
(defcustom org-man-source-highlight-langs
'((emacs-lisp "lisp") (lisp "lisp") (clojure "lisp")
(scheme "scheme")
(c "c") (cc "cpp") (csharp "csharp") (d "d")
@ -184,7 +181,7 @@ The value is the string that should be inserted as the language
parameter for the listings package. If the mode name and the
listings name are the same, the language does not need an entry
in this list - but it does not hurt if it is present."
:group 'org-export-e-man
:group 'org-export-man
:type '(repeat
(list
(symbol :tag "Major mode ")
@ -192,13 +189,13 @@ in this list - but it does not hurt if it is present."
(defvar org-e-man-custom-lang-environments nil
(defvar org-man-custom-lang-environments nil
"Alist mapping languages to language-specific Man environments.
It is used during export of src blocks by the listings and
man packages. For example,
\(setq org-e-man-custom-lang-environments
\(setq org-man-custom-lang-environments
'\(\(python \"pythoncode\"\)\)\)
would have the effect that if org encounters begin_src python
@ -208,7 +205,7 @@ during man export."
;;; Compilation
(defcustom org-e-man-pdf-process
(defcustom org-man-pdf-process
'("tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
"tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
"tbl %f | eqn | groff -man | ps2pdf - > %b.pdf")
@ -238,29 +235,29 @@ its single argument."
"tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"))
(function)))
(defcustom org-e-man-logfiles-extensions
(defcustom org-man-logfiles-extensions
'("log" "out" "toc")
"The list of file extensions to consider as Man logfiles."
:group 'org-export-e-man
:group 'org-export-man
:type '(repeat (string :tag "Extension")))
(defcustom org-e-man-remove-logfiles t
(defcustom org-man-remove-logfiles t
"Non-nil means remove the logfiles produced by PDF production.
These are the .aux, .log, .out, and .toc files."
:group 'org-export-e-man
:group 'org-export-man
:type 'boolean)
;;; Internal Functions
(defun org-e-man--caption/label-string (element info)
(defun org-man--caption/label-string (element info)
"Return caption and label Man string for ELEMENT.
INFO is a plist holding contextual information. If there's no
caption nor label, return the empty string.
For non-floats, see `org-e-man--wrap-label'."
For non-floats, see `org-man--wrap-label'."
(let ((label (org-element-property :label element))
(main (org-export-get-caption element))
(short (org-export-get-caption element t)))
@ -273,10 +270,10 @@ For non-floats, see `org-e-man--wrap-label'."
;; Standard caption format.
(t (format "\\fR%s\\fP" (org-export-data main info))))))
(defun org-e-man--wrap-label (element output)
(defun org-man--wrap-label (element output)
"Wrap label associated to ELEMENT around OUTPUT, if appropriate.
This function shouldn't be used for floats. See
`org-e-man--caption/label-string'."
`org-man--caption/label-string'."
(let ((label (org-element-property :name element)))
(if (or (not output) (not label) (string= output "") (string= label ""))
output
@ -286,7 +283,7 @@ This function shouldn't be used for floats. See
;;; Template
(defun org-e-man-template (contents info)
(defun org-man-template (contents info)
"Return complete document string after Man conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
@ -323,7 +320,7 @@ holding export options."
;;; Bold
(defun org-e-man-bold (bold contents info)
(defun org-man-bold (bold contents info)
"Transcode BOLD from Org to Man.
CONTENTS is the text with bold markup. INFO is a plist holding
contextual information."
@ -332,11 +329,11 @@ contextual information."
;;; Center Block
(defun org-e-man-center-block (center-block contents info)
(defun org-man-center-block (center-block contents info)
"Transcode a CENTER-BLOCK element from Org to Man.
CONTENTS holds the contents of the center block. INFO is a plist
holding contextual information."
(org-e-man--wrap-label
(org-man--wrap-label
center-block
(format ".ce %d\n.nf\n%s\n.fi"
(- (length (split-string contents "\n")) 1 )
@ -345,7 +342,7 @@ holding contextual information."
;;; Clock
(defun org-e-man-clock (clock contents info)
(defun org-man-clock (clock contents info)
"Transcode a CLOCK element from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual
information."
@ -354,7 +351,7 @@ information."
;;; Code
(defun org-e-man-code (code contents info)
(defun org-man-code (code contents info)
"Transcode a CODE object from Org to Man.
CONTENTS is nil. INFO is a plist used as a communication
channel."
@ -373,7 +370,7 @@ channel."
;;; Drawer
(defun org-e-man-drawer (drawer contents info)
(defun org-man-drawer (drawer contents info)
"Transcode a DRAWER element from Org to Man.
DRAWER holds the drawer information
CONTENTS holds the contents of the block.
@ -383,16 +380,16 @@ channel."
;;; Dynamic Block
(defun org-e-man-dynamic-block (dynamic-block contents info)
(defun org-man-dynamic-block (dynamic-block contents info)
"Transcode a DYNAMIC-BLOCK element from Org to Man.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information. See `org-export-data'."
(org-e-man--wrap-label dynamic-block contents))
(org-man--wrap-label dynamic-block contents))
;;; Entity
(defun org-e-man-entity (entity contents info)
(defun org-man-entity (entity contents info)
"Transcode an ENTITY object from Org to Man.
CONTENTS are the definition itself. INFO is a plist holding
contextual information."
@ -401,11 +398,11 @@ contextual information."
;;; Example Block
(defun org-e-man-example-block (example-block contents info)
(defun org-man-example-block (example-block contents info)
"Transcode an EXAMPLE-BLOCK element from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual
information."
(org-e-man--wrap-label
(org-man--wrap-label
example-block
(format ".RS\n.nf\n%s\n.fi\n.RE"
(org-export-format-code-default example-block info))))
@ -413,7 +410,7 @@ information."
;;; Export Block
(defun org-e-man-export-block (export-block contents info)
(defun org-man-export-block (export-block contents info)
"Transcode a EXPORT-BLOCK element from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(when (string= (org-element-property :type export-block) "MAN")
@ -422,19 +419,19 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;; Export Snippet
(defun org-e-man-export-snippet (export-snippet contents info)
(defun org-man-export-snippet (export-snippet contents info)
"Transcode a EXPORT-SNIPPET object from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(when (eq (org-export-snippet-backend export-snippet) 'e-man)
(when (eq (org-export-snippet-backend export-snippet) 'man)
(org-element-property :value export-snippet)))
;;; Fixed Width
(defun org-e-man-fixed-width (fixed-width contents info)
(defun org-man-fixed-width (fixed-width contents info)
"Transcode a FIXED-WIDTH element from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(org-e-man--wrap-label
(org-man--wrap-label
fixed-width
(format "\\fC\n%s\\fP"
(org-remove-indentation
@ -452,7 +449,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;; Headline
(defun org-e-man-headline (headline contents info)
(defun org-man-headline (headline contents info)
"Transcode an HEADLINE element from Org to Man.
CONTENTS holds the contents of the headline. INFO is a plist
holding contextual information."
@ -505,13 +502,13 @@ holding contextual information."
;;; Inline Src Block
(defun org-e-man-inline-src-block (inline-src-block contents info)
(defun org-man-inline-src-block (inline-src-block contents info)
"Transcode an INLINE-SRC-BLOCK element from Org to Man.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((code (org-element-property :value inline-src-block)))
(cond
(org-e-man-source-highlight
(org-man-source-highlight
(let* ((tmpdir (if (featurep 'xemacs)
temp-directory
temporary-file-directory ))
@ -521,7 +518,7 @@ contextual information."
(expand-file-name "reshilite" tmpdir)))
(org-lang (org-element-property :language inline-src-block))
(lst-lang (cadr (assq (intern org-lang)
org-e-man-source-highlight-langs)))
org-man-source-highlight-langs)))
(cmd (concat (expand-file-name "source-highlight")
" -s " lst-lang
@ -549,7 +546,7 @@ contextual information."
;;; Inlinetask
;;; Italic
(defun org-e-man-italic (italic contents info)
(defun org-man-italic (italic contents info)
"Transcode ITALIC from Org to Man.
CONTENTS is the text with italic markup. INFO is a plist holding
contextual information."
@ -559,7 +556,7 @@ contextual information."
;;; Item
(defun org-e-man-item (item contents info)
(defun org-man-item (item contents info)
"Transcode an ITEM element from Org to Man.
CONTENTS holds the contents of the item. INFO is a plist holding
@ -595,7 +592,7 @@ contextual information."
;;; Keyword
(defun org-e-man-keyword (keyword contents info)
(defun org-man-keyword (keyword contents info)
"Transcode a KEYWORD element from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((key (org-element-property :key keyword))
@ -608,37 +605,9 @@ CONTENTS is nil. INFO is a plist holding contextual information."
((string= key "TOC" ) nil))))
;;; Man Environment
(defun org-e-man-man-environment (man-environment contents info)
"Transcode a MAN-ENVIRONMENT element from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((label (org-element-property :name man-environment))
(value (org-remove-indentation
(org-element-property :value man-environment))))
(if (not (org-string-nw-p label)) value
;; Environment is labelled: label must be within the environment
;; (otherwise, a reference pointing to that element will count
;; the section instead).
(with-temp-buffer
(insert value)
(goto-char (point-min))
(forward-line)
(insert (format "%s\n" label))
(buffer-string)))))
;;; Man Fragment
(defun org-e-man-man-fragment (man-fragment contents info)
"Transcode a MAN-FRAGMENT object from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(org-element-property :value man-fragment))
;;; Line Break
(defun org-e-man-line-break (line-break contents info)
(defun org-man-line-break (line-break contents info)
"Transcode a LINE-BREAK object from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
".br\n")
@ -647,7 +616,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;; Link
(defun org-e-man-link (link desc info)
(defun org-man-link (link desc info)
"Transcode a LINK object from Org to Man.
DESC is the description part of the link, or the empty string.
@ -681,7 +650,7 @@ INFO is a plist holding contextual information. See
;;; Paragraph
(defun org-e-man-paragraph (paragraph contents info)
(defun org-man-paragraph (paragraph contents info)
"Transcode a PARAGRAPH element from Org to Man.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
@ -702,7 +671,7 @@ the plist used as a communication channel."
;;; Plain List
(defun org-e-man-plain-list (plain-list contents info)
(defun org-man-plain-list (plain-list contents info)
"Transcode a PLAIN-LIST element from Org to Man.
CONTENTS is the contents of the list. INFO is a plist holding
contextual information."
@ -710,7 +679,7 @@ contextual information."
;;; Plain Text
(defun org-e-man-plain-text (text info)
(defun org-man-plain-text (text info)
"Transcode a TEXT string from Org to Man.
TEXT is the string to transcode. INFO is a plist holding
contextual information."
@ -740,17 +709,17 @@ contextual information."
;;; Quote Block
(defun org-e-man-quote-block (quote-block contents info)
(defun org-man-quote-block (quote-block contents info)
"Transcode a QUOTE-BLOCK element from Org to Man.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(org-e-man--wrap-label
(org-man--wrap-label
quote-block
(format ".RS\n%s\n.RE" contents)))
;;; Quote Section
(defun org-e-man-quote-section (quote-section contents info)
(defun org-man-quote-section (quote-section contents info)
"Transcode a QUOTE-SECTION element from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((value (org-remove-indentation
@ -760,7 +729,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;; Radio Target
(defun org-e-man-radio-target (radio-target text info)
(defun org-man-radio-target (radio-target text info)
"Transcode a RADIO-TARGET object from Org to Man.
TEXT is the text of the target. INFO is a plist holding
contextual information."
@ -769,7 +738,7 @@ contextual information."
;;; Section
(defun org-e-man-section (section contents info)
(defun org-man-section (section contents info)
"Transcode a SECTION element from Org to Man.
CONTENTS holds the contents of the section. INFO is a plist
holding contextual information."
@ -778,19 +747,19 @@ holding contextual information."
;;; Special Block
(defun org-e-man-special-block (special-block contents info)
(defun org-man-special-block (special-block contents info)
"Transcode a SPECIAL-BLOCK element from Org to Man.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let ((type (downcase (org-element-property :type special-block))))
(org-e-man--wrap-label
(org-man--wrap-label
special-block
(format "%s\n" contents))))
;;; Src Block
(defun org-e-man-src-block (src-block contents info)
(defun org-man-src-block (src-block contents info)
"Transcode a SRC-BLOCK element from Org to Man.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
@ -798,17 +767,17 @@ contextual information."
(code (org-element-property :value src-block))
(custom-env (and lang
(cadr (assq (intern lang)
org-e-man-custom-lang-environments))))
org-man-custom-lang-environments))))
(num-start (case (org-element-property :number-lines src-block)
(continued (org-export-get-loc src-block info))
(new 0)))
(retain-labels (org-element-property :retain-labels src-block)))
(cond
;; Case 1. No source fontification.
((not org-e-man-source-highlight)
((not org-man-source-highlight)
(format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n"
(org-export-format-code-default src-block info)))
(org-e-man-source-highlight
(org-man-source-highlight
(let* ((tmpdir (if (featurep 'xemacs)
temp-directory
temporary-file-directory ))
@ -820,7 +789,7 @@ contextual information."
(org-lang (org-element-property :language src-block))
(lst-lang (cadr (assq (intern org-lang)
org-e-man-source-highlight-langs)))
org-man-source-highlight-langs)))
(cmd (concat "source-highlight"
" -s " lst-lang
@ -841,7 +810,7 @@ contextual information."
;;; Statistics Cookie
(defun org-e-man-statistics-cookie (statistics-cookie contents info)
(defun org-man-statistics-cookie (statistics-cookie contents info)
"Transcode a STATISTICS-COOKIE object from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual information."
(org-element-property :value statistics-cookie))
@ -849,7 +818,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;; Strike-Through
(defun org-e-man-strike-through (strike-through contents info)
(defun org-man-strike-through (strike-through contents info)
"Transcode STRIKE-THROUGH from Org to Man.
CONTENTS is the text with strike-through markup. INFO is a plist
holding contextual information."
@ -857,7 +826,7 @@ holding contextual information."
;;; Subscript
(defun org-e-man-subscript (subscript contents info)
(defun org-man-subscript (subscript contents info)
"Transcode a SUBSCRIPT object from Org to Man.
CONTENTS is the contents of the object. INFO is a plist holding
contextual information."
@ -865,7 +834,7 @@ contextual information."
;;; Superscript "^_%s$
(defun org-e-man-superscript (superscript contents info)
(defun org-man-superscript (superscript contents info)
"Transcode a SUPERSCRIPT object from Org to Man.
CONTENTS is the contents of the object. INFO is a plist holding
contextual information."
@ -874,22 +843,22 @@ contextual information."
;;; Table
;;
;; `org-e-man-table' is the entry point for table transcoding. It
;; `org-man-table' is the entry point for table transcoding. It
;; takes care of tables with a "verbatim" attribute. Otherwise, it
;; delegates the job to either `org-e-man-table--table.el-table' or
;; `org-e-man-table--org-table' functions, depending of the type of
;; delegates the job to either `org-man-table--table.el-table' or
;; `org-man-table--org-table' functions, depending of the type of
;; the table.
;;
;; `org-e-man-table--align-string' is a subroutine used to build
;; `org-man-table--align-string' is a subroutine used to build
;; alignment string for Org tables.
(defun org-e-man-table (table contents info)
(defun org-man-table (table contents info)
"Transcode a TABLE element from Org to Man.
CONTENTS is the contents of the table. INFO is a plist holding
contextual information."
(cond
;; Case 1: verbatim table.
((or org-e-man-tables-verbatim
((or org-man-tables-verbatim
(let ((attr (read (format "(%s)"
(mapconcat
#'identity
@ -904,42 +873,40 @@ contextual information."
(org-element-interpret-data
`(table nil ,@(org-element-contents table))))))
;; Case 2: Standard table.
(t (org-e-man-table--org-table table contents info))))
(t (org-man-table--org-table table contents info))))
(defun org-e-man-table--align-string (divider table info)
(defun org-man-table--align-string (divider table info)
"Return an appropriate Man alignment string.
TABLE is the considered table. INFO is a plist used as
a communication channel."
(let (alignment)
;; Extract column groups and alignment from first (non-rule)
;; row.
(org-element-map
(org-element-map
table 'table-row
(lambda (row)
(and (eq (org-element-property :type row) 'standard) row))
info 'first-match)
'table-cell
(lambda (cell)
(let* ((borders (org-export-table-cell-borders cell info))
(raw-width (org-export-table-cell-width cell info))
(width-cm (when raw-width (/ raw-width 5)))
(width (if raw-width (format "w(%dc)"
(if (< width-cm 1) 1 width-cm)) "")))
;; Check left border for the first cell only.
(when (and (memq 'left borders) (not alignment))
(push "|" alignment))
(push
(case (org-export-table-cell-alignment cell info)
(left (concat "l" width divider))
(right (concat "r" width divider))
(center (concat "c" width divider)))
alignment)
(when (memq 'right borders) (push "|" alignment))))
info)
(apply 'concat (reverse alignment))))
(let (alignment)
;; Extract column groups and alignment from first (non-rule) row.
(org-element-map
(org-element-map table 'table-row
(lambda (row)
(and (eq (org-element-property :type row) 'standard) row))
info 'first-match)
'table-cell
(lambda (cell)
(let* ((borders (org-export-table-cell-borders cell info))
(raw-width (org-export-table-cell-width cell info))
(width-cm (when raw-width (/ raw-width 5)))
(width (if raw-width (format "w(%dc)"
(if (< width-cm 1) 1 width-cm)) "")))
;; Check left border for the first cell only.
(when (and (memq 'left borders) (not alignment))
(push "|" alignment))
(push
(case (org-export-table-cell-alignment cell info)
(left (concat "l" width divider))
(right (concat "r" width divider))
(center (concat "c" width divider)))
alignment)
(when (memq 'right borders) (push "|" alignment))))
info)
(apply 'concat (reverse alignment))))
(defun org-e-man-table--org-table (table contents info)
(defun org-man-table--org-table (table contents info)
"Return appropriate Man code for an Org table.
TABLE is the table type element to transcode. CONTENTS is its
@ -950,11 +917,11 @@ This function assumes TABLE has `org' as its `:type' attribute."
(let* ((attr (org-export-read-attribute :attr_man table))
(label (org-element-property :name table))
(caption (and (not (plist-get attr :disable-caption))
(org-e-man--caption/label-string table info)))
(org-man--caption/label-string table info)))
(divider (if (plist-get attr :divider) "|" " "))
;; Determine alignment string.
(alignment (org-e-man-table--align-string divider table info))
(alignment (org-man-table--align-string divider table info))
;; Extract others display options.
(lines (org-split-string contents "\n"))
@ -969,9 +936,7 @@ This function assumes TABLE has `org' as its `:type' attribute."
(case (plist-get attr :placement)
('center "center")
('left nil)
(t
(if org-e-man-tables-centered
"center" "")))
(t (if org-man-tables-centered "center" "")))
(case (plist-get attr :boxtype)
('box "box")
@ -1053,16 +1018,16 @@ This function assumes TABLE has `org' as its `:type' attribute."
;;; Table Cell
(defun org-e-man-table-cell (table-cell contents info)
(defun org-man-table-cell (table-cell contents info)
"Transcode a TABLE-CELL element from Org to Man
CONTENTS is the cell contents. INFO is a plist used as
a communication channel."
(concat (if (and contents
org-e-man-table-scientific-notation
org-man-table-scientific-notation
(string-match orgtbl-exp-regexp contents))
;; Use appropriate format string for scientific
;; notation.
(format org-e-man-table-scientific-notation
(format org-man-table-scientific-notation
(match-string 1 contents)
(match-string 2 contents))
contents )
@ -1071,7 +1036,7 @@ a communication channel."
;;; Table Row
(defun org-e-man-table-row (table-row contents info)
(defun org-man-table-row (table-row contents info)
"Transcode a TABLE-ROW element from Org to Man
CONTENTS is the contents of the row. INFO is a plist used as
a communication channel."
@ -1100,7 +1065,7 @@ a communication channel."
;;; Target
(defun org-e-man-target (target contents info)
(defun org-man-target (target contents info)
"Transcode a TARGET object from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual
information."
@ -1110,7 +1075,7 @@ information."
;;; Timestamp
(defun org-e-man-timestamp (timestamp contents info)
(defun org-man-timestamp (timestamp contents info)
"Transcode a TIMESTAMP object from Org to Man.
CONTENTS is nil. INFO is a plist holding contextual
information."
@ -1119,7 +1084,7 @@ information."
;;; Underline
(defun org-e-man-underline (underline contents info)
(defun org-man-underline (underline contents info)
"Transcode UNDERLINE from Org to Man.
CONTENTS is the text with underline markup. INFO is a plist
holding contextual information."
@ -1128,7 +1093,7 @@ holding contextual information."
;;; Verbatim
(defun org-e-man-verbatim (verbatim contents info)
(defun org-man-verbatim (verbatim contents info)
"Transcode a VERBATIM object from Org to Man.
CONTENTS is nil. INFO is a plist used as a communication
channel."
@ -1137,7 +1102,7 @@ channel."
;;; Verse Block
(defun org-e-man-verse-block (verse-block contents info)
(defun org-man-verse-block (verse-block contents info)
"Transcode a VERSE-BLOCK element from Org to Man.
CONTENTS is verse block contents. INFO is a plist holding
contextual information."
@ -1147,7 +1112,7 @@ contextual information."
;;; Interactive functions
(defun org-e-man-export-to-man
(defun org-man-export-to-man
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a Man file.
@ -1179,14 +1144,14 @@ Return output file's name."
(let ((outfile (org-export-output-file-name ".man" subtreep)))
(if async
(org-export-async-start
(lambda (f) (org-export-add-to-stack f 'e-man))
(lambda (f) (org-export-add-to-stack f 'man))
`(expand-file-name
(org-export-to-file
'e-man ,outfile ,subtreep ,visible-only ,body-only ',ext-plist)))
'man ,outfile ,subtreep ,visible-only ,body-only ',ext-plist)))
(org-export-to-file
'e-man outfile subtreep visible-only body-only ext-plist))))
'man outfile subtreep visible-only body-only ext-plist))))
(defun org-e-man-export-to-pdf
(defun org-man-export-to-pdf
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to Groff then process through to PDF.
@ -1218,20 +1183,20 @@ Return PDF file's name."
(if async
(let ((outfile (org-export-output-file-name ".man" subtreep)))
(org-export-async-start
(lambda (f) (org-export-add-to-stack f 'e-man))
(lambda (f) (org-export-add-to-stack f 'man))
`(expand-file-name
(org-e-man-compile
(org-man-compile
(org-export-to-file
'e-man ,outfile ,subtreep ,visible-only ,body-only
'man ,outfile ,subtreep ,visible-only ,body-only
',ext-plist)))))
(org-e-man-compile
(org-e-man-export-to-man nil subtreep visible-only body-only ext-plist))))
(org-man-compile
(org-man-export-to-man nil subtreep visible-only body-only ext-plist))))
(defun org-e-man-compile (file)
(defun org-man-compile (file)
"Compile a Groff file.
FILE is the name of the file being compiled. Processing is done
through the command specified in `org-e-man-pdf-process'.
through the command specified in `org-man-pdf-process'.
Return PDF file name or an error if it couldn't be produced."
(let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
@ -1245,12 +1210,12 @@ Return PDF file name or an error if it couldn't be produced."
(save-window-excursion
(cond
;; A function is provided: Apply it.
((functionp org-e-man-pdf-process)
(funcall org-e-man-pdf-process (shell-quote-argument file)))
((functionp org-man-pdf-process)
(funcall org-man-pdf-process (shell-quote-argument file)))
;; A list is provided: Replace %b, %f and %o with appropriate
;; values in each command before applying it. Output is
;; redirected to "*Org PDF Groff Output*" buffer.
((consp org-e-man-pdf-process)
((consp org-man-pdf-process)
(let ((outbuf (get-buffer-create "*Org PDF Groff Output*")))
(mapc
(lambda (command)
@ -1262,9 +1227,9 @@ Return PDF file name or an error if it couldn't be produced."
(replace-regexp-in-string
"%o" (shell-quote-argument out-dir) command t t) t t) t t)
outbuf))
org-e-man-pdf-process)
org-man-pdf-process)
;; Collect standard errors from output buffer.
(setq errors (org-e-man-collect-errors outbuf))))
(setq errors (org-man-collect-errors outbuf))))
(t (error "No valid command to process to PDF")))
(let ((pdffile (concat out-dir base-name ".pdf")))
;; Check for process failure. Provide collected errors if
@ -1274,8 +1239,8 @@ Return PDF file name or an error if it couldn't be produced."
(when errors (concat ": " errors))))
;; Else remove log files, when specified, and signal end of
;; process to user, along with any error encountered.
(when org-e-man-remove-logfiles
(dolist (ext org-e-man-logfiles-extensions)
(when org-man-remove-logfiles
(dolist (ext org-man-logfiles-extensions)
(let ((file (concat out-dir base-name "." ext)))
(when (file-exists-p file) (delete-file file)))))
(message (concat "Process completed"
@ -1284,7 +1249,7 @@ Return PDF file name or an error if it couldn't be produced."
;; Return output file name.
pdffile))))
(defun org-e-man-collect-errors (buffer)
(defun org-man-collect-errors (buffer)
"Collect some kind of errors from \"groff\" output
BUFFER is the buffer containing output.
Return collected error types as a string, or nil if there was
@ -1296,5 +1261,10 @@ none."
nil )))
(provide 'org-e-man)
;;; org-e-man.el ends here
(provide 'ox-man)
;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:
;;; ox-man.el ends here

View File

@ -1,4 +1,4 @@
;;; org-md.el --- Markdown Back-End for Org Export Engine
;;; ox-md.el --- Markdown Back-End for Org Export Engine
;; Copyright (C) 2012, 2013 Free Software Foundation, Inc.
@ -21,7 +21,7 @@
;;; Commentary:
;; This library implements a Markdown back-end (vanilla flavour) for
;; Org exporter, based on `e-html'.
;; Org exporter, based on `html' back-end.
;;
;; It provides two commands for export, depending on the desired
;; output: `org-md-export-as-markdown' (temporary buffer) and
@ -29,7 +29,7 @@
;;; Code:
(require 'org-e-html)
(require 'ox-html)
@ -53,7 +53,7 @@ This variable can be set to either `atx' or `setext'."
;;; Define Back-End
(org-export-define-derived-backend md e-html
(org-export-define-derived-backend md html
:export-block ("MD" "MARKDOWN")
:filters-alist ((:filter-parse-tree . org-md-separate-elements))
:menu-entry
@ -99,14 +99,13 @@ TREE is the parse tree being exported. BACKEND is the export
back-end used. INFO is a plist used as a communication channel.
Assume BACKEND is `md'."
(org-element-map
tree org-element-all-elements
(lambda (elem)
(unless (eq (org-element-type elem) 'org-data)
(org-element-put-property
elem :post-blank
(let ((post-blank (org-element-property :post-blank elem)))
(if (not post-blank) 1 (max 1 post-blank)))))))
(org-element-map tree org-element-all-elements
(lambda (elem)
(unless (eq (org-element-type elem) 'org-data)
(org-element-put-property
elem :post-blank
(let ((post-blank (org-element-property :post-blank elem)))
(if (not post-blank) 1 (max 1 post-blank)))))))
;; Return updated tree.
tree)
@ -264,9 +263,9 @@ a communication channel."
(function
(lambda (raw-path info)
;; Treat links to `file.org' as links to `file.html', if
;; needed. See `org-e-html-link-org-files-as-html'.
;; needed. See `org-html-link-org-files-as-html'.
(cond
((and org-e-html-link-org-files-as-html
((and org-html-link-org-files-as-html
(string= ".org"
(downcase (file-name-extension raw-path "."))))
(concat (file-name-sans-extension raw-path) "."
@ -288,7 +287,7 @@ a communication channel."
(org-export-get-headline-number
destination info)
".")))))))
((org-export-inline-image-p link org-e-html-inline-image-rules)
((org-export-inline-image-p link org-html-inline-image-rules)
(let ((path (let ((raw-path (org-element-property :path link)))
(if (not (file-name-absolute-p raw-path)) raw-path
(expand-file-name raw-path)))))
@ -373,7 +372,7 @@ contextual information."
(setq text (replace-regexp-in-string "[`*_\\]" "\\\\\\&" text))
;; Handle special strings, if required.
(when (plist-get info :with-special-strings)
(setq text (org-e-html-convert-special-strings text)))
(setq text (org-html-convert-special-strings text)))
;; Handle break preservation, if required.
(when (plist-get info :preserve-breaks)
(setq text (replace-regexp-in-string "[ \t]*\n" " \n" text)))
@ -485,5 +484,10 @@ Return output file's name."
(org-export-to-file 'md outfile subtreep visible-only))))
(provide 'org-md)
;;; org-md.el ends here
(provide 'ox-md)
;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:
;;; ox-md.el ends here

File diff suppressed because it is too large Load Diff

114
lisp/ox-org.el Normal file
View File

@ -0,0 +1,114 @@
;;; ox-org.el --- Org Back-End for Org Export Engine
;; Copyright (C) 2013 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Keywords: org, wp
;; This program 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.
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This library implements an Org back-end for Org exporter. Since
;; its usage is mainly internal, it doesn't provide any interactive
;; function.
;;; Code:
(require 'ox)
(org-export-define-backend org
((babel-call . org-org-identity)
(bold . org-org-identity)
(center-block . org-org-identity)
(clock . org-org-identity)
(code . org-org-identity)
(diary-sexp . org-org-identity)
(drawer . org-org-identity)
(dynamic-block . org-org-identity)
(entity . org-org-identity)
(example-block . org-org-identity)
(fixed-width . org-org-identity)
(footnote-definition . org-org-identity)
(footnote-reference . org-org-identity)
(headline . org-org-headline)
(horizontal-rule . org-org-identity)
(inline-babel-call . org-org-identity)
(inline-src-block . org-org-identity)
(inlinetask . org-org-identity)
(italic . org-org-identity)
(item . org-org-identity)
(keyword . org-org-keyword)
(latex-environment . org-org-identity)
(latex-fragment . org-org-identity)
(line-break . org-org-identity)
(link . org-org-identity)
(node-property . org-org-identity)
(paragraph . org-org-identity)
(plain-list . org-org-identity)
(planning . org-org-identity)
(property-drawer . org-org-identity)
(quote-block . org-org-identity)
(quote-section . org-org-identity)
(radio-target . org-org-identity)
(section . org-org-identity)
(special-block . org-org-identity)
(src-block . org-org-identity)
(statistics-cookie . org-org-identity)
(strike-through . org-org-identity)
(subscript . org-org-identity)
(superscript . org-org-identity)
(table . org-org-identity)
(table-cell . org-org-identity)
(table-row . org-org-identity)
(target . org-org-identity)
(timestamp . org-org-identity)
(underline . org-org-identity)
(verbatim . org-org-identity)
(verse-block . org-org-identity)))
(defun org-org-identity (blob contents info)
"Transcode BLOB element or object back into Org syntax."
(funcall
(intern (format "org-element-%s-interpreter" (org-element-type blob)))
blob contents))
(defun org-org-headline (headline contents info)
"Transcode HEADLINE element back into Org syntax."
(unless (plist-get info :with-todo-keywords)
(org-element-put-property headline :todo-keyword nil))
(unless (plist-get info :with-tags)
(org-element-put-property headline :tags nil))
(unless (plist-get info :with-priority)
(org-element-put-property headline :priority nil))
(org-element-headline-interpreter headline contents))
(defun org-org-keyword (keyword contents info)
"Transcode KEYWORD element back into Org syntax.
Ignore keywords targeted at other export back-ends."
(unless (member (org-element-property :key keyword)
(mapcar
(lambda (block-cons)
(and (eq (cdr block-cons) 'org-element-export-block-parser)
(car block-cons)))
org-element-block-name-alist))
(org-element-keyword-interpreter keyword nil)))
(provide 'ox-org)
;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:
;;; ox-org.el ends here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -70,7 +70,8 @@ work correctly if this file is not up-to-date."
(with-temp-buffer
(set-visited-file-name "org-loaddefs.el")
(insert ";;; org-loaddefs.el --- autogenerated file, do not edit\n;;\n;;; Code:\n")
(let ((files (directory-files default-directory nil "^\\(org\\|ob\\)\\(-.*\\)?\\.el$")))
(let ((files (directory-files default-directory
nil "^\\(org\\|ob\\|ox\\)\\(-.*\\)?\\.el$")))
(mapc (lambda (f) (generate-file-autoloads f)) files))
(insert "\f\n(provide 'org-loaddefs)\n")
(insert "\f\n;; Local Variables:\n;; version-control: never\n")

View File

@ -1,4 +1,4 @@
;;; test-org-export.el --- Tests for org-export.el
;;; test-ox.el --- Tests for ox.el
;; Copyright (C) 2012, 2013 Nicolas Goaziou
@ -21,7 +21,7 @@
;;; Code:
(unless (featurep 'org-export)
(unless (featurep 'ox)
(signal 'missing-test-dependency "org-export"))
(defmacro org-test-with-backend (backend &rest body)
@ -73,38 +73,22 @@ already filled in `info'."
(ert-deftest test-org-export/bind-keyword ()
"Test reading #+BIND: keywords."
;; Test with `org-export-all-BIND' set to t.
;; Test with `org-export-allow-bind-keywords' set to t.
(should
(org-test-with-temp-text "#+BIND: variable value"
(let ((org-export-allow-BIND t))
(let ((org-export-allow-bind-keywords t))
(org-export--install-letbind-maybe)
(eq variable 'value))))
;; Test with `org-export-all-BIND' set to nil.
;; Test with `org-export-allow-bind-keywords' set to nil.
(should-not
(org-test-with-temp-text "#+BIND: variable value"
(let ((org-export-allow-BIND nil))
(org-export--install-letbind-maybe)
(boundp 'variable))))
;; Test with `org-export-all-BIND' set to 'confirm and
;; `org-export--allow-BIND-local' to t .
(should
(org-test-with-temp-text "#+BIND: variable value"
(let ((org-export-allow-BIND 'confirm))
(org-set-local 'org-export--allow-BIND-local t)
(org-export--install-letbind-maybe)
(eq variable 'value))))
;; Test with `org-export-all-BIND' set to 'confirm and
;; `org-export--allow-BIND-local' to nil.
(should-not
(org-test-with-temp-text "#+BIND: variable value"
(let ((org-export-allow-BIND 'confirm))
(org-set-local 'org-export--allow-BIND-local nil)
(let ((org-export-allow-bind-keywords nil))
(org-export--install-letbind-maybe)
(boundp 'variable))))
;; BIND keywords are case-insensitive.
(should
(org-test-with-temp-text "#+bind: variable value"
(let ((org-export-allow-BIND t))
(let ((org-export-allow-bind-keywords t))
(org-export--install-letbind-maybe)
(eq variable 'value)))))
@ -302,6 +286,15 @@ Paragraph"
(string-match
"\\`\\* Head1[ \t]+:archive:\n\\'"
(org-export-as 'test nil nil nil '(:with-archived-trees t)))))))
;; Clocks.
(let ((org-clock-string "CLOCK:"))
(org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
(org-test-with-backend test
(should
(equal (org-export-as 'test nil nil nil '(:with-clocks t))
"CLOCK: [2012-04-29 sun. 10:45]\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-clocks nil)) "")))))
;; Drawers.
(let ((org-drawers '("TEST")))
(org-test-with-temp-text ":TEST:\ncontents\n:END:"
@ -316,39 +309,12 @@ Paragraph"
(should
(equal (org-export-as 'test nil nil nil '(:with-drawers ("FOO")))
":FOO:\nkeep\n:END:\n")))))
;; Timestamps.
(org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
(org-test-with-backend test
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps t))
"[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps nil)) ""))
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps active))
"<2012-04-29 sun. 10:45>\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps inactive))
"[2012-04-29 sun. 10:45]\n"))))
;; Clocks.
(let ((org-clock-string "CLOCK:"))
(org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
(let ((org-drawers '("FOO" "BAR")))
(org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
(org-test-with-backend test
(should
(equal (org-export-as 'test nil nil nil '(:with-clocks t))
"CLOCK: [2012-04-29 sun. 10:45]\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-clocks nil)) "")))))
;; Plannings.
(let ((org-closed-string "CLOSED:"))
(org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
(org-test-with-backend test
(should
(equal (org-export-as 'test nil nil nil '(:with-plannings t))
"CLOSED: [2012-04-29 sun. 10:45]\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-plannings nil))
"")))))
(equal (org-export-as 'test nil nil nil '(:with-drawers (not "BAR")))
":FOO:\nkeep\n:END:\n")))))
;; Inlinetasks.
(when (featurep 'org-inlinetask)
(should
@ -366,13 +332,37 @@ Paragraph"
(org-test-with-backend test
(org-export-as 'test nil nil nil '(:with-inlinetasks nil)))))
"")))
;; Plannings.
(let ((org-closed-string "CLOSED:"))
(org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
(org-test-with-backend test
(should
(equal (org-export-as 'test nil nil nil '(:with-plannings t))
"CLOSED: [2012-04-29 sun. 10:45]\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-plannings nil))
"")))))
;; Statistics cookies.
(should
(equal ""
(org-test-with-temp-text "[0/0]"
(org-test-with-backend test
(org-export-as
'test nil nil nil '(:with-statistics-cookies nil)))))))
'test nil nil nil '(:with-statistics-cookies nil))))))
;; Timestamps.
(org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
(org-test-with-backend test
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps t))
"[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps nil)) ""))
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps active))
"<2012-04-29 sun. 10:45>\n"))
(should
(equal (org-export-as 'test nil nil nil '(:with-timestamps inactive))
"[2012-04-29 sun. 10:45]\n")))))
(ert-deftest test-org-export/comment-tree ()
"Test if export process ignores commented trees."
@ -669,7 +659,18 @@ body\n")))
(org-export-define-backend parent ((:headline . parent)))
(org-export-define-derived-backend test parent
:translate-alist ((:headline . test)))
(org-export-backend-translate-table 'test)))))
(org-export-backend-translate-table 'test))))
;; Options defined in the new back have priority over those defined
;; in parent.
(should
(eq 'test
(let (org-export-registered-backends)
(org-export-define-backend parent
((:headline . parent))
:options-alist ((:a nil nil 'parent)))
(org-export-define-derived-backend test parent
:options-alist ((:a nil nil 'test)))
(plist-get (org-export--get-global-options 'test) :a)))))
(ert-deftest test-org-export/derived-backend-p ()
"Test `org-export-derived-backend-p' specifications."
@ -2213,5 +2214,5 @@ Another text. (ref:text)
(org-element-map tree 'code 'identity info t) info 2))))))
(provide 'test-org-export)
(provide 'test-ox)
;;; test-org-export.el end here