Commit 8dd2bfc2 authored by Nicolas Goaziou's avatar Nicolas Goaziou
Browse files

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.
parent 33c4f623
......@@ -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
......
;;; 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)
;;; 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
;;; 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
;;; 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)