2015-10-31 23:58:57 +00:00
|
|
|
|
;;; ox-odt.el --- OpenDocument Text Exporter for Org Mode -*- lexical-binding: t; -*-
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2020-01-01 18:38:46 +00:00
|
|
|
|
;; Copyright (C) 2010-2020 Free Software Foundation, Inc.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Jambunathan K <kjambunathan at gmail dot com>
|
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
2018-01-16 16:22:00 +00:00
|
|
|
|
;; Homepage: https://orgmode.org
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-02-23 07:59:23 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
2012-05-18 08:18:42 +00:00
|
|
|
|
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(require 'cl-lib)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(require 'format-spec)
|
2012-12-30 10:05:57 +00:00
|
|
|
|
(require 'org-compat)
|
2018-11-10 20:59:52 +00:00
|
|
|
|
(require 'org-macs)
|
|
|
|
|
(require 'ox)
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(require 'table nil 'noerror)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-05-18 08:18:42 +00:00
|
|
|
|
;;; Define Back-End
|
|
|
|
|
|
2013-03-19 15:24:40 +00:00
|
|
|
|
(org-export-define-backend 'odt
|
|
|
|
|
'((bold . org-odt-bold)
|
|
|
|
|
(center-block . org-odt-center-block)
|
|
|
|
|
(clock . org-odt-clock)
|
|
|
|
|
(code . org-odt-code)
|
|
|
|
|
(drawer . org-odt-drawer)
|
|
|
|
|
(dynamic-block . org-odt-dynamic-block)
|
|
|
|
|
(entity . org-odt-entity)
|
|
|
|
|
(example-block . org-odt-example-block)
|
2014-09-08 09:57:27 +00:00
|
|
|
|
(export-block . org-odt-export-block)
|
2013-03-19 15:24:40 +00:00
|
|
|
|
(export-snippet . org-odt-export-snippet)
|
|
|
|
|
(fixed-width . org-odt-fixed-width)
|
|
|
|
|
(footnote-definition . org-odt-footnote-definition)
|
|
|
|
|
(footnote-reference . org-odt-footnote-reference)
|
|
|
|
|
(headline . org-odt-headline)
|
|
|
|
|
(horizontal-rule . org-odt-horizontal-rule)
|
|
|
|
|
(inline-src-block . org-odt-inline-src-block)
|
|
|
|
|
(inlinetask . org-odt-inlinetask)
|
|
|
|
|
(italic . org-odt-italic)
|
|
|
|
|
(item . org-odt-item)
|
|
|
|
|
(keyword . org-odt-keyword)
|
|
|
|
|
(latex-environment . org-odt-latex-environment)
|
|
|
|
|
(latex-fragment . org-odt-latex-fragment)
|
|
|
|
|
(line-break . org-odt-line-break)
|
|
|
|
|
(link . org-odt-link)
|
2013-09-25 19:27:29 +00:00
|
|
|
|
(node-property . org-odt-node-property)
|
2013-03-19 15:24:40 +00:00
|
|
|
|
(paragraph . org-odt-paragraph)
|
|
|
|
|
(plain-list . org-odt-plain-list)
|
|
|
|
|
(plain-text . org-odt-plain-text)
|
|
|
|
|
(planning . org-odt-planning)
|
|
|
|
|
(property-drawer . org-odt-property-drawer)
|
|
|
|
|
(quote-block . org-odt-quote-block)
|
|
|
|
|
(radio-target . org-odt-radio-target)
|
|
|
|
|
(section . org-odt-section)
|
|
|
|
|
(special-block . org-odt-special-block)
|
|
|
|
|
(src-block . org-odt-src-block)
|
|
|
|
|
(statistics-cookie . org-odt-statistics-cookie)
|
|
|
|
|
(strike-through . org-odt-strike-through)
|
|
|
|
|
(subscript . org-odt-subscript)
|
|
|
|
|
(superscript . org-odt-superscript)
|
|
|
|
|
(table . org-odt-table)
|
|
|
|
|
(table-cell . org-odt-table-cell)
|
|
|
|
|
(table-row . org-odt-table-row)
|
|
|
|
|
(target . org-odt-target)
|
|
|
|
|
(template . org-odt-template)
|
|
|
|
|
(timestamp . org-odt-timestamp)
|
|
|
|
|
(underline . org-odt-underline)
|
|
|
|
|
(verbatim . org-odt-verbatim)
|
|
|
|
|
(verse-block . org-odt-verse-block))
|
|
|
|
|
:filters-alist '((:filter-parse-tree
|
|
|
|
|
. (org-odt--translate-latex-fragments
|
|
|
|
|
org-odt--translate-description-lists
|
2016-12-17 10:36:49 +00:00
|
|
|
|
org-odt--translate-list-tables
|
|
|
|
|
org-odt--translate-image-links)))
|
2012-09-09 11:08:52 +00:00
|
|
|
|
:menu-entry
|
2013-03-19 15:24:40 +00:00
|
|
|
|
'(?o "Export to ODT"
|
|
|
|
|
((?o "As ODT file" org-odt-export-to-odt)
|
|
|
|
|
(?O "As ODT file and open"
|
|
|
|
|
(lambda (a s v b)
|
|
|
|
|
(if a (org-odt-export-to-odt t s v)
|
|
|
|
|
(org-open-file (org-odt-export-to-odt nil s v) 'system))))))
|
2012-07-23 12:06:13 +00:00
|
|
|
|
:options-alist
|
2020-03-04 23:50:30 +00:00
|
|
|
|
'((:odt-styles-file "ODT_STYLES_FILE" nil org-odt-styles-file t)
|
2015-03-13 20:38:26 +00:00
|
|
|
|
(:description "DESCRIPTION" nil nil newline)
|
|
|
|
|
(:keywords "KEYWORDS" nil nil space)
|
ox: Add #+SUBTITLE property in some backends
* ox-texinfo.el (texinfo, org-texinfo-template): Parse subtitle.
* ox-s5.el (org-s5-title-slide-template):
* ox-deck.el (org-deck-title-slide-template):
* ox-odt.el (odt, org-odt-template):
* ox-latex.el (latex, org-latex-template):
* ox-html.el (html, org-html-format-spec, org-html-template):
* ox-ascii.el (ascii, org-ascii-template--document-title):
* ox-beamer.el (beamer, org-beamer-template): Support #+SUBTITLE.
* ox-html.el (org-html-postamble-format)
(org-html-preamble-format):
* ox-latex.el (org-latex-title-command)
(org-latex-hyperref-template): Update docstring.
* ox-html.el (org-html-style-default): New .subtitle css property.
* ox-beamer.el (org-beamer-subtitle-format):
* ox-latex.el (org-latex-subtitle-format)
(org-latex-subtitle-separate): New variable.
* org.texi (ASCII/Latin-1/UTF-8 export)
(Beamer specific export settings)
(HTML Specific export settings)
(@LaTeX{} specific export settings, CSS support)
(ODT specific export settings)
(Texinfo specific export settings, Document preamble)
(Publishing options, Publishing options): Document #+SUBTITLE.
The patch adds a #+SUBTITLE keyword to ox-ascii, ox-latex, ox-html and
ox-odt.
2015-03-01 21:09:19 +00:00
|
|
|
|
(:subtitle "SUBTITLE" nil nil parse)
|
2014-05-21 07:06:59 +00:00
|
|
|
|
;; Other variables.
|
|
|
|
|
(:odt-content-template-file nil nil org-odt-content-template-file)
|
|
|
|
|
(:odt-display-outline-level nil nil org-odt-display-outline-level)
|
|
|
|
|
(:odt-fontify-srcblocks nil nil org-odt-fontify-srcblocks)
|
|
|
|
|
(:odt-format-drawer-function nil nil org-odt-format-drawer-function)
|
|
|
|
|
(:odt-format-headline-function nil nil org-odt-format-headline-function)
|
|
|
|
|
(:odt-format-inlinetask-function nil nil org-odt-format-inlinetask-function)
|
|
|
|
|
(:odt-inline-formula-rules nil nil org-odt-inline-formula-rules)
|
|
|
|
|
(:odt-inline-image-rules nil nil org-odt-inline-image-rules)
|
|
|
|
|
(:odt-pixels-per-inch nil nil org-odt-pixels-per-inch)
|
|
|
|
|
(:odt-table-styles nil nil org-odt-table-styles)
|
|
|
|
|
(:odt-use-date-fields nil nil org-odt-use-date-fields)
|
2013-03-19 15:24:40 +00:00
|
|
|
|
;; Redefine regular option.
|
2017-06-25 21:06:37 +00:00
|
|
|
|
(:with-latex nil "tex" org-odt-with-latex)
|
|
|
|
|
;; Retrieve LaTeX header for fragments.
|
|
|
|
|
(:latex-header "LATEX_HEADER" nil nil newline)))
|
2012-07-23 12:06:13 +00:00
|
|
|
|
|
2012-05-18 08:18:42 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;;; Dependencies
|
2012-05-18 08:18:42 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;;; Hooks
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
;;; Function and Dynamically Scoped Variables Declarations
|
2012-06-03 22:29:49 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(declare-function hfy-face-to-style "htmlfontify" (fn))
|
|
|
|
|
(declare-function hfy-face-or-def-to-name "htmlfontify" (fn))
|
2012-10-07 13:04:00 +00:00
|
|
|
|
(declare-function archive-zip-extract "arc-mode" (archive name))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(declare-function org-create-math-formula "org" (latex-frag &optional mathml-file))
|
2012-07-19 17:45:44 +00:00
|
|
|
|
(declare-function browse-url-file-url "browse-url" (file))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defvar nxml-auto-insert-xml-declaration-flag) ; nxml-mode.el
|
|
|
|
|
(defvar archive-zip-extract) ; arc-mode.el
|
|
|
|
|
(defvar hfy-end-span-handler) ; htmlfontify.el
|
|
|
|
|
(defvar hfy-begin-span-handler) ; htmlfontify.el
|
|
|
|
|
(defvar hfy-face-to-css) ; htmlfontify.el
|
|
|
|
|
(defvar hfy-html-quote-map) ; htmlfontify.el
|
|
|
|
|
(defvar hfy-html-quote-regex) ; htmlfontify.el
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;;; Internal Variables
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-lib-dir
|
2014-05-29 20:08:43 +00:00
|
|
|
|
(file-name-directory (or load-file-name (buffer-file-name)))
|
2012-10-03 10:13:47 +00:00
|
|
|
|
"Location of ODT exporter.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
Use this to infer values of `org-odt-styles-dir' and
|
|
|
|
|
`org-odt-schema-dir'.")
|
2012-10-03 10:13:47 +00:00
|
|
|
|
|
2019-02-09 11:28:15 +00:00
|
|
|
|
(defvar org-odt-data-dir (expand-file-name "../../etc/" org-odt-lib-dir)
|
2012-10-03 10:13:47 +00:00
|
|
|
|
"Data directory for ODT exporter.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
Use this to infer values of `org-odt-styles-dir' and
|
|
|
|
|
`org-odt-schema-dir'.")
|
2012-10-03 10:13:47 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-special-string-regexps
|
2012-07-19 16:45:23 +00:00
|
|
|
|
'(("\\\\-" . "­\\1") ; shy
|
|
|
|
|
("---\\([^-]\\)" . "—\\1") ; mdash
|
|
|
|
|
("--\\([^-]\\)" . "–\\1") ; ndash
|
|
|
|
|
("\\.\\.\\." . "…")) ; hellip
|
|
|
|
|
"Regular expressions for special string conversion.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-schema-dir-list
|
2019-02-09 11:28:15 +00:00
|
|
|
|
(list (expand-file-name "./schema/" org-odt-data-dir))
|
2012-10-03 10:13:47 +00:00
|
|
|
|
"List of directories to search for OpenDocument schema files.
|
2019-02-09 11:28:15 +00:00
|
|
|
|
Use this list to set the default value of `org-odt-schema-dir'.
|
|
|
|
|
The entries in this list are populated heuristically based on the
|
|
|
|
|
values of `org-odt-lib-dir' and `org-odt-data-dir'.")
|
2012-10-03 10:13:47 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-styles-dir-list
|
2012-10-03 10:13:47 +00:00
|
|
|
|
(list
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(and org-odt-data-dir
|
|
|
|
|
(expand-file-name "./styles/" org-odt-data-dir)) ; bail out
|
2019-02-09 11:28:15 +00:00
|
|
|
|
(expand-file-name "./styles/" org-odt-data-dir)
|
2016-04-19 19:30:39 +00:00
|
|
|
|
(expand-file-name "../etc/styles/" org-odt-lib-dir) ; git
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(expand-file-name "./etc/styles/" org-odt-lib-dir) ; elpa
|
2012-10-03 10:13:47 +00:00
|
|
|
|
(expand-file-name "./org/" data-directory) ; system
|
|
|
|
|
)
|
|
|
|
|
"List of directories to search for OpenDocument styles files.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
See `org-odt-styles-dir'. The entries in this list are populated
|
|
|
|
|
heuristically based on the values of `org-odt-lib-dir' and
|
|
|
|
|
`org-odt-data-dir'.")
|
2012-10-03 10:13:47 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-styles-dir
|
2016-07-25 15:18:03 +00:00
|
|
|
|
(let ((styles-dir
|
|
|
|
|
(cl-find-if
|
|
|
|
|
(lambda (dir)
|
|
|
|
|
(and dir
|
|
|
|
|
(file-readable-p
|
|
|
|
|
(expand-file-name "OrgOdtContentTemplate.xml" dir))
|
|
|
|
|
(file-readable-p (expand-file-name "OrgOdtStyles.xml" dir))))
|
|
|
|
|
org-odt-styles-dir-list)))
|
2012-10-03 10:13:47 +00:00
|
|
|
|
(unless styles-dir
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(error "Error (ox-odt): Cannot find factory styles files, aborting"))
|
2012-10-03 10:13:47 +00:00
|
|
|
|
styles-dir)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Directory that holds auxiliary XML files used by the ODT exporter.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
This directory contains the following XML files -
|
2012-10-03 10:13:47 +00:00
|
|
|
|
\"OrgOdtStyles.xml\" and \"OrgOdtContentTemplate.xml\". These
|
|
|
|
|
XML files are used as the default values of
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
`org-odt-styles-file' and `org-odt-content-template-file'.
|
2012-10-03 10:13:47 +00:00
|
|
|
|
|
|
|
|
|
The default value of this variable varies depending on the
|
2016-07-25 15:18:03 +00:00
|
|
|
|
version of Org in use and is initialized from
|
|
|
|
|
`org-odt-styles-dir-list'. Note that the user could be using Org
|
|
|
|
|
from one of: Org own private git repository, GNU ELPA tar or
|
2012-10-03 10:13:47 +00:00
|
|
|
|
standard Emacs.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-bookmark-prefix "OrgXref.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-manifest-file-entry-tag
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"\n<manifest:file-entry manifest:media-type=\"%s\" manifest:full-path=\"%s\"%s/>")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-file-extensions
|
2012-07-19 16:45:23 +00:00
|
|
|
|
'(("odt" . "OpenDocument Text")
|
|
|
|
|
("ott" . "OpenDocument Text Template")
|
|
|
|
|
("odm" . "OpenDocument Master Document")
|
|
|
|
|
("ods" . "OpenDocument Spreadsheet")
|
|
|
|
|
("ots" . "OpenDocument Spreadsheet Template")
|
|
|
|
|
("odg" . "OpenDocument Drawing (Graphics)")
|
|
|
|
|
("otg" . "OpenDocument Drawing Template")
|
|
|
|
|
("odp" . "OpenDocument Presentation")
|
|
|
|
|
("otp" . "OpenDocument Presentation Template")
|
|
|
|
|
("odi" . "OpenDocument Image")
|
|
|
|
|
("odf" . "OpenDocument Formula")
|
|
|
|
|
("odc" . "OpenDocument Chart")))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-table-style-format
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"
|
|
|
|
|
<style:style style:name=\"%s\" style:family=\"table\">
|
2013-11-05 16:26:46 +00:00
|
|
|
|
<style:table-properties style:rel-width=\"%s%%\" fo:margin-top=\"0cm\" fo:margin-bottom=\"0.20cm\" table:align=\"center\"/>
|
2012-07-19 16:45:23 +00:00
|
|
|
|
</style:style>
|
|
|
|
|
"
|
|
|
|
|
"Template for auto-generated Table styles.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-automatic-styles '()
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Registry of automatic styles for various OBJECT-TYPEs.
|
|
|
|
|
The variable has the following form:
|
2015-09-17 23:08:20 +00:00
|
|
|
|
((OBJECT-TYPE-A
|
|
|
|
|
((OBJECT-NAME-A.1 OBJECT-PROPS-A.1)
|
|
|
|
|
(OBJECT-NAME-A.2 OBJECT-PROPS-A.2) ...))
|
|
|
|
|
(OBJECT-TYPE-B
|
|
|
|
|
((OBJECT-NAME-B.1 OBJECT-PROPS-B.1)
|
|
|
|
|
(OBJECT-NAME-B.2 OBJECT-PROPS-B.2) ...))
|
|
|
|
|
...).
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
OBJECT-TYPEs could be \"Section\", \"Table\", \"Figure\" etc.
|
|
|
|
|
OBJECT-PROPS is (typically) a plist created by passing
|
2013-01-27 22:11:34 +00:00
|
|
|
|
\"#+ATTR_ODT: \" option to `org-odt-parse-block-attributes'.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
Use `org-odt-add-automatic-style' to add update this variable.'")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-object-counters nil
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Running counters for various OBJECT-TYPEs.
|
|
|
|
|
Use this to generate automatic names and style-names. See
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-add-automatic-style'.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-src-block-paragraph-format
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"<style:style style:name=\"OrgSrcBlock\" style:family=\"paragraph\" style:parent-style-name=\"Preformatted_20_Text\">
|
|
|
|
|
<style:paragraph-properties fo:background-color=\"%s\" fo:padding=\"0.049cm\" fo:border=\"0.51pt solid #000000\" style:shadow=\"none\">
|
|
|
|
|
<style:background-image/>
|
|
|
|
|
</style:paragraph-properties>
|
|
|
|
|
<style:text-properties fo:color=\"%s\"/>
|
|
|
|
|
</style:style>"
|
|
|
|
|
"Custom paragraph style for colorized source and example blocks.
|
|
|
|
|
This style is much the same as that of \"OrgFixedWidthBlock\"
|
|
|
|
|
except that the foreground and background colors are set
|
|
|
|
|
according to the default face identified by the `htmlfontify'.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2015-04-06 06:40:54 +00:00
|
|
|
|
(defvar hfy-optimizations)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-embedded-formulas-count 0)
|
|
|
|
|
(defvar org-odt-embedded-images-count 0)
|
|
|
|
|
(defvar org-odt-image-size-probe-method
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(append (and (executable-find "identify") '(imagemagick)) ; See Bug#10675
|
|
|
|
|
'(emacs fixed))
|
|
|
|
|
"Ordered list of methods for determining image sizes.")
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-default-image-sizes-alist
|
2012-02-22 14:44:21 +00:00
|
|
|
|
'(("as-char" . (5 . 0.4))
|
|
|
|
|
("paragraph" . (5 . 5)))
|
|
|
|
|
"Hardcoded image dimensions one for each of the anchor
|
|
|
|
|
methods.")
|
|
|
|
|
|
|
|
|
|
;; A4 page size is 21.0 by 29.7 cms
|
|
|
|
|
;; The default page settings has 2cm margin on each of the sides. So
|
|
|
|
|
;; the effective text area is 17.0 by 25.7 cm
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-max-image-size '(17.0 . 20.0)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
"Limiting dimensions for an embedded image.")
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defconst org-odt-label-styles
|
2012-04-06 09:00:39 +00:00
|
|
|
|
'(("math-formula" "%c" "text" "(%n)")
|
|
|
|
|
("math-label" "(%n)" "text" "(%n)")
|
|
|
|
|
("category-and-value" "%e %n: %c" "category-and-value" "%e %n")
|
|
|
|
|
("value" "%e %n: %c" "value" "%n"))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
"Specify how labels are applied and referenced.
|
|
|
|
|
|
2013-06-26 13:22:09 +00:00
|
|
|
|
This is an alist where each element is of the form:
|
|
|
|
|
|
2015-09-17 23:08:20 +00:00
|
|
|
|
(STYLE-NAME ATTACH-FMT REF-MODE REF-FMT)
|
2013-06-26 13:22:09 +00:00
|
|
|
|
|
|
|
|
|
ATTACH-FMT controls how labels and captions are attached to an
|
|
|
|
|
entity. It may contain following specifiers - %e and %c. %e is
|
|
|
|
|
replaced with the CATEGORY-NAME. %n is replaced with
|
2012-02-22 14:44:21 +00:00
|
|
|
|
\"<text:sequence ...> SEQNO </text:sequence>\". %c is replaced
|
2013-06-26 13:22:09 +00:00
|
|
|
|
with CAPTION.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-06-26 13:22:09 +00:00
|
|
|
|
REF-MODE and REF-FMT controls how label references are generated.
|
|
|
|
|
The following XML is generated for a label reference -
|
|
|
|
|
\"<text:sequence-ref text:reference-format=\"REF-MODE\" ...>
|
|
|
|
|
REF-FMT </text:sequence-ref>\". REF-FMT may contain following
|
2012-02-22 14:44:21 +00:00
|
|
|
|
specifiers - %e and %n. %e is replaced with the CATEGORY-NAME.
|
2013-06-26 13:22:09 +00:00
|
|
|
|
%n is replaced with SEQNO.
|
|
|
|
|
|
|
|
|
|
See also `org-odt-format-label'.")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
|
|
|
|
|
(defvar org-odt-category-map-alist
|
2013-06-26 07:44:36 +00:00
|
|
|
|
'(("__Table__" "Table" "value" "Table" org-odt--enumerable-p)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)
|
|
|
|
|
("__MathFormula__" "Text" "math-formula" "Equation" org-odt--enumerable-formula-p)
|
|
|
|
|
("__DvipngImage__" "Equation" "value" "Equation" org-odt--enumerable-latex-image-p)
|
2013-06-26 13:22:09 +00:00
|
|
|
|
("__Listing__" "Listing" "value" "Listing" org-odt--enumerable-p))
|
2012-04-06 09:00:39 +00:00
|
|
|
|
"Map a CATEGORY-HANDLE to OD-VARIABLE and LABEL-STYLE.
|
2013-06-26 13:22:09 +00:00
|
|
|
|
|
|
|
|
|
This is a list where each entry is of the form:
|
|
|
|
|
|
2015-09-17 23:08:20 +00:00
|
|
|
|
(CATEGORY-HANDLE OD-VARIABLE LABEL-STYLE CATEGORY-NAME ENUMERATOR-PREDICATE)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
|
|
|
|
CATEGORY_HANDLE identifies the captionable entity in question.
|
|
|
|
|
|
|
|
|
|
OD-VARIABLE is the OpenDocument sequence counter associated with
|
|
|
|
|
the entity. These counters are declared within
|
2012-04-06 09:00:39 +00:00
|
|
|
|
\"<text:sequence-decls>...</text:sequence-decls>\" block of
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-content-template-file'.
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
LABEL-STYLE is a key into `org-odt-label-styles' and specifies
|
2012-09-13 20:41:03 +00:00
|
|
|
|
how a given entity should be captioned and referenced.
|
|
|
|
|
|
2013-06-26 13:22:09 +00:00
|
|
|
|
CATEGORY-NAME is used for qualifying captions on export.
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
|
|
|
|
ENUMERATOR-PREDICATE is used for assigning a sequence number to
|
2013-01-27 22:11:34 +00:00
|
|
|
|
the entity. See `org-odt--enumerate'.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-manifest-file-entries nil)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(defvar hfy-user-sheet-assoc)
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defvar org-odt-zip-dir nil
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Temporary work directory for OpenDocument exporter.")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; User Configuration Variables
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defgroup org-export-odt nil
|
2012-04-06 09:00:39 +00:00
|
|
|
|
"Options for exporting Org mode files to ODT."
|
|
|
|
|
:tag "Org Export ODT"
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:group 'org-export)
|
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
;;;; Debugging
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-prettify-xml nil
|
2012-07-15 22:08:07 +00:00
|
|
|
|
"Specify whether or not the xml output should be prettified.
|
|
|
|
|
When this option is turned on, `indent-region' is run on all
|
|
|
|
|
component xml buffers before they are saved. Turn this off for
|
|
|
|
|
regular use. Turn this on if you need to examine the xml
|
|
|
|
|
visually."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-07-15 22:08:07 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Document schema
|
|
|
|
|
|
2013-07-01 21:12:54 +00:00
|
|
|
|
(require 'rng-loc)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-schema-dir
|
2016-07-25 15:18:03 +00:00
|
|
|
|
(cl-find-if
|
|
|
|
|
(lambda (dir)
|
|
|
|
|
(and dir
|
|
|
|
|
(file-expand-wildcards
|
|
|
|
|
(expand-file-name "od-manifest-schema*.rnc" dir))
|
|
|
|
|
(file-expand-wildcards (expand-file-name "od-schema*.rnc" dir))
|
|
|
|
|
(file-readable-p (expand-file-name "schemas.xml" dir))))
|
|
|
|
|
org-odt-schema-dir-list)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
"Directory that contains OpenDocument schema files.
|
|
|
|
|
|
|
|
|
|
This directory contains:
|
|
|
|
|
1. rnc files for OpenDocument schema
|
|
|
|
|
2. a \"schemas.xml\" file that specifies locating rules needed
|
|
|
|
|
for auto validation of OpenDocument XML files.
|
|
|
|
|
|
|
|
|
|
Use the customize interface to set this variable. This ensures
|
|
|
|
|
that `rng-schema-locating-files' is updated and auto-validation
|
|
|
|
|
of OpenDocument XML takes place based on the value
|
|
|
|
|
`rng-nxml-auto-validate-flag'.
|
|
|
|
|
|
2012-10-03 10:13:47 +00:00
|
|
|
|
The default value of this variable varies depending on the
|
|
|
|
|
version of org in use and is initialized from
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-schema-dir-list'. The OASIS schema files are available
|
2012-10-03 10:13:47 +00:00
|
|
|
|
only in the org's private git repository. It is *not* bundled
|
|
|
|
|
with GNU ELPA tar or standard Emacs distribution."
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "Not set" nil)
|
|
|
|
|
(directory :tag "Schema directory"))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:set
|
|
|
|
|
(lambda (var value)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
"Set `org-odt-schema-dir'.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
Also add it to `rng-schema-locating-files'."
|
|
|
|
|
(let ((schema-dir value))
|
|
|
|
|
(set var
|
|
|
|
|
(if (and
|
2012-11-10 15:57:52 +00:00
|
|
|
|
(file-expand-wildcards
|
|
|
|
|
(expand-file-name "od-manifest-schema*.rnc" schema-dir))
|
|
|
|
|
(file-expand-wildcards
|
|
|
|
|
(expand-file-name "od-schema*.rnc" schema-dir))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(file-readable-p
|
|
|
|
|
(expand-file-name "schemas.xml" schema-dir)))
|
|
|
|
|
schema-dir
|
2012-10-03 10:13:26 +00:00
|
|
|
|
(when value
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(message "Error (ox-odt): %s has no OpenDocument schema files"
|
2012-10-03 10:13:47 +00:00
|
|
|
|
value))
|
2012-10-03 10:13:26 +00:00
|
|
|
|
nil)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(when org-odt-schema-dir
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(eval-after-load 'rng-loc
|
|
|
|
|
'(add-to-list 'rng-schema-locating-files
|
|
|
|
|
(expand-file-name "schemas.xml"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
org-odt-schema-dir))))))
|
2012-10-03 10:13:47 +00:00
|
|
|
|
|
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
;;;; Document styles
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-content-template-file nil
|
2012-02-22 14:44:21 +00:00
|
|
|
|
"Template file for \"content.xml\".
|
|
|
|
|
The exporter embeds the exported content just before
|
|
|
|
|
\"</office:text>\" element.
|
|
|
|
|
|
|
|
|
|
If unspecified, the file named \"OrgOdtContentTemplate.xml\"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
under `org-odt-styles-dir' is used."
|
2013-05-09 13:19:02 +00:00
|
|
|
|
:type '(choice (const nil)
|
|
|
|
|
(file))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2013-11-14 13:13:46 +00:00
|
|
|
|
:version "24.3")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-styles-file nil
|
2012-02-22 14:44:21 +00:00
|
|
|
|
"Default styles file for use with ODT export.
|
|
|
|
|
Valid values are one of:
|
|
|
|
|
1. nil
|
|
|
|
|
2. path to a styles.xml file
|
|
|
|
|
3. path to a *.odt or a *.ott file
|
|
|
|
|
4. list of the form (ODT-OR-OTT-FILE (FILE-MEMBER-1 FILE-MEMBER-2
|
|
|
|
|
...))
|
|
|
|
|
|
|
|
|
|
In case of option 1, an in-built styles.xml is used. See
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-styles-dir' for more information.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
In case of option 3, the specified file is unzipped and the
|
|
|
|
|
styles.xml embedded therein is used.
|
|
|
|
|
|
|
|
|
|
In case of option 4, the specified ODT-OR-OTT-FILE is unzipped
|
|
|
|
|
and FILE-MEMBER-1, FILE-MEMBER-2 etc are copied in to the
|
|
|
|
|
generated odt file. Use relative path for specifying the
|
|
|
|
|
FILE-MEMBERS. styles.xml must be specified as one of the
|
|
|
|
|
FILE-MEMBERS.
|
|
|
|
|
|
|
|
|
|
Use options 1, 2 or 3 only if styles.xml alone suffices for
|
|
|
|
|
achieving the desired formatting. Use option 4, if the styles.xml
|
|
|
|
|
references additional files like header and footer images for
|
|
|
|
|
achieving the desired formatting.
|
|
|
|
|
|
|
|
|
|
Use \"#+ODT_STYLES_FILE: ...\" directive to set this variable on
|
|
|
|
|
a per-file basis. For example,
|
|
|
|
|
|
|
|
|
|
#+ODT_STYLES_FILE: \"/path/to/styles.xml\" or
|
|
|
|
|
#+ODT_STYLES_FILE: (\"/path/to/file.ott\" (\"styles.xml\" \"image/hdr.png\"))."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type
|
|
|
|
|
'(choice
|
|
|
|
|
(const :tag "Factory settings" nil)
|
|
|
|
|
(file :must-match t :tag "styles.xml")
|
|
|
|
|
(file :must-match t :tag "ODT or OTT file")
|
|
|
|
|
(list :tag "ODT or OTT file + Members"
|
|
|
|
|
(file :must-match t :tag "ODF Text or Text Template file")
|
|
|
|
|
(cons :tag "Members"
|
|
|
|
|
(file :tag " Member" "styles.xml")
|
|
|
|
|
(repeat (file :tag "Member"))))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-display-outline-level 2
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Outline levels considered for enumerating captioned entities."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2013-11-14 08:54:35 +00:00
|
|
|
|
:version "24.4"
|
|
|
|
|
:package-version '(Org . "8.0")
|
2012-07-19 16:45:23 +00:00
|
|
|
|
:type 'integer)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
;;;; Document conversion
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-convert-processes
|
2012-02-22 14:44:21 +00:00
|
|
|
|
'(("LibreOffice"
|
|
|
|
|
"soffice --headless --convert-to %f%x --outdir %d %i")
|
|
|
|
|
("unoconv"
|
|
|
|
|
"unoconv -f %f -o %d %i"))
|
|
|
|
|
"Specify a list of document converters and their usage.
|
|
|
|
|
The converters in this list are offered as choices while
|
2013-01-27 22:11:34 +00:00
|
|
|
|
customizing `org-odt-convert-process'.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
This variable is a list where each element is of the
|
|
|
|
|
form (CONVERTER-NAME CONVERTER-CMD). CONVERTER-NAME is the name
|
|
|
|
|
of the converter. CONVERTER-CMD is the shell command for the
|
|
|
|
|
converter and can contain format specifiers. These format
|
|
|
|
|
specifiers are interpreted as below:
|
|
|
|
|
|
|
|
|
|
%i input file name in full
|
|
|
|
|
%I input file name as a URL
|
|
|
|
|
%f format of the output file
|
|
|
|
|
%o output file name in full
|
|
|
|
|
%O output file name as a URL
|
|
|
|
|
%d output dir in full
|
|
|
|
|
%D output dir as a URL.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
%x extra options as set in `org-odt-convert-capabilities'."
|
|
|
|
|
:group 'org-export-odt
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type
|
|
|
|
|
'(choice
|
|
|
|
|
(const :tag "None" nil)
|
|
|
|
|
(alist :tag "Converters"
|
|
|
|
|
:key-type (string :tag "Converter Name")
|
|
|
|
|
:value-type (group (string :tag "Command line")))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-convert-process "LibreOffice"
|
2012-02-22 14:44:21 +00:00
|
|
|
|
"Use this converter to convert from \"odt\" format to other formats.
|
|
|
|
|
During customization, the list of converter names are populated
|
2013-01-27 22:11:34 +00:00
|
|
|
|
from `org-odt-convert-processes'."
|
|
|
|
|
:group 'org-export-odt
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type '(choice :convert-widget
|
|
|
|
|
(lambda (w)
|
|
|
|
|
(apply 'widget-convert (widget-type w)
|
|
|
|
|
(eval (car (widget-get w :args)))))
|
|
|
|
|
`((const :tag "None" nil)
|
|
|
|
|
,@(mapcar (lambda (c)
|
|
|
|
|
`(const :tag ,(car c) ,(car c)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
org-odt-convert-processes))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-convert-capabilities
|
2012-02-22 14:44:21 +00:00
|
|
|
|
'(("Text"
|
|
|
|
|
("odt" "ott" "doc" "rtf" "docx")
|
|
|
|
|
(("pdf" "pdf") ("odt" "odt") ("rtf" "rtf") ("ott" "ott")
|
|
|
|
|
("doc" "doc" ":\"MS Word 97\"") ("docx" "docx") ("html" "html")))
|
|
|
|
|
("Web"
|
|
|
|
|
("html")
|
|
|
|
|
(("pdf" "pdf") ("odt" "odt") ("html" "html")))
|
|
|
|
|
("Spreadsheet"
|
|
|
|
|
("ods" "ots" "xls" "csv" "xlsx")
|
|
|
|
|
(("pdf" "pdf") ("ots" "ots") ("html" "html") ("csv" "csv") ("ods" "ods")
|
|
|
|
|
("xls" "xls") ("xlsx" "xlsx")))
|
|
|
|
|
("Presentation"
|
|
|
|
|
("odp" "otp" "ppt" "pptx")
|
|
|
|
|
(("pdf" "pdf") ("swf" "swf") ("odp" "odp") ("otp" "otp") ("ppt" "ppt")
|
|
|
|
|
("pptx" "pptx") ("odg" "odg"))))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
"Specify input and output formats of `org-odt-convert-process'.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
More correctly, specify the set of input and output formats that
|
|
|
|
|
the user is actually interested in.
|
|
|
|
|
|
|
|
|
|
This variable is an alist where each element is of the
|
|
|
|
|
form (DOCUMENT-CLASS INPUT-FMT-LIST OUTPUT-FMT-ALIST).
|
|
|
|
|
INPUT-FMT-LIST is a list of INPUT-FMTs. OUTPUT-FMT-ALIST is an
|
|
|
|
|
alist where each element is of the form (OUTPUT-FMT
|
|
|
|
|
OUTPUT-FILE-EXTENSION EXTRA-OPTIONS).
|
|
|
|
|
|
|
|
|
|
The variable is interpreted as follows:
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-convert-process' can take any document that is in
|
2012-02-22 14:44:21 +00:00
|
|
|
|
INPUT-FMT-LIST and produce any document that is in the
|
|
|
|
|
OUTPUT-FMT-LIST. A document converted to OUTPUT-FMT will have
|
|
|
|
|
OUTPUT-FILE-EXTENSION as the file name extension. OUTPUT-FMT
|
|
|
|
|
serves dual purposes:
|
|
|
|
|
- It is used for populating completion candidates during
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-convert' commands.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
- It is used as the value of \"%f\" specifier in
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-convert-process'.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
EXTRA-OPTIONS is used as the value of \"%x\" specifier in
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-convert-process'.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
DOCUMENT-CLASS is used to group a set of file formats in
|
|
|
|
|
INPUT-FMT-LIST in to a single class.
|
|
|
|
|
|
|
|
|
|
Note that this variable inherently captures how LibreOffice based
|
|
|
|
|
converters work. LibreOffice maps documents of various formats
|
|
|
|
|
to classes like Text, Web, Spreadsheet, Presentation etc and
|
2013-11-17 08:12:41 +00:00
|
|
|
|
allow document of a given class (irrespective of its source
|
2012-02-22 14:44:21 +00:00
|
|
|
|
format) to be converted to any of the export formats associated
|
|
|
|
|
with that class.
|
|
|
|
|
|
2018-02-16 22:33:57 +00:00
|
|
|
|
See default setting of this variable for a typical configuration."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type
|
|
|
|
|
'(choice
|
|
|
|
|
(const :tag "None" nil)
|
|
|
|
|
(alist :tag "Capabilities"
|
|
|
|
|
:key-type (string :tag "Document Class")
|
|
|
|
|
:value-type
|
|
|
|
|
(group (repeat :tag "Input formats" (string :tag "Input format"))
|
|
|
|
|
(alist :tag "Output formats"
|
|
|
|
|
:key-type (string :tag "Output format")
|
|
|
|
|
:value-type
|
|
|
|
|
(group (string :tag "Output file extension")
|
|
|
|
|
(choice
|
|
|
|
|
(const :tag "None" nil)
|
|
|
|
|
(string :tag "Extra options"))))))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-preferred-output-format nil
|
2012-07-15 22:08:07 +00:00
|
|
|
|
"Automatically post-process to this format after exporting to \"odt\".
|
2013-01-27 22:11:34 +00:00
|
|
|
|
Command `org-odt-export-to-odt' exports first to \"odt\" format
|
|
|
|
|
and then uses `org-odt-convert-process' to convert the
|
2012-07-15 22:08:07 +00:00
|
|
|
|
resulting document to this format. During customization of this
|
|
|
|
|
variable, the list of valid values are populated based on
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-convert-capabilities'.
|
2012-09-01 21:31:56 +00:00
|
|
|
|
|
|
|
|
|
You can set this option on per-file basis using file local
|
|
|
|
|
values. See Info node `(emacs) File Variables'."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-07-15 22:08:07 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type '(choice :convert-widget
|
|
|
|
|
(lambda (w)
|
|
|
|
|
(apply 'widget-convert (widget-type w)
|
|
|
|
|
(eval (car (widget-get w :args)))))
|
|
|
|
|
`((const :tag "None" nil)
|
|
|
|
|
,@(mapcar (lambda (c)
|
|
|
|
|
`(const :tag ,c ,c))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-reachable-formats "odt")))))
|
2012-09-01 21:31:56 +00:00
|
|
|
|
;;;###autoload
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(put 'org-odt-preferred-output-format 'safe-local-variable 'stringp)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
;;;; Drawers
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defcustom org-odt-format-drawer-function (lambda (_name contents) contents)
|
2012-12-19 20:38:22 +00:00
|
|
|
|
"Function called to format a drawer in ODT code.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
The function must accept two parameters:
|
|
|
|
|
NAME the drawer name, like \"LOGBOOK\"
|
|
|
|
|
CONTENTS the contents of the drawer.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
The function should return the string to be exported.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-11-14 13:05:18 +00:00
|
|
|
|
The default value simply returns the value of CONTENTS."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2017-09-07 20:56:11 +00:00
|
|
|
|
:version "26.1"
|
2013-11-14 13:05:18 +00:00
|
|
|
|
:package-version '(Org . "8.3")
|
2012-07-15 22:08:07 +00:00
|
|
|
|
:type 'function)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Headline
|
|
|
|
|
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(defcustom org-odt-format-headline-function
|
|
|
|
|
'org-odt-format-headline-default-function
|
2012-02-22 14:44:21 +00:00
|
|
|
|
"Function to format headline text.
|
|
|
|
|
|
|
|
|
|
This function will be called with 5 arguments:
|
2015-09-17 23:08:20 +00:00
|
|
|
|
TODO the todo keyword (string or nil).
|
|
|
|
|
TODO-TYPE the type of todo (symbol: `todo', `done', nil)
|
|
|
|
|
PRIORITY the priority of the headline (integer or nil)
|
|
|
|
|
TEXT the main headline text (string).
|
|
|
|
|
TAGS the tags string, separated with colons (string or nil).
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-12-19 20:38:22 +00:00
|
|
|
|
The function result will be used as headline text."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2017-01-26 04:39:18 +00:00
|
|
|
|
:version "26.1"
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
:package-version '(Org . "8.3")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:type 'function)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inlinetasks
|
|
|
|
|
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(defcustom org-odt-format-inlinetask-function
|
|
|
|
|
'org-odt-format-inlinetask-default-function
|
2012-12-19 20:38:22 +00:00
|
|
|
|
"Function called to format an inlinetask in ODT code.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
The function must accept six parameters:
|
|
|
|
|
TODO the todo keyword, as a string
|
|
|
|
|
TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
|
|
|
|
|
PRIORITY the inlinetask priority, as a string
|
|
|
|
|
NAME the inlinetask name, as a string.
|
|
|
|
|
TAGS the inlinetask tags, as a string.
|
|
|
|
|
CONTENTS the contents of the inlinetask, as a string.
|
|
|
|
|
|
2012-12-19 20:38:22 +00:00
|
|
|
|
The function should return the string to be exported."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2017-01-26 04:39:18 +00:00
|
|
|
|
:version "26.1"
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
:package-version '(Org . "8.3")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
:type 'function)
|
|
|
|
|
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;;;; LaTeX
|
|
|
|
|
|
2013-11-15 05:22:36 +00:00
|
|
|
|
(defcustom org-odt-with-latex org-export-with-latex
|
2013-01-27 22:11:34 +00:00
|
|
|
|
"Non-nil means process LaTeX math snippets.
|
|
|
|
|
|
|
|
|
|
When set, the exporter will process LaTeX environments and
|
|
|
|
|
fragments.
|
|
|
|
|
|
|
|
|
|
This option can also be set with the +OPTIONS line,
|
|
|
|
|
e.g. \"tex:mathjax\". Allowed values are:
|
|
|
|
|
|
|
|
|
|
nil Ignore math snippets.
|
|
|
|
|
`verbatim' Keep everything in verbatim
|
|
|
|
|
`dvipng' Process the LaTeX fragments to images. This will also
|
|
|
|
|
include processing of non-math environments.
|
|
|
|
|
`imagemagick' Convert the LaTeX fragments to pdf files and use
|
|
|
|
|
imagemagick to convert pdf files to png files.
|
|
|
|
|
`mathjax' Do MathJax preprocessing and arrange for MathJax.js to
|
|
|
|
|
be loaded.
|
2017-12-13 22:51:10 +00:00
|
|
|
|
|
|
|
|
|
Any other symbol is a synonym for `mathjax'."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
Export framework: Add :version and :package-version informations to defcustoms
* lisp/ox-beamer.el (org-beamer-column-view-format, org-beamer-theme,
org-beamer-environments-extra): Add :version and :package-version.
* lisp/ox-html.el (org-html-with-latex, org-html-inline-image-rules):
Add :version and :package-version.
* lisp/ox-latex.el (org-latex-inline-image-rules,
org-latex-default-table-environment, org-latex-default-table-mode,
org-latex-tables-booktabs, org-latex-table-scientific-notation,
org-latex-known-errors): Add :version and :package-version.
* lisp/ox-md.el (org-md-headline-style): Add :version
and :package-version.
* lisp/ox-odt.el (org-odt-with-latex): Add :version
and :package-version.
* lisp/ox.el (org-export-with-drawers, org-export-with-latex,
org-export-with-inlinetasks, org-export-with-planning,
org-export-with-smart-quotes, org-export-with-statistics-cookies,
org-export-allow-bind-keywords, org-export-async-init-file):
Add :version and :package-version.
2013-03-06 13:45:12 +00:00
|
|
|
|
:version "24.4"
|
|
|
|
|
:package-version '(Org . "8.0")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "Do not process math in any way" nil)
|
2017-12-13 22:51:10 +00:00
|
|
|
|
(const :tag "Leave math verbatim" verbatim)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(const :tag "Use dvipng to make images" dvipng)
|
|
|
|
|
(const :tag "Use imagemagick to make images" imagemagick)
|
2017-12-13 22:51:10 +00:00
|
|
|
|
(other :tag "Use MathJax to display math" mathjax)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
|
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
;;;; Links
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-inline-formula-rules
|
2012-12-15 20:36:04 +00:00
|
|
|
|
'(("file" . "\\.\\(mathml\\|mml\\|odf\\)\\'"))
|
2012-12-19 20:38:22 +00:00
|
|
|
|
"Rules characterizing formula files that can be inlined into ODT.
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
|
|
|
|
A rule consists in an association whose key is the type of link
|
|
|
|
|
to consider, and value is a regexp that will be matched against
|
|
|
|
|
link's path."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2013-11-13 07:46:01 +00:00
|
|
|
|
:version "24.4"
|
2013-11-13 06:35:57 +00:00
|
|
|
|
:package-version '(Org . "8.0")
|
2012-09-13 20:41:03 +00:00
|
|
|
|
:type '(alist :key-type (string :tag "Type")
|
|
|
|
|
:value-type (regexp :tag "Path")))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-inline-image-rules
|
2015-04-27 21:02:22 +00:00
|
|
|
|
'(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
|
2012-12-19 20:38:22 +00:00
|
|
|
|
"Rules characterizing image files that can be inlined into ODT.
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
A rule consists in an association whose key is the type of link
|
|
|
|
|
to consider, and value is a regexp that will be matched against
|
2012-09-13 20:41:03 +00:00
|
|
|
|
link's path."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2017-01-26 04:39:18 +00:00
|
|
|
|
:version "26.1"
|
2015-04-27 22:25:11 +00:00
|
|
|
|
:package-version '(Org . "8.3")
|
2012-07-15 22:08:07 +00:00
|
|
|
|
:type '(alist :key-type (string :tag "Type")
|
|
|
|
|
:value-type (regexp :tag "Path")))
|
|
|
|
|
|
2013-07-10 10:12:59 +00:00
|
|
|
|
(defcustom org-odt-pixels-per-inch 96.0
|
2012-07-15 22:08:07 +00:00
|
|
|
|
"Scaling factor for converting images pixels to inches.
|
|
|
|
|
Use this for sizing of embedded images. See Info node `(org)
|
|
|
|
|
Images in ODT export' for more information."
|
|
|
|
|
:type 'float
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2013-07-10 10:12:59 +00:00
|
|
|
|
:version "24.4"
|
|
|
|
|
:package-version '(Org . "8.1"))
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
;;;; Src Block
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-create-custom-styles-for-srcblocks t
|
2012-07-15 22:08:07 +00:00
|
|
|
|
"Whether custom styles for colorized source blocks be automatically created.
|
|
|
|
|
When this option is turned on, the exporter creates custom styles
|
|
|
|
|
for source blocks based on the advice of `htmlfontify'. Creation
|
2013-01-27 22:11:34 +00:00
|
|
|
|
of custom styles happen as part of `org-odt-hfy-face-to-css'.
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
When this option is turned off exporter does not create such
|
|
|
|
|
styles.
|
|
|
|
|
|
|
|
|
|
Use the latter option if you do not want the custom styles to be
|
|
|
|
|
based on your current display settings. It is necessary that the
|
|
|
|
|
styles.xml already contains needed styles for colorizing to work.
|
|
|
|
|
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
This variable is effective only if `org-odt-fontify-srcblocks' is
|
|
|
|
|
turned on."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-07-15 22:08:07 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-fontify-srcblocks t
|
2012-07-15 22:08:07 +00:00
|
|
|
|
"Specify whether or not source blocks need to be fontified.
|
|
|
|
|
Turn this option on if you want to colorize the source code
|
|
|
|
|
blocks in the exported file. For colorization to work, you need
|
|
|
|
|
to make available an enhanced version of `htmlfontify' library."
|
|
|
|
|
:type 'boolean
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-07-15 22:08:07 +00:00
|
|
|
|
:version "24.1")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Table
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-table-styles
|
2012-07-15 22:08:07 +00:00
|
|
|
|
'(("OrgEquation" "OrgEquation"
|
|
|
|
|
((use-first-column-styles . t)
|
2012-09-04 21:40:43 +00:00
|
|
|
|
(use-last-column-styles . t)))
|
|
|
|
|
("TableWithHeaderRowAndColumn" "Custom"
|
|
|
|
|
((use-first-row-styles . t)
|
|
|
|
|
(use-first-column-styles . t)))
|
|
|
|
|
("TableWithFirstRowandLastRow" "Custom"
|
|
|
|
|
((use-first-row-styles . t)
|
|
|
|
|
(use-last-row-styles . t)))
|
|
|
|
|
("GriddedTable" "Custom" nil))
|
2012-07-15 22:08:07 +00:00
|
|
|
|
"Specify how Table Styles should be derived from a Table Template.
|
|
|
|
|
This is a list where each element is of the
|
|
|
|
|
form (TABLE-STYLE-NAME TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS).
|
|
|
|
|
|
|
|
|
|
TABLE-STYLE-NAME is the style associated with the table through
|
|
|
|
|
\"#+ATTR_ODT: :style TABLE-STYLE-NAME\" line.
|
|
|
|
|
|
2019-11-12 13:44:05 +00:00
|
|
|
|
TABLE-TEMPLATE-NAME is a set of - up to 9 - automatic
|
2012-07-15 22:08:07 +00:00
|
|
|
|
TABLE-CELL-STYLE-NAMEs and PARAGRAPH-STYLE-NAMEs (as defined
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
below) that is included in `org-odt-content-template-file'.
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
TABLE-CELL-STYLE-NAME := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
|
|
|
|
|
\"TableCell\"
|
|
|
|
|
PARAGRAPH-STYLE-NAME := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
|
|
|
|
|
\"TableParagraph\"
|
|
|
|
|
TABLE-CELL-TYPE := \"FirstRow\" | \"LastColumn\" |
|
|
|
|
|
\"FirstRow\" | \"LastRow\" |
|
|
|
|
|
\"EvenRow\" | \"OddRow\" |
|
|
|
|
|
\"EvenColumn\" | \"OddColumn\" | \"\"
|
|
|
|
|
where \"+\" above denotes string concatenation.
|
|
|
|
|
|
|
|
|
|
TABLE-CELL-OPTIONS is an alist where each element is of the
|
|
|
|
|
form (TABLE-CELL-STYLE-SELECTOR . ON-OR-OFF).
|
|
|
|
|
TABLE-CELL-STYLE-SELECTOR := `use-first-row-styles' |
|
|
|
|
|
`use-last-row-styles' |
|
|
|
|
|
`use-first-column-styles' |
|
|
|
|
|
`use-last-column-styles' |
|
|
|
|
|
`use-banding-rows-styles' |
|
|
|
|
|
`use-banding-columns-styles' |
|
|
|
|
|
`use-first-row-styles'
|
2015-05-21 17:04:45 +00:00
|
|
|
|
ON-OR-OFF := t | nil
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
For example, with the following configuration
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
\(setq org-odt-table-styles
|
2016-12-07 19:29:54 +00:00
|
|
|
|
\\='((\"TableWithHeaderRowsAndColumns\" \"Custom\"
|
2015-09-17 23:08:20 +00:00
|
|
|
|
((use-first-row-styles . t)
|
|
|
|
|
(use-first-column-styles . t)))
|
|
|
|
|
(\"TableWithHeaderColumns\" \"Custom\"
|
|
|
|
|
((use-first-column-styles . t)))))
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
1. A table associated with \"TableWithHeaderRowsAndColumns\"
|
|
|
|
|
style will use the following table-cell styles -
|
|
|
|
|
\"CustomFirstRowTableCell\", \"CustomFirstColumnTableCell\",
|
|
|
|
|
\"CustomTableCell\" and the following paragraph styles
|
|
|
|
|
\"CustomFirstRowTableParagraph\",
|
|
|
|
|
\"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
|
|
|
|
|
as appropriate.
|
|
|
|
|
|
|
|
|
|
2. A table associated with \"TableWithHeaderColumns\" style will
|
|
|
|
|
use the following table-cell styles -
|
|
|
|
|
\"CustomFirstColumnTableCell\", \"CustomTableCell\" and the
|
|
|
|
|
following paragraph styles
|
|
|
|
|
\"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
|
|
|
|
|
as appropriate..
|
|
|
|
|
|
|
|
|
|
Note that TABLE-TEMPLATE-NAME corresponds to the
|
|
|
|
|
\"<table:table-template>\" elements contained within
|
|
|
|
|
\"<office:styles>\". The entries (TABLE-STYLE-NAME
|
|
|
|
|
TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS) correspond to
|
|
|
|
|
\"table:template-name\" and \"table:use-first-row-styles\" etc
|
|
|
|
|
attributes of \"<table:table>\" element. Refer ODF-1.2
|
|
|
|
|
specification for more information. Also consult the
|
2013-01-27 22:11:34 +00:00
|
|
|
|
implementation filed under `org-odt-get-table-cell-styles'.
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
The TABLE-STYLE-NAME \"OrgEquation\" is used internally for
|
|
|
|
|
formatting of numbered display equations. Do not delete this
|
|
|
|
|
style from the list."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:group 'org-export-odt
|
2012-07-15 22:08:07 +00:00
|
|
|
|
:version "24.1"
|
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "None" nil)
|
|
|
|
|
(repeat :tag "Table Styles"
|
|
|
|
|
(list :tag "Table Style Specification"
|
|
|
|
|
(string :tag "Table Style Name")
|
|
|
|
|
(string :tag "Table Template Name")
|
|
|
|
|
(alist :options (use-first-row-styles
|
|
|
|
|
use-last-row-styles
|
|
|
|
|
use-first-column-styles
|
|
|
|
|
use-last-column-styles
|
|
|
|
|
use-banding-rows-styles
|
|
|
|
|
use-banding-columns-styles)
|
|
|
|
|
:key-type symbol
|
|
|
|
|
:value-type (const :tag "True" t))))))
|
|
|
|
|
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;;;; Timestamps
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defcustom org-odt-use-date-fields nil
|
2012-12-07 09:07:12 +00:00
|
|
|
|
"Non-nil, if timestamps should be exported as date fields.
|
|
|
|
|
|
|
|
|
|
When nil, export timestamps as plain text.
|
|
|
|
|
|
|
|
|
|
When non-nil, map `org-time-stamp-custom-formats' to a pair of
|
|
|
|
|
OpenDocument date-styles with names \"OrgDate1\" and \"OrgDate2\"
|
|
|
|
|
respectively. A timestamp with no time component is formatted
|
|
|
|
|
with style \"OrgDate1\" while one with explicit hour and minutes
|
|
|
|
|
is formatted with style \"OrgDate2\".
|
|
|
|
|
|
|
|
|
|
This feature is experimental. Most (but not all) of the common
|
|
|
|
|
%-specifiers in `format-time-string' are supported.
|
|
|
|
|
Specifically, locale-dependent specifiers like \"%c\", \"%x\" are
|
|
|
|
|
formatted as canonical Org timestamps. For finer control, avoid
|
|
|
|
|
these %-specifiers.
|
|
|
|
|
|
2013-11-17 08:12:41 +00:00
|
|
|
|
Textual specifiers like \"%b\", \"%h\", \"%B\", \"%a\", \"%A\"
|
2012-12-07 09:07:12 +00:00
|
|
|
|
etc., are displayed by the application in the default language
|
2013-01-27 22:11:34 +00:00
|
|
|
|
and country specified in `org-odt-styles-file'. Note that the
|
2012-12-07 09:07:12 +00:00
|
|
|
|
default styles file uses language \"en\" and country \"GB\". You
|
|
|
|
|
can localize the week day and month strings in the exported
|
|
|
|
|
document by setting the default language and country either using
|
|
|
|
|
the application UI or through a custom styles file.
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
See `org-odt--build-date-styles' for implementation details."
|
|
|
|
|
:group 'org-export-odt
|
2013-11-13 07:46:01 +00:00
|
|
|
|
:version "24.4"
|
2013-11-13 06:35:57 +00:00
|
|
|
|
:package-version '(Org . "8.0")
|
2012-12-07 09:07:12 +00:00
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;;; Internal functions
|
|
|
|
|
|
|
|
|
|
;;;; Date
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--format-timestamp (timestamp &optional end iso-date-p)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(let* ((format-timestamp
|
|
|
|
|
(lambda (timestamp format &optional end utc)
|
|
|
|
|
(if timestamp
|
2013-01-10 20:42:21 +00:00
|
|
|
|
(org-timestamp-format timestamp format end utc)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(format-time-string format nil utc))))
|
|
|
|
|
(has-time-p (or (not timestamp)
|
2013-01-10 20:42:21 +00:00
|
|
|
|
(org-timestamp-has-time-p timestamp)))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(iso-date (let ((format (if has-time-p "%Y-%m-%dT%H:%M:%S"
|
2020-01-31 16:21:43 +00:00
|
|
|
|
"%Y-%m-%d")))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(funcall format-timestamp timestamp format end))))
|
|
|
|
|
(if iso-date-p iso-date
|
|
|
|
|
(let* ((style (if has-time-p "OrgDate2" "OrgDate1"))
|
|
|
|
|
;; LibreOffice does not care about end goes as content
|
|
|
|
|
;; within the "<text:date>...</text:date>" field. The
|
|
|
|
|
;; displayed date is automagically corrected to match the
|
|
|
|
|
;; format requested by "style:data-style-name" attribute. So
|
|
|
|
|
;; don't bother about formatting the date contents to be
|
|
|
|
|
;; compatible with "OrgDate1" and "OrgDateTime" styles. A
|
|
|
|
|
;; simple Org-style date should suffice.
|
|
|
|
|
(date (let* ((formats
|
|
|
|
|
(if org-display-custom-times
|
|
|
|
|
(cons (substring
|
|
|
|
|
(car org-time-stamp-custom-formats) 1 -1)
|
|
|
|
|
(substring
|
|
|
|
|
(cdr org-time-stamp-custom-formats) 1 -1))
|
|
|
|
|
'("%Y-%m-%d %a" . "%Y-%m-%d %a %H:%M")))
|
|
|
|
|
(format (if has-time-p (cdr formats) (car formats))))
|
|
|
|
|
(funcall format-timestamp timestamp format end)))
|
|
|
|
|
(repeater (let ((repeater-type (org-element-property
|
|
|
|
|
:repeater-type timestamp))
|
|
|
|
|
(repeater-value (org-element-property
|
|
|
|
|
:repeater-value timestamp))
|
|
|
|
|
(repeater-unit (org-element-property
|
|
|
|
|
:repeater-unit timestamp)))
|
|
|
|
|
(concat
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case repeater-type
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(catchup "++") (restart ".+") (cumulate "+"))
|
|
|
|
|
(when repeater-value
|
|
|
|
|
(number-to-string repeater-value))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case repeater-unit
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(hour "h") (day "d") (week "w") (month "m")
|
|
|
|
|
(year "y"))))))
|
|
|
|
|
(concat
|
|
|
|
|
(format "<text:date text:date-value=\"%s\" style:data-style-name=\"%s\" text:fixed=\"true\">%s</text:date>"
|
|
|
|
|
iso-date style date)
|
|
|
|
|
(and (not (string= repeater "")) " ")
|
|
|
|
|
repeater)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;;;; Frame
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--frame (text width height style &optional extra
|
2012-12-15 20:36:04 +00:00
|
|
|
|
anchor-type &rest title-and-desc)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((frame-attrs
|
|
|
|
|
(concat
|
|
|
|
|
(if width (format " svg:width=\"%0.2fcm\"" width) "")
|
|
|
|
|
(if height (format " svg:height=\"%0.2fcm\"" height) "")
|
|
|
|
|
extra
|
2014-01-04 17:09:31 +00:00
|
|
|
|
(format " text:anchor-type=\"%s\"" (or anchor-type "paragraph"))
|
|
|
|
|
(format " draw:name=\"%s\""
|
|
|
|
|
(car (org-odt-add-automatic-style "Frame"))))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format
|
|
|
|
|
"\n<draw:frame draw:style-name=\"%s\"%s>\n%s\n</draw:frame>"
|
|
|
|
|
style frame-attrs
|
|
|
|
|
(concat text
|
2012-12-15 20:36:04 +00:00
|
|
|
|
(let ((title (car title-and-desc))
|
|
|
|
|
(desc (cadr title-and-desc)))
|
|
|
|
|
(concat (when title
|
|
|
|
|
(format "<svg:title>%s</svg:title>"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--encode-plain-text title t)))
|
2012-12-15 20:36:04 +00:00
|
|
|
|
(when desc
|
|
|
|
|
(format "<svg:desc>%s</svg:desc>"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--encode-plain-text desc t)))))))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;;;; Library wrappers
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--zip-extract (archive members target)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(when (atom members) (setq members (list members)))
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(require 'arc-mode)
|
|
|
|
|
(dolist (member members)
|
|
|
|
|
(let* ((--quote-file-name
|
|
|
|
|
;; This is shamelessly stolen from `archive-zip-extract'.
|
|
|
|
|
(lambda (name)
|
|
|
|
|
(if (or (not (memq system-type '(windows-nt ms-dos)))
|
|
|
|
|
(and (boundp 'w32-quote-process-args)
|
|
|
|
|
(null w32-quote-process-args)))
|
|
|
|
|
(shell-quote-argument name)
|
|
|
|
|
name)))
|
|
|
|
|
(target (funcall --quote-file-name target))
|
|
|
|
|
(archive (expand-file-name archive))
|
|
|
|
|
(archive-zip-extract
|
|
|
|
|
(list "unzip" "-qq" "-o" "-d" target))
|
|
|
|
|
exit-code command-output)
|
|
|
|
|
(setq command-output
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq exit-code (archive-zip-extract archive member))
|
|
|
|
|
(buffer-string)))
|
|
|
|
|
(unless (zerop exit-code)
|
|
|
|
|
(message command-output)
|
|
|
|
|
(error "Extraction failed")))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;;;; Target
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--target (text id)
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(if (not id) text
|
|
|
|
|
(concat
|
|
|
|
|
(format "\n<text:bookmark-start text:name=\"OrgXref.%s\"/>" id)
|
|
|
|
|
(format "\n<text:bookmark text:name=\"%s\"/>" id) text
|
|
|
|
|
(format "\n<text:bookmark-end text:name=\"OrgXref.%s\"/>" id))))
|
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;;;; Textbox
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--textbox (text width height style &optional
|
2012-07-19 16:45:23 +00:00
|
|
|
|
extra anchor-type)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--frame
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "\n<draw:text-box %s>%s\n</draw:text-box>"
|
|
|
|
|
(concat (format " fo:min-height=\"%0.2fcm\"" (or height .2))
|
|
|
|
|
(and (not width)
|
|
|
|
|
(format " fo:min-width=\"%0.2fcm\"" (or width .2))))
|
|
|
|
|
text)
|
|
|
|
|
width nil style extra anchor-type))
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;;;; Table of Contents
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2014-10-25 15:14:34 +00:00
|
|
|
|
(defun org-odt--format-toc (title entries depth)
|
|
|
|
|
"Return a table of contents.
|
|
|
|
|
TITLE is the title of the table, as a string, or nil. ENTRIES is
|
|
|
|
|
the contents of the table, as a string. DEPTH is an integer
|
|
|
|
|
specifying the depth of the table."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(concat
|
2014-10-25 15:14:34 +00:00
|
|
|
|
"
|
|
|
|
|
<text:table-of-content text:style-name=\"OrgIndexSection\" text:protected=\"true\" text:name=\"Table of Contents\">\n"
|
|
|
|
|
(format " <text:table-of-content-source text:outline-level=\"%d\">" depth)
|
|
|
|
|
(and title
|
|
|
|
|
(format "
|
|
|
|
|
<text:index-title-template text:style-name=\"Contents_20_Heading\">%s</text:index-title-template>
|
|
|
|
|
"
|
|
|
|
|
title))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((levels (number-sequence 1 10)))
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (level)
|
|
|
|
|
(format
|
|
|
|
|
"
|
|
|
|
|
<text:table-of-content-entry-template text:outline-level=\"%d\" text:style-name=\"Contents_20_%d\">
|
|
|
|
|
<text:index-entry-link-start text:style-name=\"Internet_20_link\"/>
|
|
|
|
|
<text:index-entry-chapter/>
|
|
|
|
|
<text:index-entry-text/>
|
|
|
|
|
<text:index-entry-link-end/>
|
2014-10-25 15:14:34 +00:00
|
|
|
|
</text:table-of-content-entry-template>\n"
|
|
|
|
|
level level)) levels ""))
|
|
|
|
|
"
|
|
|
|
|
</text:table-of-content-source>
|
|
|
|
|
<text:index-body>"
|
|
|
|
|
(and title
|
|
|
|
|
(format "
|
|
|
|
|
<text:index-title text:style-name=\"Sect1\" text:name=\"Table of Contents1_Head\">
|
|
|
|
|
<text:p text:style-name=\"Contents_20_Heading\">%s</text:p>
|
|
|
|
|
</text:index-title>\n"
|
|
|
|
|
title))
|
|
|
|
|
entries
|
|
|
|
|
"
|
|
|
|
|
</text:index-body>
|
|
|
|
|
</text:table-of-content>"))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(cl-defun org-odt-format-toc-headline
|
|
|
|
|
(todo _todo-type priority text tags
|
|
|
|
|
&key _level section-number headline-label &allow-other-keys)
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
|
2015-10-31 23:58:57 +00:00
|
|
|
|
headline-label
|
|
|
|
|
(concat
|
|
|
|
|
;; Section number.
|
|
|
|
|
(and section-number (concat section-number ". "))
|
|
|
|
|
;; Todo.
|
|
|
|
|
(when todo
|
|
|
|
|
(let ((style (if (member todo org-done-keywords)
|
|
|
|
|
"OrgDone" "OrgTodo")))
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span> "
|
|
|
|
|
style todo)))
|
|
|
|
|
(when priority
|
|
|
|
|
(let* ((style (format "OrgPriority-%s" priority))
|
|
|
|
|
(priority (format "[#%c]" priority)))
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span> "
|
|
|
|
|
style priority)))
|
|
|
|
|
;; Title.
|
|
|
|
|
text
|
|
|
|
|
;; Tags.
|
|
|
|
|
(when tags
|
|
|
|
|
(concat
|
|
|
|
|
(format " <text:span text:style-name=\"%s\">[%s]</text:span>"
|
|
|
|
|
"OrgTags"
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (tag)
|
|
|
|
|
(format
|
|
|
|
|
"<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgTag" tag)) tags " : ")))))))
|
2012-04-04 16:59:04 +00:00
|
|
|
|
|
2014-10-25 15:14:34 +00:00
|
|
|
|
(defun org-odt-toc (depth info &optional scope)
|
|
|
|
|
"Build a table of contents.
|
|
|
|
|
DEPTH is an integer specifying the depth of the table. INFO is
|
|
|
|
|
a plist containing current export properties. Optional argument
|
|
|
|
|
SCOPE, when non-nil, defines the scope of the table. Return the
|
|
|
|
|
table of contents as a string, or nil."
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (wholenump depth))
|
2012-12-17 07:31:10 +00:00
|
|
|
|
;; When a headline is marked as a radio target, as in the example below:
|
|
|
|
|
;;
|
|
|
|
|
;; ** <<<Some Heading>>>
|
|
|
|
|
;; Some text.
|
|
|
|
|
;;
|
|
|
|
|
;; suppress generation of radio targets. i.e., Radio targets are to
|
|
|
|
|
;; be marked as targets within /document body/ and *not* within
|
|
|
|
|
;; /TOC/, as otherwise there will be duplicated anchors one in TOC
|
|
|
|
|
;; and one in the document body.
|
|
|
|
|
;;
|
2015-09-18 21:58:51 +00:00
|
|
|
|
;; Likewise, links, footnote references and regular targets are also
|
|
|
|
|
;; suppressed.
|
2014-10-25 15:14:34 +00:00
|
|
|
|
(let* ((headlines (org-export-collect-headlines info depth scope))
|
2017-10-14 10:29:52 +00:00
|
|
|
|
(backend (org-export-toc-entry-backend
|
|
|
|
|
(org-export-backend-name (plist-get info :back-end)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(when headlines
|
2014-10-25 15:14:34 +00:00
|
|
|
|
(org-odt--format-toc
|
|
|
|
|
(and (not scope) (org-export-translate "Table of Contents" :utf-8 info))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (headline)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((entry (org-odt-format-headline--wrap
|
2013-06-24 18:55:24 +00:00
|
|
|
|
headline backend info 'org-odt-format-toc-headline))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(level (org-export-get-relative-level headline info))
|
|
|
|
|
(style (format "Contents_20_%d" level)))
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
style entry)))
|
|
|
|
|
headlines "\n")
|
2014-10-25 15:14:34 +00:00
|
|
|
|
depth))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Document styles
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-add-automatic-style (object-type &optional object-props)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Create an automatic style of type OBJECT-TYPE with param OBJECT-PROPS.
|
|
|
|
|
OBJECT-PROPS is (typically) a plist created by passing
|
|
|
|
|
\"#+ATTR_ODT: \" option of the object in question to
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-parse-block-attributes'.
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
Use `org-odt-object-counters' to generate an automatic
|
2012-07-19 16:45:23 +00:00
|
|
|
|
OBJECT-NAME and STYLE-NAME. If OBJECT-PROPS is non-nil, add a
|
2013-01-27 22:11:34 +00:00
|
|
|
|
new entry in `org-odt-automatic-styles'. Return (OBJECT-NAME
|
2012-07-19 16:45:23 +00:00
|
|
|
|
. STYLE-NAME)."
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (stringp object-type))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let* ((object (intern object-type))
|
|
|
|
|
(seqvar object)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(seqno (1+ (or (plist-get org-odt-object-counters seqvar) 0)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(object-name (format "%s%d" object-type seqno)) style-name)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(setq org-odt-object-counters
|
|
|
|
|
(plist-put org-odt-object-counters seqvar seqno))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(when object-props
|
|
|
|
|
(setq style-name (format "Org%s" object-name))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(setq org-odt-automatic-styles
|
|
|
|
|
(plist-put org-odt-automatic-styles object
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(append (list (list style-name object-props))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(plist-get org-odt-automatic-styles object)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(cons object-name style-name)))
|
|
|
|
|
|
|
|
|
|
;;;; Checkbox
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--checkbox (item)
|
2012-06-09 13:34:27 +00:00
|
|
|
|
"Return check-box string associated to ITEM."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((checkbox (org-element-property :checkbox item)))
|
|
|
|
|
(if (not checkbox) ""
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
2016-07-25 13:51:23 +00:00
|
|
|
|
"OrgCode" (cl-case checkbox
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(on "[✓] ") ; CHECK MARK
|
|
|
|
|
(off "[ ] ")
|
|
|
|
|
(trans "[-] "))))))
|
2012-03-14 18:28:43 +00:00
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;; Template
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--build-date-styles (fmt style)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; In LibreOffice 3.4.6, there doesn't seem to be a convenient way
|
|
|
|
|
;; to modify the date fields. A date could be modified by
|
|
|
|
|
;; offsetting in days. That's about it. Also, date and time may
|
|
|
|
|
;; have to be emitted as two fields - a date field and a time field
|
|
|
|
|
;; - separately.
|
|
|
|
|
|
|
|
|
|
;; One can add Form Controls to date and time fields so that they
|
|
|
|
|
;; can be easily modified. But then, the exported document will
|
|
|
|
|
;; become tightly coupled with LibreOffice and may not function
|
|
|
|
|
;; properly with other OpenDocument applications.
|
|
|
|
|
|
|
|
|
|
;; I have a strange feeling that Date styles are a bit flaky at the
|
|
|
|
|
;; moment.
|
|
|
|
|
|
|
|
|
|
;; The feature is experimental.
|
|
|
|
|
(when (and fmt style)
|
|
|
|
|
(let* ((fmt-alist
|
|
|
|
|
'(("%A" . "<number:day-of-week number:style=\"long\"/>")
|
|
|
|
|
("%B" . "<number:month number:textual=\"true\" number:style=\"long\"/>")
|
|
|
|
|
("%H" . "<number:hours number:style=\"long\"/>")
|
|
|
|
|
("%M" . "<number:minutes number:style=\"long\"/>")
|
|
|
|
|
("%S" . "<number:seconds number:style=\"long\"/>")
|
|
|
|
|
("%V" . "<number:week-of-year/>")
|
|
|
|
|
("%Y" . "<number:year number:style=\"long\"/>")
|
|
|
|
|
("%a" . "<number:day-of-week number:style=\"short\"/>")
|
|
|
|
|
("%b" . "<number:month number:textual=\"true\" number:style=\"short\"/>")
|
|
|
|
|
("%d" . "<number:day number:style=\"long\"/>")
|
|
|
|
|
("%e" . "<number:day number:style=\"short\"/>")
|
|
|
|
|
("%h" . "<number:month number:textual=\"true\" number:style=\"short\"/>")
|
|
|
|
|
("%k" . "<number:hours number:style=\"short\"/>")
|
|
|
|
|
("%m" . "<number:month number:style=\"long\"/>")
|
|
|
|
|
("%p" . "<number:am-pm/>")
|
|
|
|
|
("%y" . "<number:year number:style=\"short\"/>")))
|
|
|
|
|
(case-fold-search nil)
|
|
|
|
|
(re (mapconcat 'identity (mapcar 'car fmt-alist) "\\|"))
|
|
|
|
|
match rpl (start 0) (filler-beg 0) filler-end filler output)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (pair
|
|
|
|
|
'(("\\(?:%[[:digit:]]*N\\)" . "") ; strip ns, us and ns
|
|
|
|
|
("%C" . "Y") ; replace century with year
|
|
|
|
|
("%D" . "%m/%d/%y")
|
|
|
|
|
("%G" . "Y") ; year corresponding to iso week
|
|
|
|
|
("%I" . "%H") ; hour on a 12-hour clock
|
|
|
|
|
("%R" . "%H:%M")
|
|
|
|
|
("%T" . "%H:%M:%S")
|
|
|
|
|
("%U\\|%W" . "%V") ; week no. starting on Sun./Mon.
|
|
|
|
|
("%Z" . "") ; time zone name
|
|
|
|
|
("%c" . "%Y-%M-%d %a %H:%M" ) ; locale's date and time format
|
|
|
|
|
("%g" . "%y")
|
|
|
|
|
("%X" . "%x" ) ; locale's pref. time format
|
|
|
|
|
("%j" . "") ; day of the year
|
|
|
|
|
("%l" . "%k") ; like %I blank-padded
|
|
|
|
|
("%s" . "") ; no. of secs since 1970-01-01 00:00:00 +0000
|
|
|
|
|
("%n" . "<text:line-break/>")
|
|
|
|
|
("%r" . "%I:%M:%S %p")
|
|
|
|
|
("%t" . "<text:tab/>")
|
|
|
|
|
("%u\\|%w" . "") ; numeric day of week - Mon (1-7), Sun(0-6)
|
|
|
|
|
("%x" . "%Y-%M-%d %a") ; locale's pref. time format
|
|
|
|
|
("%z" . "") ; time zone in numeric form
|
|
|
|
|
))
|
|
|
|
|
(setq fmt (replace-regexp-in-string (car pair) (cdr pair) fmt t t)))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(while (string-match re fmt start)
|
|
|
|
|
(setq match (match-string 0 fmt))
|
|
|
|
|
(setq rpl (assoc-default match fmt-alist))
|
|
|
|
|
(setq start (match-end 0))
|
|
|
|
|
(setq filler-end (match-beginning 0))
|
|
|
|
|
(setq filler (substring fmt (prog1 filler-beg
|
|
|
|
|
(setq filler-beg (match-end 0)))
|
|
|
|
|
filler-end))
|
|
|
|
|
(setq filler (and (not (string= filler ""))
|
|
|
|
|
(format "<number:text>%s</number:text>"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--encode-plain-text filler))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(setq output (concat output "\n" filler "\n" rpl)))
|
|
|
|
|
(setq filler (substring fmt filler-beg))
|
|
|
|
|
(unless (string= filler "")
|
|
|
|
|
(setq output (concat output
|
|
|
|
|
(format "\n<number:text>%s</number:text>"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--encode-plain-text filler)))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(format "\n<number:date-style style:name=\"%s\" %s>%s\n</number:date-style>"
|
|
|
|
|
style
|
|
|
|
|
(concat " number:automatic-order=\"true\""
|
|
|
|
|
" number:format-source=\"fixed\"")
|
|
|
|
|
output ))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-template (contents info)
|
2012-12-19 20:38:22 +00:00
|
|
|
|
"Return complete document string after ODT conversion.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is the transcoded contents string. RAW-DATA is the
|
|
|
|
|
original parsed data. INFO is a plist holding export options."
|
2012-07-15 22:08:07 +00:00
|
|
|
|
;; Write meta file.
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((title (org-export-data (plist-get info :title) info))
|
ox: Add #+SUBTITLE property in some backends
* ox-texinfo.el (texinfo, org-texinfo-template): Parse subtitle.
* ox-s5.el (org-s5-title-slide-template):
* ox-deck.el (org-deck-title-slide-template):
* ox-odt.el (odt, org-odt-template):
* ox-latex.el (latex, org-latex-template):
* ox-html.el (html, org-html-format-spec, org-html-template):
* ox-ascii.el (ascii, org-ascii-template--document-title):
* ox-beamer.el (beamer, org-beamer-template): Support #+SUBTITLE.
* ox-html.el (org-html-postamble-format)
(org-html-preamble-format):
* ox-latex.el (org-latex-title-command)
(org-latex-hyperref-template): Update docstring.
* ox-html.el (org-html-style-default): New .subtitle css property.
* ox-beamer.el (org-beamer-subtitle-format):
* ox-latex.el (org-latex-subtitle-format)
(org-latex-subtitle-separate): New variable.
* org.texi (ASCII/Latin-1/UTF-8 export)
(Beamer specific export settings)
(HTML Specific export settings)
(@LaTeX{} specific export settings, CSS support)
(ODT specific export settings)
(Texinfo specific export settings, Document preamble)
(Publishing options, Publishing options): Document #+SUBTITLE.
The patch adds a #+SUBTITLE keyword to ox-ascii, ox-latex, ox-html and
ox-odt.
2015-03-01 21:09:19 +00:00
|
|
|
|
(subtitle (org-export-data (plist-get info :subtitle) info))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(author (let ((author (plist-get info :author)))
|
|
|
|
|
(if (not author) "" (org-export-data author info))))
|
2015-03-17 00:09:50 +00:00
|
|
|
|
(keywords (or (plist-get info :keywords) ""))
|
|
|
|
|
(description (or (plist-get info :description) "")))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(write-region
|
|
|
|
|
(concat
|
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|
|
|
|
<office:document-meta
|
|
|
|
|
xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"
|
|
|
|
|
xmlns:xlink=\"http://www.w3.org/1999/xlink\"
|
|
|
|
|
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
|
|
|
|
|
xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"
|
|
|
|
|
xmlns:ooo=\"http://openoffice.org/2004/office\"
|
|
|
|
|
office:version=\"1.2\">
|
|
|
|
|
<office:meta>\n"
|
|
|
|
|
(format "<dc:creator>%s</dc:creator>\n" author)
|
|
|
|
|
(format "<meta:initial-creator>%s</meta:initial-creator>\n" author)
|
2012-11-10 18:56:20 +00:00
|
|
|
|
;; Date, if required.
|
|
|
|
|
(when (plist-get info :with-date)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; Check if DATE is specified as an Org-timestamp. If yes,
|
|
|
|
|
;; include it as meta information. Otherwise, just use
|
|
|
|
|
;; today's date.
|
|
|
|
|
(let* ((date (let ((date (plist-get info :date)))
|
|
|
|
|
(and (not (cdr date))
|
|
|
|
|
(eq (org-element-type (car date)) 'timestamp)
|
|
|
|
|
(car date)))))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let ((iso-date (org-odt--format-timestamp date nil 'iso-date)))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(concat
|
|
|
|
|
(format "<dc:date>%s</dc:date>\n" iso-date)
|
|
|
|
|
(format "<meta:creation-date>%s</meta:creation-date>\n"
|
|
|
|
|
iso-date)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<meta:generator>%s</meta:generator>\n"
|
2015-03-27 11:51:01 +00:00
|
|
|
|
(plist-get info :creator))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<meta:keyword>%s</meta:keyword>\n" keywords)
|
|
|
|
|
(format "<dc:subject>%s</dc:subject>\n" description)
|
|
|
|
|
(format "<dc:title>%s</dc:title>\n" title)
|
ox: Add #+SUBTITLE property in some backends
* ox-texinfo.el (texinfo, org-texinfo-template): Parse subtitle.
* ox-s5.el (org-s5-title-slide-template):
* ox-deck.el (org-deck-title-slide-template):
* ox-odt.el (odt, org-odt-template):
* ox-latex.el (latex, org-latex-template):
* ox-html.el (html, org-html-format-spec, org-html-template):
* ox-ascii.el (ascii, org-ascii-template--document-title):
* ox-beamer.el (beamer, org-beamer-template): Support #+SUBTITLE.
* ox-html.el (org-html-postamble-format)
(org-html-preamble-format):
* ox-latex.el (org-latex-title-command)
(org-latex-hyperref-template): Update docstring.
* ox-html.el (org-html-style-default): New .subtitle css property.
* ox-beamer.el (org-beamer-subtitle-format):
* ox-latex.el (org-latex-subtitle-format)
(org-latex-subtitle-separate): New variable.
* org.texi (ASCII/Latin-1/UTF-8 export)
(Beamer specific export settings)
(HTML Specific export settings)
(@LaTeX{} specific export settings, CSS support)
(ODT specific export settings)
(Texinfo specific export settings, Document preamble)
(Publishing options, Publishing options): Document #+SUBTITLE.
The patch adds a #+SUBTITLE keyword to ox-ascii, ox-latex, ox-html and
ox-odt.
2015-03-01 21:09:19 +00:00
|
|
|
|
(when (org-string-nw-p subtitle)
|
|
|
|
|
(format
|
|
|
|
|
"<meta:user-defined meta:name=\"subtitle\">%s</meta:user-defined>\n"
|
|
|
|
|
subtitle))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"\n"
|
|
|
|
|
" </office:meta>\n" "</office:document-meta>")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
nil (concat org-odt-zip-dir "meta.xml"))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;; Add meta.xml in to manifest.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-create-manifest-file-entry "text/xml" "meta.xml"))
|
2012-07-15 22:08:07 +00:00
|
|
|
|
|
|
|
|
|
;; Update styles file.
|
|
|
|
|
;; Copy styles.xml. Also dump htmlfontify styles, if there is any.
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;; Write styles file.
|
2018-11-10 18:59:12 +00:00
|
|
|
|
(let* ((styles-file
|
|
|
|
|
(pcase (plist-get info :odt-styles-file)
|
|
|
|
|
(`nil (expand-file-name "OrgOdtStyles.xml" org-odt-styles-dir))
|
|
|
|
|
((and s (pred (string-match-p "\\`(.*)\\'")))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(read s)
|
|
|
|
|
(error (user-error "Invalid styles file specification: %S" s))))
|
2018-11-10 20:59:52 +00:00
|
|
|
|
(filename (org-strip-quotes filename)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(cond
|
2018-11-10 18:59:12 +00:00
|
|
|
|
;; Non-availability of styles.xml is not a critical error. For
|
|
|
|
|
;; now, throw an error.
|
|
|
|
|
((null styles-file) (error "Missing styles file"))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
((listp styles-file)
|
|
|
|
|
(let ((archive (nth 0 styles-file))
|
|
|
|
|
(members (nth 1 styles-file)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--zip-extract archive members org-odt-zip-dir)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (member members)
|
|
|
|
|
(when (org-file-image-p member)
|
|
|
|
|
(let* ((image-type (file-name-extension member))
|
|
|
|
|
(media-type (format "image/%s" image-type)))
|
|
|
|
|
(org-odt-create-manifest-file-entry media-type member))))))
|
2018-11-10 18:59:12 +00:00
|
|
|
|
((file-exists-p styles-file)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((styles-file-type (file-name-extension styles-file)))
|
|
|
|
|
(cond
|
|
|
|
|
((string= styles-file-type "xml")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(copy-file styles-file (concat org-odt-zip-dir "styles.xml") t))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
((member styles-file-type '("odt" "ott"))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--zip-extract styles-file "styles.xml" org-odt-zip-dir)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(t
|
2015-08-06 02:06:57 +00:00
|
|
|
|
(error "Invalid specification of styles.xml file: %S"
|
|
|
|
|
(plist-get info :odt-styles-file))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;; create a manifest entry for styles.xml
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-create-manifest-file-entry "text/xml" "styles.xml")
|
2019-12-20 10:45:11 +00:00
|
|
|
|
;; Ensure we have write permissions to this file.
|
|
|
|
|
(set-file-modes (concat org-odt-zip-dir "styles.xml") #o600)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;; FIXME: Who is opening an empty styles.xml before this point?
|
|
|
|
|
(with-current-buffer
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(find-file-noselect (concat org-odt-zip-dir "styles.xml") t)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(revert-buffer t t)
|
|
|
|
|
|
|
|
|
|
;; Write custom styles for source blocks
|
|
|
|
|
;; Save STYLES used for colorizing of source blocks.
|
|
|
|
|
;; Update styles.xml with styles that were collected as part of
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; `org-odt-hfy-face-to-css' callbacks.
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((styles (mapconcat (lambda (style) (format " %s\n" (cddr style)))
|
|
|
|
|
hfy-user-sheet-assoc "")))
|
|
|
|
|
(when styles
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(when (re-search-forward "</office:styles>" nil t)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(insert "\n<!-- Org Htmlfontify Styles -->\n" styles "\n"))))
|
|
|
|
|
|
|
|
|
|
;; Update styles.xml - take care of outline numbering
|
|
|
|
|
|
|
|
|
|
;; Don't make automatic backup of styles.xml file. This setting
|
|
|
|
|
;; prevents the backed-up styles.xml file from being zipped in to
|
|
|
|
|
;; odt file. This is more of a hackish fix. Better alternative
|
|
|
|
|
;; would be to fix the zip command so that the output odt file
|
|
|
|
|
;; includes only the needed files and excludes any auto-generated
|
|
|
|
|
;; extra files like backups and auto-saves etc etc. Note that
|
|
|
|
|
;; currently the zip command zips up the entire temp directory so
|
|
|
|
|
;; that any auto-generated files created under the hood ends up in
|
|
|
|
|
;; the resulting odt file.
|
2015-11-05 16:47:38 +00:00
|
|
|
|
(setq-local backup-inhibited t)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2019-11-12 13:44:05 +00:00
|
|
|
|
;; Outline numbering is retained only up to LEVEL.
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;; To disable outline numbering pass a LEVEL of 0.
|
|
|
|
|
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((regex
|
|
|
|
|
"<text:outline-level-style\\([^>]*\\)text:level=\"\\([^\"]*\\)\"\\([^>]*\\)>")
|
|
|
|
|
(replacement
|
|
|
|
|
"<text:outline-level-style\\1text:level=\"\\2\" style:num-format=\"\">"))
|
|
|
|
|
(while (re-search-forward regex nil t)
|
|
|
|
|
(unless (let ((sec-num (plist-get info :section-numbers))
|
|
|
|
|
(level (string-to-number (match-string 2))))
|
|
|
|
|
(if (wholenump sec-num) (<= level sec-num) sec-num))
|
|
|
|
|
(replace-match replacement t nil))))
|
|
|
|
|
(save-buffer 0)))
|
|
|
|
|
;; Update content.xml.
|
2012-12-07 09:07:12 +00:00
|
|
|
|
|
|
|
|
|
(let* ( ;; `org-display-custom-times' should be accessed right
|
2013-11-17 08:12:41 +00:00
|
|
|
|
;; within the context of the Org buffer. So obtain its
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; value before moving on to temp-buffer context down below.
|
|
|
|
|
(custom-time-fmts
|
|
|
|
|
(if org-display-custom-times
|
|
|
|
|
(cons (substring (car org-time-stamp-custom-formats) 1 -1)
|
|
|
|
|
(substring (cdr org-time-stamp-custom-formats) 1 -1))
|
|
|
|
|
'("%Y-%M-%d %a" . "%Y-%M-%d %a %H:%M"))))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(or (plist-get info :odt-content-template-file)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(expand-file-name "OrgOdtContentTemplate.xml"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
org-odt-styles-dir)))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; Write automatic styles.
|
|
|
|
|
;; - Position the cursor.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(re-search-forward " </office:automatic-styles>" nil t)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
;; - Dump automatic table styles.
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for (style-name props) in
|
|
|
|
|
(plist-get org-odt-automatic-styles 'Table) do
|
|
|
|
|
(when (setq props (or (plist-get props :rel-width) "96"))
|
|
|
|
|
(insert (format org-odt-table-style-format style-name props))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; - Dump date-styles.
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(when (plist-get info :odt-use-date-fields)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(insert (org-odt--build-date-styles (car custom-time-fmts)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
"OrgDate1")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--build-date-styles (cdr custom-time-fmts)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
"OrgDate2")))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; Update display level.
|
|
|
|
|
;; - Remove existing sequence decls. Also position the cursor.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(when (re-search-forward "<text:sequence-decls" nil t)
|
|
|
|
|
(delete-region (match-beginning 0)
|
|
|
|
|
(re-search-forward "</text:sequence-decls>" nil nil)))
|
|
|
|
|
;; Update sequence decls according to user preference.
|
|
|
|
|
(insert
|
|
|
|
|
(format
|
|
|
|
|
"\n<text:sequence-decls>\n%s\n</text:sequence-decls>"
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (x)
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(format
|
2012-12-07 09:07:12 +00:00
|
|
|
|
"<text:sequence-decl text:display-outline-level=\"%d\" text:name=\"%s\"/>"
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(plist-get info :odt-display-outline-level)
|
|
|
|
|
(nth 1 x)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
org-odt-category-map-alist "\n")))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; Position the cursor to document body.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(re-search-forward "</office:text>" nil nil)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
|
|
|
|
|
;; Preamble - Title, Author, Date etc.
|
|
|
|
|
(insert
|
ox: Optional export of title
* ox.el (org-export-with-title): New variable.
* ox (org-export-options-alist),
ox-ascii.el (org-ascii-template--document-title),
ox-beamer.el (org-beamer-template), ox-html.el (org-html-template),
ox-latex.el (org-latex-template), ox-man.el (org-man-template),
ox-odt.el (org-odt-template), ox-org.el (org-org-template),
ox-publish.el (org-publish-project-alist),
ox-texinfo.el (org-texinfo-template),
ox-groff.el (org-groff--mt-head): Use new variable.
* ox-koma-letter.el (org-koma-letter-use-title): Mark obsolete.
* test-ox.el (test-org-export/parse-option-keyword): Add :with-title.
* ORG-NEWS, org.texi: Mention org-export-with-title.
This is useful in e.g. ox-html where title can be set via
`org-html-preamble-template' or when using the {{{title}}}-macro.
2015-02-10 23:09:39 +00:00
|
|
|
|
(let* ((title (and (plist-get info :with-title)
|
|
|
|
|
(org-export-data (plist-get info :title) info)))
|
ox: Add #+SUBTITLE property in some backends
* ox-texinfo.el (texinfo, org-texinfo-template): Parse subtitle.
* ox-s5.el (org-s5-title-slide-template):
* ox-deck.el (org-deck-title-slide-template):
* ox-odt.el (odt, org-odt-template):
* ox-latex.el (latex, org-latex-template):
* ox-html.el (html, org-html-format-spec, org-html-template):
* ox-ascii.el (ascii, org-ascii-template--document-title):
* ox-beamer.el (beamer, org-beamer-template): Support #+SUBTITLE.
* ox-html.el (org-html-postamble-format)
(org-html-preamble-format):
* ox-latex.el (org-latex-title-command)
(org-latex-hyperref-template): Update docstring.
* ox-html.el (org-html-style-default): New .subtitle css property.
* ox-beamer.el (org-beamer-subtitle-format):
* ox-latex.el (org-latex-subtitle-format)
(org-latex-subtitle-separate): New variable.
* org.texi (ASCII/Latin-1/UTF-8 export)
(Beamer specific export settings)
(HTML Specific export settings)
(@LaTeX{} specific export settings, CSS support)
(ODT specific export settings)
(Texinfo specific export settings, Document preamble)
(Publishing options, Publishing options): Document #+SUBTITLE.
The patch adds a #+SUBTITLE keyword to ox-ascii, ox-latex, ox-html and
ox-odt.
2015-03-01 21:09:19 +00:00
|
|
|
|
(subtitle (when title
|
|
|
|
|
(org-export-data (plist-get info :subtitle) info)))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(author (and (plist-get info :with-author)
|
|
|
|
|
(let ((auth (plist-get info :author)))
|
|
|
|
|
(and auth (org-export-data auth info)))))
|
|
|
|
|
(email (plist-get info :email))
|
|
|
|
|
;; Switch on or off above vars based on user settings
|
|
|
|
|
(author (and (plist-get info :with-author) (or author email)))
|
|
|
|
|
(email (and (plist-get info :with-email) email)))
|
|
|
|
|
(concat
|
|
|
|
|
;; Title.
|
2014-03-28 09:08:56 +00:00
|
|
|
|
(when (org-string-nw-p title)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(concat
|
ox: Add #+SUBTITLE property in some backends
* ox-texinfo.el (texinfo, org-texinfo-template): Parse subtitle.
* ox-s5.el (org-s5-title-slide-template):
* ox-deck.el (org-deck-title-slide-template):
* ox-odt.el (odt, org-odt-template):
* ox-latex.el (latex, org-latex-template):
* ox-html.el (html, org-html-format-spec, org-html-template):
* ox-ascii.el (ascii, org-ascii-template--document-title):
* ox-beamer.el (beamer, org-beamer-template): Support #+SUBTITLE.
* ox-html.el (org-html-postamble-format)
(org-html-preamble-format):
* ox-latex.el (org-latex-title-command)
(org-latex-hyperref-template): Update docstring.
* ox-html.el (org-html-style-default): New .subtitle css property.
* ox-beamer.el (org-beamer-subtitle-format):
* ox-latex.el (org-latex-subtitle-format)
(org-latex-subtitle-separate): New variable.
* org.texi (ASCII/Latin-1/UTF-8 export)
(Beamer specific export settings)
(HTML Specific export settings)
(@LaTeX{} specific export settings, CSS support)
(ODT specific export settings)
(Texinfo specific export settings, Document preamble)
(Publishing options, Publishing options): Document #+SUBTITLE.
The patch adds a #+SUBTITLE keyword to ox-ascii, ox-latex, ox-html and
ox-odt.
2015-03-01 21:09:19 +00:00
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>\n"
|
2012-12-07 09:07:12 +00:00
|
|
|
|
"OrgTitle" (format "\n<text:title>%s</text:title>" title))
|
|
|
|
|
;; Separator.
|
ox: Add #+SUBTITLE property in some backends
* ox-texinfo.el (texinfo, org-texinfo-template): Parse subtitle.
* ox-s5.el (org-s5-title-slide-template):
* ox-deck.el (org-deck-title-slide-template):
* ox-odt.el (odt, org-odt-template):
* ox-latex.el (latex, org-latex-template):
* ox-html.el (html, org-html-format-spec, org-html-template):
* ox-ascii.el (ascii, org-ascii-template--document-title):
* ox-beamer.el (beamer, org-beamer-template): Support #+SUBTITLE.
* ox-html.el (org-html-postamble-format)
(org-html-preamble-format):
* ox-latex.el (org-latex-title-command)
(org-latex-hyperref-template): Update docstring.
* ox-html.el (org-html-style-default): New .subtitle css property.
* ox-beamer.el (org-beamer-subtitle-format):
* ox-latex.el (org-latex-subtitle-format)
(org-latex-subtitle-separate): New variable.
* org.texi (ASCII/Latin-1/UTF-8 export)
(Beamer specific export settings)
(HTML Specific export settings)
(@LaTeX{} specific export settings, CSS support)
(ODT specific export settings)
(Texinfo specific export settings, Document preamble)
(Publishing options, Publishing options): Document #+SUBTITLE.
The patch adds a #+SUBTITLE keyword to ox-ascii, ox-latex, ox-html and
ox-odt.
2015-03-01 21:09:19 +00:00
|
|
|
|
"\n<text:p text:style-name=\"OrgTitle\"/>\n"
|
|
|
|
|
;; Subtitle.
|
|
|
|
|
(when (org-string-nw-p subtitle)
|
|
|
|
|
(concat
|
|
|
|
|
(format "<text:p text:style-name=\"OrgSubtitle\">\n%s\n</text:p>\n"
|
|
|
|
|
(concat
|
|
|
|
|
"<text:user-defined style:data-style-name=\"N0\" text:name=\"subtitle\">\n"
|
|
|
|
|
subtitle
|
|
|
|
|
"</text:user-defined>\n"))
|
|
|
|
|
;; Separator.
|
|
|
|
|
"<text:p text:style-name=\"OrgSubtitle\"/>\n"))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(cond
|
|
|
|
|
((and author (not email))
|
|
|
|
|
;; Author only.
|
|
|
|
|
(concat
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"OrgSubtitle"
|
|
|
|
|
(format "<text:initial-creator>%s</text:initial-creator>" author))
|
|
|
|
|
;; Separator.
|
|
|
|
|
"\n<text:p text:style-name=\"OrgSubtitle\"/>"))
|
|
|
|
|
((and author email)
|
|
|
|
|
;; Author and E-mail.
|
2012-11-10 18:56:20 +00:00
|
|
|
|
(concat
|
|
|
|
|
(format
|
|
|
|
|
"\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"OrgSubtitle"
|
|
|
|
|
(format
|
2012-12-07 09:07:12 +00:00
|
|
|
|
"<text:a xlink:type=\"simple\" xlink:href=\"%s\">%s</text:a>"
|
|
|
|
|
(concat "mailto:" email)
|
|
|
|
|
(format "<text:initial-creator>%s</text:initial-creator>" author)))
|
|
|
|
|
;; Separator.
|
|
|
|
|
"\n<text:p text:style-name=\"OrgSubtitle\"/>")))
|
|
|
|
|
;; Date, if required.
|
|
|
|
|
(when (plist-get info :with-date)
|
|
|
|
|
(let* ((date (plist-get info :date))
|
|
|
|
|
;; Check if DATE is specified as a timestamp.
|
|
|
|
|
(timestamp (and (not (cdr date))
|
|
|
|
|
(eq (org-element-type (car date)) 'timestamp)
|
|
|
|
|
(car date))))
|
2015-02-24 14:13:36 +00:00
|
|
|
|
(when date
|
|
|
|
|
(concat
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"OrgSubtitle"
|
|
|
|
|
(if (and (plist-get info :odt-use-date-fields) timestamp)
|
|
|
|
|
(org-odt--format-timestamp (car date))
|
|
|
|
|
(org-export-data date info)))
|
|
|
|
|
;; Separator
|
|
|
|
|
"<text:p text:style-name=\"OrgSubtitle\"/>")))))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; Table of Contents
|
|
|
|
|
(let* ((with-toc (plist-get info :with-toc))
|
|
|
|
|
(depth (and with-toc (if (wholenump with-toc)
|
|
|
|
|
with-toc
|
|
|
|
|
(plist-get info :headline-levels)))))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(when depth (insert (or (org-odt-toc depth info) ""))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
;; Contents.
|
|
|
|
|
(insert contents)
|
|
|
|
|
;; Return contents.
|
|
|
|
|
(buffer-substring-no-properties (point-min) (point-max)))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Transcode Functions
|
|
|
|
|
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
;;;; Bold
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-bold (_bold contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode BOLD from Org to ODT.
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
CONTENTS is the text with bold markup. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"Bold" contents))
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Center Block
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-center-block (_center-block contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a CENTER-BLOCK element from Org to ODT.
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
CONTENTS holds the contents of the center block. INFO is a plist
|
2012-02-22 14:44:21 +00:00
|
|
|
|
holding contextual information."
|
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
2012-09-13 15:15:07 +00:00
|
|
|
|
contents)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2012-04-29 00:11:22 +00:00
|
|
|
|
;;;; Clock
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-clock (clock contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a CLOCK element from Org to ODT.
|
2012-04-29 00:11:22 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(let ((timestamp (org-element-property :value clock))
|
|
|
|
|
(duration (org-element-property :duration clock)))
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
(if (eq (org-element-type (org-export-get-next-element clock info))
|
|
|
|
|
'clock) "OrgClock" "OrgClockLastLine")
|
|
|
|
|
(concat
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgClockKeyword" org-clock-string)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-timestamp timestamp contents info)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(and duration (format " (%s)" duration))))))
|
2012-04-29 00:11:22 +00:00
|
|
|
|
|
|
|
|
|
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
;;;; Code
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-code (code _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a CODE object from Org to ODT.
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
2013-03-13 16:02:34 +00:00
|
|
|
|
"OrgCode" (org-odt--encode-plain-text
|
|
|
|
|
(org-element-property :value code))))
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Drawer
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-drawer (drawer contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a DRAWER element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the block. INFO is a plist
|
|
|
|
|
holding contextual information."
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(let* ((name (org-element-property :drawer-name drawer))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(output (funcall (plist-get info :odt-format-drawer-function)
|
2013-11-14 13:05:18 +00:00
|
|
|
|
name contents)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
output))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Dynamic Block
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-dynamic-block (_dynamic-block contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a DYNAMIC-BLOCK element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the block. INFO is a plist
|
org-export: Remove unnecessary back-end arguments
* contrib/lisp/org-e-ascii.el (org-e-ascii--build-title,
org-e-ascii--build-caption, org-e-ascii--list-listings,
org-e-ascii--list-tables, org-e-ascii--describe-links,
org-e-ascii-template--document-title, org-e-ascii-dynamic-block,
org-e-ascii-inlinetask, org-e-ascii-item, org-e-ascii-link,
org-e-ascii-quote-section, org-e-ascii--table-cell-width): Do not
provide back-end symbol.
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html-footnote-section, org-e-html-template,
org-e-html-dynamic-block, org-e-html-format-headline--wrap,
org-e-html-headline, org-e-html-item, org-e-html-link,
org-e-html-time-stamp): Do not provide back-end symbol.
* contrib/lisp/org-e-latex.el (org-e-latex--caption/label-string,
org-e-latex-template, org-e-latex-dynamic-block,
org-e-latex-footnote-reference, org-e-latex-headline,
org-e-latex-inlinetask, org-e-latex-item, org-e-latex-link,
org-e-latex-src-block): Do not provide back-end symbol.
* contrib/lisp/org-e-odt.el (org-e-odt-format-preamble,
org-e-odt-format-label, org-e-odt-write-manifest-file,
org-e-odt--caption/label-string, org-e-odt-dynamic-block,
org-e-odt-format-headline--wrap, org-e-odt-headline, org-e-odt-item,
org-e-odt-latex-environment, org-e-odt-link, org-e-odt-src-block,
org-e-odt-time-stamp): Do not provide back-end symbol.
* contrib/lisp/org-export.el (org-export-get-environment): Provide
back-end symbol under `:back-end' property.
(org-export-collect-tree-properties, org-export-data,
org-export-filter-verbatim-functions, org-export-install-filters,
org-export-as, org-export-expand-macro,
org-export-filter-apply-functions, org-export-secondary-string):
Remove back-end references.
* testing/lisp/test-org-export.el: Update tests.
Back-end can be found in communication channel with (plist-get
info :back-end). Hence back-ends do not have to hard-code their name
in any transcoder. It will allow to derive a back-end from another
one.
2012-04-28 09:33:16 +00:00
|
|
|
|
holding contextual information. See `org-export-data'."
|
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
2012-09-13 15:15:07 +00:00
|
|
|
|
contents)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Entity
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-entity (entity _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode an ENTITY object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS are the definition itself. INFO is a plist holding
|
|
|
|
|
contextual information."
|
|
|
|
|
(org-element-property :utf-8 entity))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Example Block
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-example-block (example-block _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a EXAMPLE-BLOCK element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-format-code example-block info))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Export Snippet
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-export-snippet (export-snippet _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a EXPORT-SNIPPET object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(when (eq (org-export-snippet-backend export-snippet) 'odt)
|
2012-02-23 17:10:14 +00:00
|
|
|
|
(org-element-property :value export-snippet)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2014-09-08 09:57:27 +00:00
|
|
|
|
;;;; Export Block
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-export-block (export-block _contents _info)
|
2014-09-08 09:57:27 +00:00
|
|
|
|
"Transcode a EXPORT-BLOCK element from Org to ODT.
|
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
|
|
|
|
(when (string= (org-element-property :type export-block) "ODT")
|
|
|
|
|
(org-remove-indentation (org-element-property :value export-block))))
|
|
|
|
|
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Fixed Width
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-fixed-width (fixed-width _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a FIXED-WIDTH element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(org-odt-do-format-code (org-element-property :value fixed-width) info))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Footnote Definition
|
|
|
|
|
|
|
|
|
|
;; Footnote Definitions are ignored.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Footnote Reference
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-footnote-reference (footnote-reference _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a FOOTNOTE-REFERENCE element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((--format-footnote-definition
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(lambda (n def)
|
|
|
|
|
(setq n (format "%d" n))
|
|
|
|
|
(let ((id (concat "fn" n))
|
|
|
|
|
(note-class "footnote"))
|
|
|
|
|
(format
|
|
|
|
|
"<text:note text:id=\"%s\" text:note-class=\"%s\">%s</text:note>"
|
|
|
|
|
id note-class
|
|
|
|
|
(concat
|
|
|
|
|
(format "<text:note-citation>%s</text:note-citation>" n)
|
|
|
|
|
(format "<text:note-body>%s</text:note-body>" def))))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(--format-footnote-reference
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(lambda (n)
|
|
|
|
|
(setq n (format "%d" n))
|
|
|
|
|
(let ((note-class "footnote")
|
|
|
|
|
(ref-format "text")
|
|
|
|
|
(ref-name (concat "fn" n)))
|
|
|
|
|
(format
|
|
|
|
|
"<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgSuperscript"
|
|
|
|
|
(format "<text:note-ref text:note-class=\"%s\" text:reference-format=\"%s\" text:ref-name=\"%s\">%s</text:note-ref>"
|
|
|
|
|
note-class ref-format ref-name n))))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(concat
|
|
|
|
|
;; Insert separator between two footnotes in a row.
|
2012-07-27 14:13:57 +00:00
|
|
|
|
(let ((prev (org-export-get-previous-element footnote-reference info)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(and (eq (org-element-type prev) 'footnote-reference)
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgSuperscript" ",")))
|
2013-11-17 08:12:41 +00:00
|
|
|
|
;; Transcode footnote reference.
|
2015-02-21 08:34:15 +00:00
|
|
|
|
(let ((n (org-export-get-footnote-number footnote-reference info nil t)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(cond
|
2015-02-21 08:34:15 +00:00
|
|
|
|
((not
|
|
|
|
|
(org-export-footnote-first-reference-p footnote-reference info nil t))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(funcall --format-footnote-reference n))
|
|
|
|
|
(t
|
2013-03-29 22:09:11 +00:00
|
|
|
|
(let* ((raw (org-export-get-footnote-definition
|
|
|
|
|
footnote-reference info))
|
2013-06-24 18:55:24 +00:00
|
|
|
|
(def
|
|
|
|
|
(let ((def (org-trim
|
|
|
|
|
(org-export-data-with-backend
|
|
|
|
|
raw
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'odt
|
|
|
|
|
:transcoders
|
|
|
|
|
'((paragraph . (lambda (p c i)
|
|
|
|
|
(org-odt--format-paragraph
|
2014-07-25 09:20:49 +00:00
|
|
|
|
p c i
|
|
|
|
|
"Footnote"
|
2013-06-24 18:55:24 +00:00
|
|
|
|
"OrgFootnoteCenter"
|
|
|
|
|
"OrgFootnoteQuotations")))))
|
|
|
|
|
info))))
|
2015-08-15 21:42:33 +00:00
|
|
|
|
;; Inline definitions are secondary strings. We
|
|
|
|
|
;; need to wrap them within a paragraph.
|
2016-10-25 11:13:26 +00:00
|
|
|
|
(if (eq (org-element-class (car (org-element-contents raw)))
|
|
|
|
|
'element)
|
2015-08-15 21:42:33 +00:00
|
|
|
|
def
|
2015-08-16 17:30:39 +00:00
|
|
|
|
(format
|
|
|
|
|
"\n<text:p text:style-name=\"Footnote\">%s</text:p>"
|
|
|
|
|
def)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(funcall --format-footnote-definition n def))))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Headline
|
|
|
|
|
|
2013-06-24 18:55:24 +00:00
|
|
|
|
(defun org-odt-format-headline--wrap (headline backend info
|
|
|
|
|
&optional format-function
|
|
|
|
|
&rest extra-keys)
|
|
|
|
|
"Transcode a HEADLINE element using BACKEND.
|
|
|
|
|
INFO is a plist holding contextual information."
|
|
|
|
|
(setq backend (or backend (plist-get info :back-end)))
|
2012-04-04 16:59:04 +00:00
|
|
|
|
(let* ((level (+ (org-export-get-relative-level headline info)))
|
|
|
|
|
(headline-number (org-export-get-headline-number headline info))
|
|
|
|
|
(section-number (and (org-export-numbered-headline-p headline info)
|
|
|
|
|
(mapconcat 'number-to-string
|
|
|
|
|
headline-number ".")))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(todo (and (plist-get info :with-todo-keywords)
|
org-export: Secondary strings are transcoded with `org-export-data'
* contrib/lisp/org-export.el (org-export-transcoder): New function.
(org-export-data): Also export secondary strings. Refactored.
(org-export-secondary-string): Remove function.
(org-export-expand): Fix code indentation.
(org-export-expand-macro): Use `org-export-data' instead of
`org-export-secondary-string'.
* contrib/lisp/org-e-ascii.el (org-e-ascii--build-title,
org-e-ascii--build-caption, org-e-ascii--list-listings,
org-e-ascii--list-tables, org-e-ascii--describe-links,
org-e-ascii-template--document-title, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-link, org-e-ascii-quote-section,
org-e-ascii--table-cell-width): Use `org-export-data' instead of
`org-export-secondary-string'.
* contrib/lisp/org-e-html.el (org-e-html-footnote-section,
org-e-html--caption/label-string, org-e-html-meta-info,
org-e-html-preamble, org-e-html-template,
org-e-html-format-headline--wrap, org-e-html-headline,
org-e-html-item, org-e-html-link): Use `org-export-data' instead of
`org-export-secondary-string'.
* contrib/lisp/org-e-latex.el (org-e-latex--caption/label-string,
org-e-latex-template, org-e-latex-footnote-reference,
org-e-latex-headline, org-e-latex-inlinetask, org-e-latex-item,
org-e-latex-link, org-e-latex-src-block): Use `org-export-data'
instead of `org-export-secondary-string'.
* contrib/lisp/org-e-odt.el (org-e-odt-format-preamble,
org-e-odt-format-label, org-e-odt-update-meta-file,
org-e-odt--caption/label-string, org-e-odt-footnote-def,
org-e-odt-format-headline--wrap, org-e-odt-headline, org-e-odt-item,
org-e-odt-latex-environment, org-e-odt-link, org-e-odt-src-block):
Use `org-export-data' instead of `org-export-secondary-string'.
2012-04-30 00:04:03 +00:00
|
|
|
|
(let ((todo (org-element-property :todo-keyword headline)))
|
2013-06-24 18:55:24 +00:00
|
|
|
|
(and todo
|
|
|
|
|
(org-export-data-with-backend todo backend info)))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(todo-type (and todo (org-element-property :todo-type headline)))
|
|
|
|
|
(priority (and (plist-get info :with-priority)
|
|
|
|
|
(org-element-property :priority headline)))
|
2013-06-24 18:55:24 +00:00
|
|
|
|
(text (org-export-data-with-backend
|
|
|
|
|
(org-element-property :title headline) backend info))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(tags (and (plist-get info :with-tags)
|
2012-05-26 11:44:13 +00:00
|
|
|
|
(org-export-get-tags headline info)))
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(headline-label (org-export-get-reference headline info))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(format-function
|
|
|
|
|
(if (functionp format-function) format-function
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(cl-function
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(lambda (todo todo-type priority text tags
|
2015-10-31 23:58:57 +00:00
|
|
|
|
&key _level _section-number _headline-label
|
|
|
|
|
&allow-other-keys)
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(funcall (plist-get info :odt-format-headline-function)
|
|
|
|
|
todo todo-type priority text tags))))))
|
2012-04-04 16:59:04 +00:00
|
|
|
|
(apply format-function
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
todo todo-type priority text tags
|
2015-10-31 23:58:57 +00:00
|
|
|
|
:headline-label headline-label
|
|
|
|
|
:level level
|
2013-01-27 22:11:34 +00:00
|
|
|
|
:section-number section-number extra-keys)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-headline (headline contents info)
|
2013-02-23 12:47:44 +00:00
|
|
|
|
"Transcode a HEADLINE element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the headline. INFO is a plist
|
|
|
|
|
holding contextual information."
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; Case 1: This is a footnote section: ignore it.
|
|
|
|
|
(unless (org-element-property :footnote-section-p headline)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(let* ((full-text (org-odt-format-headline--wrap headline nil info))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; Get level relative to current parsed data.
|
|
|
|
|
(level (org-export-get-relative-level headline info))
|
2014-09-21 14:17:55 +00:00
|
|
|
|
(numbered (org-export-numbered-headline-p headline info))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; Get canonical label for the headline.
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(id (org-export-get-reference headline info))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; Extra targets.
|
|
|
|
|
(extra-targets
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(let ((id (org-element-property :ID headline)))
|
|
|
|
|
(if id (org-odt--target "" (concat "ID-" id)) "")))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; Title.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(anchored-title (org-odt--target full-text id)))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(cond
|
|
|
|
|
;; Case 2. This is a deep sub-tree: export it as a list item.
|
|
|
|
|
;; Also export as items headlines for which no section
|
|
|
|
|
;; format has been found.
|
|
|
|
|
((org-export-low-level-p headline info)
|
|
|
|
|
;; Build the real contents of the sub-tree.
|
|
|
|
|
(concat
|
|
|
|
|
(and (org-export-first-sibling-p headline info)
|
|
|
|
|
(format "\n<text:list text:style-name=\"%s\" %s>"
|
|
|
|
|
;; Choose style based on list type.
|
2014-09-21 14:17:55 +00:00
|
|
|
|
(if numbered "OrgNumberedList" "OrgBulletedList")
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; If top-level list, re-start numbering. Otherwise,
|
|
|
|
|
;; continue numbering.
|
|
|
|
|
(format "text:continue-numbering=\"%s\""
|
|
|
|
|
(let* ((parent (org-export-get-parent-headline
|
|
|
|
|
headline)))
|
|
|
|
|
(if (and parent
|
|
|
|
|
(org-export-low-level-p parent info))
|
|
|
|
|
"true" "false")))))
|
2012-09-04 08:45:14 +00:00
|
|
|
|
(let ((headline-has-table-p
|
|
|
|
|
(let ((section (assq 'section (org-element-contents headline))))
|
|
|
|
|
(assq 'table (and section (org-element-contents section))))))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(format "\n<text:list-item>\n%s\n%s"
|
|
|
|
|
(concat
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Text_20_body"
|
|
|
|
|
(concat extra-targets anchored-title))
|
|
|
|
|
contents)
|
|
|
|
|
(if headline-has-table-p
|
|
|
|
|
"</text:list-header>"
|
|
|
|
|
"</text:list-item>")))
|
|
|
|
|
(and (org-export-last-sibling-p headline info)
|
|
|
|
|
"</text:list>")))
|
|
|
|
|
;; Case 3. Standard headline. Export it as a section.
|
|
|
|
|
(t
|
2012-04-04 16:59:04 +00:00
|
|
|
|
(concat
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format
|
2014-09-21 14:17:55 +00:00
|
|
|
|
"\n<text:h text:style-name=\"%s\" text:outline-level=\"%s\" text:is-list-header=\"%s\">%s</text:h>"
|
|
|
|
|
(format "Heading_20_%s%s"
|
|
|
|
|
level (if numbered "" "_unnumbered"))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
level
|
2014-09-21 14:17:55 +00:00
|
|
|
|
(if numbered "false" "true")
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(concat extra-targets anchored-title))
|
2012-04-04 16:59:04 +00:00
|
|
|
|
contents))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(defun org-odt-format-headline-default-function
|
|
|
|
|
(todo todo-type priority text tags)
|
|
|
|
|
"Default format function for a headline.
|
|
|
|
|
See `org-odt-format-headline-function' for details."
|
|
|
|
|
(concat
|
|
|
|
|
;; Todo.
|
|
|
|
|
(when todo
|
|
|
|
|
(let ((style (if (eq todo-type 'done) "OrgDone" "OrgTodo")))
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span> " style todo)))
|
|
|
|
|
(when priority
|
2017-08-30 06:04:25 +00:00
|
|
|
|
(let* ((style (format "OrgPriority-%c" priority))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(priority (format "[#%c]" priority)))
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span> "
|
|
|
|
|
style priority)))
|
|
|
|
|
;; Title.
|
|
|
|
|
text
|
|
|
|
|
;; Tags.
|
|
|
|
|
(when tags
|
|
|
|
|
(concat
|
|
|
|
|
"<text:tab/>"
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">[%s]</text:span>"
|
|
|
|
|
"OrgTags" (mapconcat
|
|
|
|
|
(lambda (tag)
|
|
|
|
|
(format
|
|
|
|
|
"<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgTag" tag)) tags " : "))))))
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
;;;; Horizontal Rule
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-horizontal-rule (_horizontal-rule _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode an HORIZONTAL-RULE object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
2012-09-13 15:15:07 +00:00
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Horizontal_20_Line" ""))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inline Babel Call
|
|
|
|
|
|
|
|
|
|
;; Inline Babel Calls are ignored.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inline Src Block
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--find-verb-separator (s)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Return a character not used in string S.
|
|
|
|
|
This is used to choose a separator for constructs like \\verb."
|
|
|
|
|
(let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for c across ll
|
|
|
|
|
when (not (string-match (regexp-quote (char-to-string c)) s))
|
|
|
|
|
return (char-to-string c))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-inline-src-block (_inline-src-block _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode an INLINE-SRC-BLOCK element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the item. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(error "FIXME"))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inlinetask
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-inlinetask (inlinetask contents info)
|
2012-04-04 16:59:04 +00:00
|
|
|
|
"Transcode an INLINETASK element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the block. INFO is a plist
|
|
|
|
|
holding contextual information."
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(let* ((todo
|
|
|
|
|
(and (plist-get info :with-todo-keywords)
|
|
|
|
|
(let ((todo (org-element-property :todo-keyword inlinetask)))
|
|
|
|
|
(and todo (org-export-data todo info)))))
|
|
|
|
|
(todo-type (and todo (org-element-property :todo-type inlinetask)))
|
|
|
|
|
(priority (and (plist-get info :with-priority)
|
|
|
|
|
(org-element-property :priority inlinetask)))
|
|
|
|
|
(text (org-export-data (org-element-property :title inlinetask) info))
|
|
|
|
|
(tags (and (plist-get info :with-tags)
|
|
|
|
|
(org-export-get-tags inlinetask info))))
|
|
|
|
|
(funcall (plist-get info :odt-format-inlinetask-function)
|
|
|
|
|
todo todo-type priority text tags contents)))
|
|
|
|
|
|
|
|
|
|
(defun org-odt-format-inlinetask-default-function
|
|
|
|
|
(todo todo-type priority name tags contents)
|
2018-02-16 22:33:57 +00:00
|
|
|
|
"Default format function for inlinetasks.
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
See `org-odt-format-inlinetask-function' for details."
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Text_20_body"
|
|
|
|
|
(org-odt--textbox
|
|
|
|
|
(concat
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"OrgInlineTaskHeading"
|
|
|
|
|
(org-odt-format-headline-default-function
|
|
|
|
|
todo todo-type priority name tags))
|
|
|
|
|
contents)
|
|
|
|
|
nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\"")))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
;;;; Italic
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-italic (_italic contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode ITALIC from Org to ODT.
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
CONTENTS is the text with italic markup. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"Emphasis" contents))
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Item
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-item (item contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode an ITEM element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the item. INFO is a plist holding
|
|
|
|
|
contextual information."
|
org-export: Rewrite topology functions
* contrib/lisp/org-export.el (org-export-get-genealogy,
org-export-get-parent, org-export-get-parent-headline,
org-export-get-parent-table): Rewrite function to use :parent
property. Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code. Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
org-e-ascii--unique-links, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
change.
* contrib/lisp/org-e-html.el (org-e-html-link,
org-e-html-link--inline-image): Use new function and apply signature
change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
org-e-odt-format-label, org-e-odt-link--inline-image): Use new
function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
2012-06-08 19:00:47 +00:00
|
|
|
|
(let* ((plain-list (org-export-get-parent item))
|
2018-10-19 13:19:38 +00:00
|
|
|
|
(count (org-element-property :counter item))
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(type (org-element-property :type plain-list)))
|
|
|
|
|
(unless (memq type '(ordered unordered descriptive-1 descriptive-2))
|
|
|
|
|
(error "Unknown list type: %S" type))
|
2018-10-19 13:19:38 +00:00
|
|
|
|
(format "\n<text:list-item%s>\n%s\n%s"
|
|
|
|
|
(if count (format " text:start-value=\"%s\"" count) "")
|
2015-10-31 23:58:57 +00:00
|
|
|
|
contents
|
|
|
|
|
(if (org-element-map item 'table #'identity info 'first-match)
|
|
|
|
|
"</text:list-header>"
|
|
|
|
|
"</text:list-item>"))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
;;;; Keyword
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-keyword (keyword _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a KEYWORD element from Org to ODT.
|
2014-10-25 15:14:34 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual
|
|
|
|
|
information."
|
2012-03-28 12:04:26 +00:00
|
|
|
|
(let ((key (org-element-property :key keyword))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(value (org-element-property :value keyword)))
|
|
|
|
|
(cond
|
2012-08-25 20:35:24 +00:00
|
|
|
|
((string= key "ODT") value)
|
2012-12-10 05:28:40 +00:00
|
|
|
|
((string= key "INDEX")
|
|
|
|
|
;; FIXME
|
|
|
|
|
(ignore))
|
2013-03-04 19:31:08 +00:00
|
|
|
|
((string= key "TOC")
|
2014-10-25 15:14:34 +00:00
|
|
|
|
(let ((case-fold-search t))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(cond
|
2016-07-25 13:21:12 +00:00
|
|
|
|
((string-match-p "\\<headlines\\>" value)
|
2014-10-25 15:14:34 +00:00
|
|
|
|
(let ((depth (or (and (string-match "\\<[0-9]+\\>" value)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(string-to-number (match-string 0 value)))
|
2014-10-25 15:14:34 +00:00
|
|
|
|
(plist-get info :headline-levels)))
|
2019-05-15 18:22:05 +00:00
|
|
|
|
(scope
|
|
|
|
|
(cond
|
|
|
|
|
((string-match ":target +\\(\".+?\"\\|\\S-+\\)" value) ;link
|
|
|
|
|
(org-export-resolve-link
|
|
|
|
|
(org-strip-quotes (match-string 1 value)) info))
|
|
|
|
|
((string-match-p "\\<local\\>" value) keyword)))) ;local
|
|
|
|
|
(org-odt-toc depth info scope)))
|
2016-07-25 13:21:12 +00:00
|
|
|
|
((string-match-p "tables\\|figures\\|listings" value)
|
2012-12-10 05:28:40 +00:00
|
|
|
|
;; FIXME
|
|
|
|
|
(ignore))))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Latex Environment
|
|
|
|
|
|
2012-10-03 10:13:47 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; (eval-after-load 'ox-odt '(ad-deactivate 'org-format-latex-as-mathml))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;; (defadvice org-format-latex-as-mathml ; FIXME
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; (after org-odt-protect-latex-fragment activate)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;; "Encode LaTeX fragment as XML.
|
|
|
|
|
;; Do this when translation to MathML fails."
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; (unless (> (length ad-return-value) 0)
|
|
|
|
|
;; (setq ad-return-value (org-odt--encode-plain-text (ad-get-arg 0)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-latex-environment (latex-environment _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a LATEX-ENVIRONMENT element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(let* ((latex-frag (org-remove-indentation
|
|
|
|
|
(org-element-property :value latex-environment))))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(org-odt-do-format-code latex-frag info)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Latex Fragment
|
|
|
|
|
|
2012-04-14 20:14:19 +00:00
|
|
|
|
;; (when latex-frag ; FIXME
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
|
;; (setq href (propertize href :title "LaTeX Fragment"
|
2012-04-14 20:14:19 +00:00
|
|
|
|
;; :description latex-frag)))
|
|
|
|
|
;; handle verbatim
|
|
|
|
|
;; provide descriptions
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-latex-fragment (latex-fragment _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a LATEX-FRAGMENT object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(let ((latex-frag (org-element-property :value latex-fragment)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
"OrgCode" (org-odt--encode-plain-text latex-frag t))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Line Break
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-line-break (_line-break _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a LINE-BREAK object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
2013-10-23 16:49:03 +00:00
|
|
|
|
"<text:line-break/>")
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;;;; Link
|
|
|
|
|
|
|
|
|
|
;;;; Links :: Label references
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--enumerate (element info &optional predicate n)
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(when predicate (cl-assert (funcall predicate element info)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let* ((--numbered-parent-headline-at-<=-n
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(lambda (element n info)
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for x in (org-element-lineage element)
|
|
|
|
|
thereis (and (eq (org-element-type x) 'headline)
|
|
|
|
|
(<= (org-export-get-relative-level x info) n)
|
|
|
|
|
(org-export-numbered-headline-p x info)
|
|
|
|
|
x))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(--enumerate
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(lambda (element scope info &optional predicate)
|
|
|
|
|
(let ((counter 0))
|
|
|
|
|
(org-element-map (or scope (plist-get info :parse-tree))
|
|
|
|
|
(org-element-type element)
|
|
|
|
|
(lambda (el)
|
|
|
|
|
(and (or (not predicate) (funcall predicate el info))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-incf counter)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(eq element el)
|
|
|
|
|
counter))
|
|
|
|
|
info 'first-match))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(scope (funcall --numbered-parent-headline-at-<=-n
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
element
|
|
|
|
|
(or n (plist-get info :odt-display-outline-level))
|
|
|
|
|
info))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(ordinal (funcall --enumerate element scope info predicate))
|
|
|
|
|
(tag
|
|
|
|
|
(concat
|
|
|
|
|
;; Section number.
|
|
|
|
|
(and scope
|
|
|
|
|
(mapconcat 'number-to-string
|
|
|
|
|
(org-export-get-headline-number scope info) "."))
|
|
|
|
|
;; Separator.
|
|
|
|
|
(and scope ".")
|
|
|
|
|
;; Ordinal.
|
|
|
|
|
(number-to-string ordinal))))
|
|
|
|
|
tag))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-format-label (element info op)
|
2013-06-26 13:22:09 +00:00
|
|
|
|
"Return a label for ELEMENT.
|
|
|
|
|
|
|
|
|
|
ELEMENT is a `link', `table', `src-block' or `paragraph' type
|
|
|
|
|
element. INFO is a plist used as a communication channel. OP is
|
|
|
|
|
either `definition' or `reference', depending on the purpose of
|
|
|
|
|
the generated string.
|
|
|
|
|
|
|
|
|
|
Return value is a string if OP is set to `reference' or a cons
|
|
|
|
|
cell like CAPTION . SHORT-CAPTION) where CAPTION and
|
|
|
|
|
SHORT-CAPTION are strings."
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (memq (org-element-type element) '(link table src-block paragraph)))
|
2015-04-23 10:35:43 +00:00
|
|
|
|
(let* ((element-or-parent
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-element-type element)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(link (org-export-get-parent-element element))
|
|
|
|
|
(t element)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Get label and caption.
|
2015-04-23 10:35:43 +00:00
|
|
|
|
(label (and (or (org-element-property :name element)
|
|
|
|
|
(org-element-property :name element-or-parent))
|
|
|
|
|
(org-export-get-reference element-or-parent info)))
|
|
|
|
|
(caption (let ((c (org-export-get-caption element-or-parent)))
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(and c (org-export-data c info))))
|
2014-01-04 17:09:31 +00:00
|
|
|
|
;; FIXME: We don't use short-caption for now
|
|
|
|
|
(short-caption nil))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(when (or label caption)
|
|
|
|
|
(let* ((default-category
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-element-type element)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(table "__Table__")
|
|
|
|
|
(src-block "__Listing__")
|
|
|
|
|
((link paragraph)
|
|
|
|
|
(cond
|
2013-01-27 22:11:34 +00:00
|
|
|
|
((org-odt--enumerable-latex-image-p element info)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
"__DvipngImage__")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
((org-odt--enumerable-image-p element info)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
"__Figure__")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
((org-odt--enumerable-formula-p element info)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
"__MathFormula__")
|
|
|
|
|
(t (error "Don't know how to format label for link: %S"
|
|
|
|
|
element))))
|
|
|
|
|
(t (error "Don't know how to format label for element type: %s"
|
|
|
|
|
(org-element-type element)))))
|
|
|
|
|
seqno)
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert default-category)
|
|
|
|
|
(pcase-let
|
|
|
|
|
((`(,counter ,label-style ,category ,predicate)
|
|
|
|
|
(assoc-default default-category org-odt-category-map-alist)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Compute sequence number of the element.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(setq seqno (org-odt--enumerate element info predicate))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Localize category string.
|
|
|
|
|
(setq category (org-export-translate category :utf-8 info))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case op
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Case 1: Handle Label definition.
|
|
|
|
|
(definition
|
|
|
|
|
(cons
|
2012-12-21 10:11:32 +00:00
|
|
|
|
(concat
|
|
|
|
|
;; Sneak in a bookmark. The bookmark is used when the
|
|
|
|
|
;; labeled element is referenced with a link that
|
2013-11-17 08:12:41 +00:00
|
|
|
|
;; provides its own description.
|
2012-12-21 10:11:32 +00:00
|
|
|
|
(format "\n<text:bookmark text:name=\"%s\"/>" label)
|
|
|
|
|
;; Label definition: Typically formatted as below:
|
|
|
|
|
;; CATEGORY SEQ-NO: LONG CAPTION
|
2013-06-26 13:22:09 +00:00
|
|
|
|
;; with translation for correct punctuation.
|
2012-12-21 10:11:32 +00:00
|
|
|
|
(format-spec
|
2013-06-26 13:22:09 +00:00
|
|
|
|
(org-export-translate
|
|
|
|
|
(cadr (assoc-string label-style org-odt-label-styles t))
|
|
|
|
|
:utf-8 info)
|
2012-12-21 10:11:32 +00:00
|
|
|
|
`((?e . ,category)
|
|
|
|
|
(?n . ,(format
|
|
|
|
|
"<text:sequence text:ref-name=\"%s\" text:name=\"%s\" text:formula=\"ooow:%s+1\" style:num-format=\"1\">%s</text:sequence>"
|
|
|
|
|
label counter counter seqno))
|
|
|
|
|
(?c . ,(or caption "")))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
short-caption))
|
|
|
|
|
;; Case 2: Handle Label reference.
|
|
|
|
|
(reference
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(fmt1 (car fmt))
|
|
|
|
|
(fmt2 (cadr fmt)))
|
|
|
|
|
(format "<text:sequence-ref text:reference-format=\"%s\" text:ref-name=\"%s\">%s</text:sequence-ref>"
|
2015-04-13 09:24:42 +00:00
|
|
|
|
fmt1
|
|
|
|
|
label
|
|
|
|
|
(format-spec fmt2 `((?e . ,category) (?n . ,seqno))))))
|
2012-12-21 10:11:32 +00:00
|
|
|
|
(t (error "Unknown %S on label" op))))))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Links :: Inline Images
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--copy-image-file (path)
|
2019-09-19 02:32:25 +00:00
|
|
|
|
"Return the internal name of the file"
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(let* ((image-type (file-name-extension path))
|
|
|
|
|
(media-type (format "image/%s" image-type))
|
|
|
|
|
(target-dir "Images/")
|
|
|
|
|
(target-file
|
|
|
|
|
(format "%s%04d.%s" target-dir
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-incf org-odt-embedded-images-count) image-type)))
|
2013-04-06 14:49:10 +00:00
|
|
|
|
(message "Embedding %s as %s..."
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(substring-no-properties path) target-file)
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(when (= 1 org-odt-embedded-images-count)
|
|
|
|
|
(make-directory (concat org-odt-zip-dir target-dir))
|
|
|
|
|
(org-odt-create-manifest-file-entry "" target-dir))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(copy-file path (concat org-odt-zip-dir target-file) 'overwrite)
|
|
|
|
|
(org-odt-create-manifest-file-entry media-type target-file)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
target-file))
|
|
|
|
|
|
2018-02-28 21:55:41 +00:00
|
|
|
|
;; For --without-x builds.
|
|
|
|
|
(declare-function clear-image-cache "image.c" (&optional filter))
|
|
|
|
|
(declare-function image-size "image.c" (spec &optional pixels frame))
|
|
|
|
|
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(defun org-odt--image-size
|
|
|
|
|
(file info &optional user-width user-height scale dpi embed-as)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(let* ((--pixels-to-cms
|
|
|
|
|
(function (lambda (pixels dpi)
|
|
|
|
|
(let ((cms-per-inch 2.54)
|
|
|
|
|
(inches (/ pixels dpi)))
|
|
|
|
|
(* cms-per-inch inches)))))
|
|
|
|
|
(--size-in-cms
|
|
|
|
|
(function
|
|
|
|
|
(lambda (size-in-pixels dpi)
|
|
|
|
|
(and size-in-pixels
|
|
|
|
|
(cons (funcall --pixels-to-cms (car size-in-pixels) dpi)
|
|
|
|
|
(funcall --pixels-to-cms (cdr size-in-pixels) dpi))))))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(dpi (or dpi (plist-get info :odt-pixels-per-inch)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(anchor-type (or embed-as "paragraph"))
|
|
|
|
|
(user-width (and (not scale) user-width))
|
|
|
|
|
(user-height (and (not scale) user-height))
|
|
|
|
|
(size
|
|
|
|
|
(and
|
|
|
|
|
(not (and user-height user-width))
|
|
|
|
|
(or
|
|
|
|
|
;; Use Imagemagick.
|
|
|
|
|
(and (executable-find "identify")
|
|
|
|
|
(let ((size-in-pixels
|
|
|
|
|
(let ((dim (shell-command-to-string
|
|
|
|
|
(format "identify -format \"%%w:%%h\" \"%s\""
|
|
|
|
|
file))))
|
|
|
|
|
(when (string-match "\\([0-9]+\\):\\([0-9]+\\)" dim)
|
|
|
|
|
(cons (string-to-number (match-string 1 dim))
|
|
|
|
|
(string-to-number (match-string 2 dim)))))))
|
|
|
|
|
(funcall --size-in-cms size-in-pixels dpi)))
|
|
|
|
|
;; Use Emacs.
|
|
|
|
|
(let ((size-in-pixels
|
|
|
|
|
(ignore-errors ; Emacs could be in batch mode
|
|
|
|
|
(clear-image-cache)
|
|
|
|
|
(image-size (create-image file) 'pixels))))
|
|
|
|
|
(funcall --size-in-cms size-in-pixels dpi))
|
|
|
|
|
;; Use hard-coded values.
|
|
|
|
|
(cdr (assoc-string anchor-type
|
2013-01-27 22:11:34 +00:00
|
|
|
|
org-odt-default-image-sizes-alist))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Error out.
|
2012-09-28 15:47:48 +00:00
|
|
|
|
(error "Cannot determine image size, aborting"))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(width (car size)) (height (cdr size)))
|
|
|
|
|
(cond
|
|
|
|
|
(scale
|
|
|
|
|
(setq width (* width scale) height (* height scale)))
|
|
|
|
|
((and user-height user-width)
|
|
|
|
|
(setq width user-width height user-height))
|
|
|
|
|
(user-height
|
|
|
|
|
(setq width (* user-height (/ width height)) height user-height))
|
|
|
|
|
(user-width
|
|
|
|
|
(setq height (* user-width (/ height width)) width user-width))
|
|
|
|
|
(t (ignore)))
|
|
|
|
|
;; ensure that an embedded image fits comfortably within a page
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let ((max-width (car org-odt-max-image-size))
|
|
|
|
|
(max-height (cdr org-odt-max-image-size)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(when (or (> width max-width) (> height max-height))
|
|
|
|
|
(let* ((scale1 (/ max-width width))
|
|
|
|
|
(scale2 (/ max-height height))
|
|
|
|
|
(scale (min scale1 scale2)))
|
|
|
|
|
(setq width (* scale width) height (* scale height)))))
|
|
|
|
|
(cons width height)))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-link--inline-image (element info)
|
2012-12-19 20:38:22 +00:00
|
|
|
|
"Return ODT code for an inline image.
|
2012-09-13 20:41:03 +00:00
|
|
|
|
LINK is the link pointing to the inline image. INFO is a plist
|
|
|
|
|
used as a communication channel."
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (eq (org-element-type element) 'link))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(let* ((src (let* ((type (org-element-property :type element))
|
|
|
|
|
(raw-path (org-element-property :path element)))
|
|
|
|
|
(cond ((member type '("http" "https"))
|
|
|
|
|
(concat type ":" raw-path))
|
|
|
|
|
((file-name-absolute-p raw-path)
|
|
|
|
|
(expand-file-name raw-path))
|
|
|
|
|
(t raw-path))))
|
|
|
|
|
(src-expanded (if (file-name-absolute-p src) src
|
|
|
|
|
(expand-file-name src (file-name-directory
|
|
|
|
|
(plist-get info :input-file)))))
|
|
|
|
|
(href (format
|
|
|
|
|
"\n<draw:image xlink:href=\"%s\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--copy-image-file src-expanded)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Extract attributes from #+ATTR_ODT line.
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(attr-from (cl-case (org-element-type element)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(link (org-export-get-parent-element element))
|
|
|
|
|
(t element)))
|
|
|
|
|
;; Convert attributes to a plist.
|
|
|
|
|
(attr-plist (org-export-read-attribute :attr_odt attr-from))
|
|
|
|
|
;; Handle `:anchor', `:style' and `:attributes' properties.
|
|
|
|
|
(user-frame-anchor
|
|
|
|
|
(car (assoc-string (plist-get attr-plist :anchor)
|
|
|
|
|
'(("as-char") ("paragraph") ("page")) t)))
|
|
|
|
|
(user-frame-style
|
|
|
|
|
(and user-frame-anchor (plist-get attr-plist :style)))
|
|
|
|
|
(user-frame-attrs
|
|
|
|
|
(and user-frame-anchor (plist-get attr-plist :attributes)))
|
|
|
|
|
(user-frame-params
|
|
|
|
|
(list user-frame-style user-frame-attrs user-frame-anchor))
|
|
|
|
|
;; (embed-as (or embed-as user-frame-anchor "paragraph"))
|
2013-03-08 23:58:31 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Handle `:width', `:height' and `:scale' properties. Read
|
|
|
|
|
;; them as numbers since we need them for computations.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(size (org-odt--image-size
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
src-expanded info
|
2013-03-08 23:58:31 +00:00
|
|
|
|
(let ((width (plist-get attr-plist :width)))
|
|
|
|
|
(and width (read width)))
|
|
|
|
|
(let ((length (plist-get attr-plist :length)))
|
|
|
|
|
(and length (read length)))
|
|
|
|
|
(let ((scale (plist-get attr-plist :scale)))
|
|
|
|
|
(and scale (read scale)))
|
|
|
|
|
nil ; embed-as
|
|
|
|
|
"paragraph" ; FIXME
|
2012-09-13 20:41:03 +00:00
|
|
|
|
))
|
|
|
|
|
(width (car size)) (height (cdr size))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(standalone-link-p (org-odt--standalone-link-p element info))
|
2012-12-15 20:36:04 +00:00
|
|
|
|
(embed-as (if standalone-link-p "paragraph" "as-char"))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(captions (org-odt-format-label element info 'definition))
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(caption (car captions))
|
2012-12-15 20:36:04 +00:00
|
|
|
|
(entity (concat (and caption "Captioned") embed-as "Image"))
|
|
|
|
|
;; Check if this link was created by LaTeX-to-PNG converter.
|
|
|
|
|
(replaces (org-element-property
|
|
|
|
|
:replaces (if (not standalone-link-p) element
|
|
|
|
|
(org-export-get-parent-element element))))
|
|
|
|
|
;; If yes, note down the type of the element - LaTeX Fragment
|
|
|
|
|
;; or LaTeX environment. It will go in to frame title.
|
|
|
|
|
(title (and replaces (capitalize
|
|
|
|
|
(symbol-name (org-element-type replaces)))))
|
|
|
|
|
|
2013-11-17 08:12:41 +00:00
|
|
|
|
;; If yes, note down its contents. It will go in to frame
|
2012-12-15 20:36:04 +00:00
|
|
|
|
;; description. This quite useful for debugging.
|
|
|
|
|
(desc (and replaces (org-element-property :value replaces))))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--render-image/formula entity href width height
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
captions user-frame-params title desc)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;;;; Links :: Math formula
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-link--inline-formula (element info)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(let* ((src (let ((raw-path (org-element-property :path element)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(cond
|
|
|
|
|
((file-name-absolute-p raw-path)
|
|
|
|
|
(expand-file-name raw-path))
|
|
|
|
|
(t raw-path))))
|
2012-12-15 20:48:58 +00:00
|
|
|
|
(src-expanded (if (file-name-absolute-p src) src
|
|
|
|
|
(expand-file-name src (file-name-directory
|
|
|
|
|
(plist-get info :input-file)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(href
|
2012-12-15 20:48:58 +00:00
|
|
|
|
(format
|
|
|
|
|
"\n<draw:object %s xlink:href=\"%s\" xlink:type=\"simple\"/>"
|
|
|
|
|
" xlink:show=\"embed\" xlink:actuate=\"onLoad\""
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(file-name-directory (org-odt--copy-formula-file src-expanded))))
|
|
|
|
|
(standalone-link-p (org-odt--standalone-link-p element info))
|
2012-12-15 20:48:58 +00:00
|
|
|
|
(embed-as (if standalone-link-p 'paragraph 'character))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(captions (org-odt-format-label element info 'definition))
|
2012-12-15 20:36:04 +00:00
|
|
|
|
;; Check if this link was created by LaTeX-to-MathML
|
|
|
|
|
;; converter.
|
|
|
|
|
(replaces (org-element-property
|
|
|
|
|
:replaces (if (not standalone-link-p) element
|
|
|
|
|
(org-export-get-parent-element element))))
|
|
|
|
|
;; If yes, note down the type of the element - LaTeX Fragment
|
|
|
|
|
;; or LaTeX environment. It will go in to frame title.
|
|
|
|
|
(title (and replaces (capitalize
|
|
|
|
|
(symbol-name (org-element-type replaces)))))
|
|
|
|
|
|
2013-11-17 08:12:41 +00:00
|
|
|
|
;; If yes, note down its contents. It will go in to frame
|
2012-12-15 20:36:04 +00:00
|
|
|
|
;; description. This quite useful for debugging.
|
|
|
|
|
(desc (and replaces (org-element-property :value replaces)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
width height)
|
|
|
|
|
(cond
|
|
|
|
|
((eq embed-as 'character)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--render-image/formula "InlineFormula" href width height
|
2015-10-31 23:58:57 +00:00
|
|
|
|
nil nil title desc))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(t
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((equation (org-odt--render-image/formula
|
2012-12-15 20:36:04 +00:00
|
|
|
|
"CaptionedDisplayFormula" href width height
|
|
|
|
|
captions nil title desc))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(label
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((org-odt-category-map-alist
|
2012-09-13 20:41:03 +00:00
|
|
|
|
'(("__MathFormula__" "Text" "math-label" "Equation"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
org-odt--enumerable-formula-p))))
|
|
|
|
|
(car (org-odt-format-label element info 'definition)))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(concat equation "<text:tab/>" label))))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--copy-formula-file (src-file)
|
2019-09-19 02:32:25 +00:00
|
|
|
|
"Return the internal name of the file"
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let* ((target-dir (format "Formula-%04d/"
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-incf org-odt-embedded-formulas-count)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(target-file (concat target-dir "content.xml")))
|
|
|
|
|
;; Create a directory for holding formula file. Also enter it in
|
|
|
|
|
;; to manifest.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(make-directory (concat org-odt-zip-dir target-dir))
|
|
|
|
|
(org-odt-create-manifest-file-entry
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"application/vnd.oasis.opendocument.formula" target-dir "1.2")
|
|
|
|
|
;; Copy over the formula file from user directory to zip
|
|
|
|
|
;; directory.
|
2013-04-06 14:49:10 +00:00
|
|
|
|
(message "Embedding %s as %s..." src-file target-file)
|
2016-09-01 17:44:30 +00:00
|
|
|
|
(let ((ext (file-name-extension src-file)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(cond
|
|
|
|
|
;; Case 1: Mathml.
|
2016-09-01 17:44:30 +00:00
|
|
|
|
((member ext '("mathml" "mml"))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(copy-file src-file (concat org-odt-zip-dir target-file) 'overwrite))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
;; Case 2: OpenDocument formula.
|
2016-09-01 17:44:30 +00:00
|
|
|
|
((string= ext "odf")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--zip-extract src-file "content.xml"
|
|
|
|
|
(concat org-odt-zip-dir target-dir)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(t (error "%s is not a formula file" src-file))))
|
|
|
|
|
;; Enter the formula file in to manifest.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-create-manifest-file-entry "text/xml" target-file)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
target-file))
|
|
|
|
|
|
|
|
|
|
;;;; Targets
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--render-image/formula (cfg-key href width height &optional
|
2016-07-25 13:51:23 +00:00
|
|
|
|
captions user-frame-params
|
|
|
|
|
&rest title-and-desc)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(let* ((frame-cfg-alist
|
|
|
|
|
;; Each element of this alist is of the form (CFG-HANDLE
|
|
|
|
|
;; INNER-FRAME-PARAMS OUTER-FRAME-PARAMS).
|
|
|
|
|
|
|
|
|
|
;; CFG-HANDLE is the key to the alist.
|
|
|
|
|
|
|
|
|
|
;; INNER-FRAME-PARAMS and OUTER-FRAME-PARAMS specify the
|
|
|
|
|
;; frame params for INNER-FRAME and OUTER-FRAME
|
|
|
|
|
;; respectively. See below.
|
|
|
|
|
|
|
|
|
|
;; Configurations that are meant to be applied to
|
|
|
|
|
;; non-captioned image/formula specifies no
|
|
|
|
|
;; OUTER-FRAME-PARAMS.
|
|
|
|
|
|
|
|
|
|
;; TERMINOLOGY
|
|
|
|
|
;; ===========
|
|
|
|
|
;; INNER-FRAME :: Frame that directly surrounds an
|
|
|
|
|
;; image/formula.
|
|
|
|
|
|
|
|
|
|
;; OUTER-FRAME :: Frame that encloses the INNER-FRAME. This
|
|
|
|
|
;; frame also contains the caption, if any.
|
|
|
|
|
|
|
|
|
|
;; FRAME-PARAMS :: List of the form (FRAME-STYLE-NAME
|
|
|
|
|
;; FRAME-ATTRIBUTES FRAME-ANCHOR). Note
|
|
|
|
|
;; that these are the last three arguments
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; to `org-odt--frame'.
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
|
|
|
|
;; Note that an un-captioned image/formula requires just an
|
|
|
|
|
;; INNER-FRAME, while a captioned image/formula requires
|
|
|
|
|
;; both an INNER and an OUTER-FRAME.
|
|
|
|
|
'(("As-CharImage" ("OrgInlineImage" nil "as-char"))
|
|
|
|
|
("ParagraphImage" ("OrgDisplayImage" nil "paragraph"))
|
|
|
|
|
("PageImage" ("OrgPageImage" nil "page"))
|
|
|
|
|
("CaptionedAs-CharImage"
|
|
|
|
|
("OrgCaptionedImage"
|
|
|
|
|
" style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
|
|
|
|
|
("OrgInlineImage" nil "as-char"))
|
|
|
|
|
("CaptionedParagraphImage"
|
|
|
|
|
("OrgCaptionedImage"
|
|
|
|
|
" style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
|
|
|
|
|
("OrgImageCaptionFrame" nil "paragraph"))
|
|
|
|
|
("CaptionedPageImage"
|
|
|
|
|
("OrgCaptionedImage"
|
|
|
|
|
" style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
|
|
|
|
|
("OrgPageImageCaptionFrame" nil "page"))
|
|
|
|
|
("InlineFormula" ("OrgInlineFormula" nil "as-char"))
|
|
|
|
|
("DisplayFormula" ("OrgDisplayFormula" nil "as-char"))
|
|
|
|
|
("CaptionedDisplayFormula"
|
|
|
|
|
("OrgCaptionedFormula" nil "paragraph")
|
|
|
|
|
("OrgFormulaCaptionFrame" nil "paragraph"))))
|
|
|
|
|
(caption (car captions)) (short-caption (cdr captions))
|
|
|
|
|
;; Retrieve inner and outer frame params, from configuration.
|
|
|
|
|
(frame-cfg (assoc-string cfg-key frame-cfg-alist t))
|
|
|
|
|
(inner (nth 1 frame-cfg))
|
|
|
|
|
(outer (nth 2 frame-cfg))
|
|
|
|
|
;; User-specified frame params (from #+ATTR_ODT spec)
|
|
|
|
|
(user user-frame-params)
|
|
|
|
|
(--merge-frame-params (function
|
|
|
|
|
(lambda (default user)
|
|
|
|
|
"Merge default and user frame params."
|
|
|
|
|
(if (not user) default
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (= (length default) 3))
|
|
|
|
|
(cl-assert (= (length user) 3))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for u in user
|
|
|
|
|
for d in default
|
|
|
|
|
collect (or u d)))))))
|
2012-04-14 20:14:19 +00:00
|
|
|
|
(cond
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Case 1: Image/Formula has no caption.
|
|
|
|
|
;; There is only one frame, one that surrounds the image
|
|
|
|
|
;; or formula.
|
2012-04-14 20:14:19 +00:00
|
|
|
|
((not caption)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Merge user frame params with that from configuration.
|
|
|
|
|
(setq inner (funcall --merge-frame-params inner user))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(apply 'org-odt--frame href width height
|
2012-12-15 20:36:04 +00:00
|
|
|
|
(append inner title-and-desc)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Case 2: Image/Formula is captioned or labeled.
|
|
|
|
|
;; There are two frames: The inner one surrounds the
|
|
|
|
|
;; image or formula. The outer one contains the
|
|
|
|
|
;; caption/sequence number.
|
2012-04-14 20:14:19 +00:00
|
|
|
|
(t
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Merge user frame params with outer frame params.
|
|
|
|
|
(setq outer (funcall --merge-frame-params outer user))
|
|
|
|
|
;; Short caption, if specified, goes as part of inner frame.
|
|
|
|
|
(setq inner (let ((frame-params (copy-sequence inner)))
|
|
|
|
|
(setcar (cdr frame-params)
|
|
|
|
|
(concat
|
|
|
|
|
(cadr frame-params)
|
|
|
|
|
(when short-caption
|
|
|
|
|
(format " draw:name=\"%s\" " short-caption))))
|
|
|
|
|
frame-params))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(apply 'org-odt--textbox
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Illustration"
|
|
|
|
|
(concat
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(apply 'org-odt--frame href width height
|
2012-12-15 20:36:04 +00:00
|
|
|
|
(append inner title-and-desc))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
caption))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
width height outer)))))
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt--enumerable-p (element _info)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Element should have a caption or label.
|
|
|
|
|
(or (org-element-property :caption element)
|
|
|
|
|
(org-element-property :name element)))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--enumerable-image-p (element info)
|
|
|
|
|
(org-odt--standalone-link-p
|
2012-09-13 20:41:03 +00:00
|
|
|
|
element info
|
|
|
|
|
;; Paragraph should have a caption or label. It SHOULD NOT be a
|
|
|
|
|
;; replacement element. (i.e., It SHOULD NOT be a result of LaTeX
|
|
|
|
|
;; processing.)
|
|
|
|
|
(lambda (p)
|
|
|
|
|
(and (not (org-element-property :replaces p))
|
|
|
|
|
(or (org-element-property :caption p)
|
|
|
|
|
(org-element-property :name p))))
|
|
|
|
|
;; Link should point to an image file.
|
|
|
|
|
(lambda (l)
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (eq (org-element-type l) 'link))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(org-export-inline-image-p l (plist-get info :odt-inline-image-rules)))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--enumerable-latex-image-p (element info)
|
|
|
|
|
(org-odt--standalone-link-p
|
2012-09-13 20:41:03 +00:00
|
|
|
|
element info
|
|
|
|
|
;; Paragraph should have a caption or label. It SHOULD also be a
|
|
|
|
|
;; replacement element. (i.e., It SHOULD be a result of LaTeX
|
|
|
|
|
;; processing.)
|
|
|
|
|
(lambda (p)
|
|
|
|
|
(and (org-element-property :replaces p)
|
|
|
|
|
(or (org-element-property :caption p)
|
|
|
|
|
(org-element-property :name p))))
|
|
|
|
|
;; Link should point to an image file.
|
|
|
|
|
(lambda (l)
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (eq (org-element-type l) 'link))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(org-export-inline-image-p l (plist-get info :odt-inline-image-rules)))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--enumerable-formula-p (element info)
|
|
|
|
|
(org-odt--standalone-link-p
|
2012-09-13 20:41:03 +00:00
|
|
|
|
element info
|
|
|
|
|
;; Paragraph should have a caption or label.
|
|
|
|
|
(lambda (p)
|
|
|
|
|
(or (org-element-property :caption p)
|
|
|
|
|
(org-element-property :name p)))
|
|
|
|
|
;; Link should point to a MathML or ODF file.
|
|
|
|
|
(lambda (l)
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (eq (org-element-type l) 'link))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(org-export-inline-image-p l (plist-get info :odt-inline-formula-rules)))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt--standalone-link-p (element _info &optional
|
2016-07-25 13:51:23 +00:00
|
|
|
|
paragraph-predicate
|
|
|
|
|
link-predicate)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
"Test if ELEMENT is a standalone link for the purpose ODT export.
|
2012-04-04 16:59:04 +00:00
|
|
|
|
INFO is a plist holding contextual information.
|
|
|
|
|
|
2012-09-13 20:41:03 +00:00
|
|
|
|
Return non-nil, if ELEMENT is of type paragraph satisfying
|
2013-11-17 08:12:41 +00:00
|
|
|
|
PARAGRAPH-PREDICATE and its sole content, save for whitespaces,
|
2012-09-13 20:41:03 +00:00
|
|
|
|
is a link that satisfies LINK-PREDICATE.
|
|
|
|
|
|
|
|
|
|
Return non-nil, if ELEMENT is of type link satisfying
|
2013-11-17 08:12:41 +00:00
|
|
|
|
LINK-PREDICATE and its containing paragraph satisfies
|
|
|
|
|
PARAGRAPH-PREDICATE in addition to having no other content save for
|
2012-09-13 20:41:03 +00:00
|
|
|
|
leading and trailing whitespaces.
|
|
|
|
|
|
|
|
|
|
Return nil, otherwise."
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(let ((p (cl-case (org-element-type element)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(paragraph element)
|
|
|
|
|
(link (and (or (not link-predicate)
|
|
|
|
|
(funcall link-predicate element))
|
|
|
|
|
(org-export-get-parent element)))
|
|
|
|
|
(t nil))))
|
2012-12-19 20:38:22 +00:00
|
|
|
|
(when (and p (eq (org-element-type p) 'paragraph))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(when (or (not paragraph-predicate)
|
|
|
|
|
(funcall paragraph-predicate p))
|
|
|
|
|
(let ((contents (org-element-contents p)))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for x in contents
|
|
|
|
|
with inline-image-count = 0
|
|
|
|
|
always (cl-case (org-element-type x)
|
|
|
|
|
(plain-text
|
|
|
|
|
(not (org-string-nw-p x)))
|
|
|
|
|
(link
|
|
|
|
|
(and (or (not link-predicate)
|
|
|
|
|
(funcall link-predicate x))
|
|
|
|
|
(= (cl-incf inline-image-count) 1)))
|
|
|
|
|
(t nil))))))))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-link--infer-description (destination info)
|
2015-02-10 21:23:40 +00:00
|
|
|
|
;; DESTINATION is a headline or an element (like paragraph,
|
|
|
|
|
;; verse-block etc) to which a "#+NAME: label" can be attached.
|
|
|
|
|
|
|
|
|
|
;; Note that labels that are attached to captioned entities - inline
|
|
|
|
|
;; images, math formulae and tables - get resolved as part of
|
|
|
|
|
;; `org-odt-format-label' and `org-odt--enumerate'.
|
2012-12-22 20:54:55 +00:00
|
|
|
|
|
|
|
|
|
;; Create a cross-reference to DESTINATION but make best-efforts to
|
|
|
|
|
;; create a *meaningful* description. Check item numbers, section
|
|
|
|
|
;; number and section title in that order.
|
|
|
|
|
|
|
|
|
|
;; NOTE: Counterpart of `org-export-get-ordinal'.
|
|
|
|
|
;; FIXME: Handle footnote-definition footnote-reference?
|
2014-11-16 12:27:34 +00:00
|
|
|
|
(let* ((genealogy (org-element-lineage destination))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
(data (reverse genealogy))
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(label (let ((type (org-element-type destination)))
|
|
|
|
|
(if (memq type '(headline target))
|
|
|
|
|
(org-export-get-reference destination info)
|
|
|
|
|
(error "FIXME: Unable to resolve %S" destination)))))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
(or
|
|
|
|
|
(let* ( ;; Locate top-level list.
|
|
|
|
|
(top-level-list
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for x on data
|
|
|
|
|
when (eq (org-element-type (car x)) 'plain-list)
|
|
|
|
|
return x))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
;; Get list item nos.
|
|
|
|
|
(item-numbers
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for (plain-list item . rest) on top-level-list by #'cddr
|
|
|
|
|
until (not (eq (org-element-type plain-list) 'plain-list))
|
|
|
|
|
collect (when (eq (org-element-property :type
|
|
|
|
|
plain-list)
|
|
|
|
|
'ordered)
|
|
|
|
|
(1+ (length (org-export-get-previous-element
|
|
|
|
|
item info t))))))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
;; Locate top-most listified headline.
|
|
|
|
|
(listified-headlines
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for x on data
|
|
|
|
|
when (and (eq (org-element-type (car x)) 'headline)
|
|
|
|
|
(org-export-low-level-p (car x) info))
|
|
|
|
|
return x))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
;; Get listified headline numbers.
|
|
|
|
|
(listified-headline-nos
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for el in listified-headlines
|
|
|
|
|
when (eq (org-element-type el) 'headline)
|
|
|
|
|
collect (when (org-export-numbered-headline-p el info)
|
|
|
|
|
(1+ (length (org-export-get-previous-element
|
|
|
|
|
el info t)))))))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
;; Combine item numbers from both the listified headlines and
|
|
|
|
|
;; regular list items.
|
|
|
|
|
|
|
|
|
|
;; Case 1: Check if all the parents of list item are numbered.
|
|
|
|
|
;; If yes, link to the item proper.
|
|
|
|
|
(let ((item-numbers (append listified-headline-nos item-numbers)))
|
|
|
|
|
(when (and item-numbers (not (memq nil item-numbers)))
|
|
|
|
|
(format "<text:bookmark-ref text:reference-format=\"number-all-superior\" text:ref-name=\"%s\">%s</text:bookmark-ref>"
|
2015-04-13 09:24:42 +00:00
|
|
|
|
label
|
2012-12-22 20:54:55 +00:00
|
|
|
|
(mapconcat (lambda (n) (if (not n) " "
|
2014-11-16 12:27:34 +00:00
|
|
|
|
(concat (number-to-string n) ".")))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
item-numbers "")))))
|
|
|
|
|
;; Case 2: Locate a regular and numbered headline in the
|
2013-11-17 08:12:41 +00:00
|
|
|
|
;; hierarchy. Display its section number.
|
2014-09-21 14:17:55 +00:00
|
|
|
|
(let ((headline
|
|
|
|
|
(and
|
|
|
|
|
;; Test if destination is a numbered headline.
|
|
|
|
|
(org-export-numbered-headline-p destination info)
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for el in (cons destination genealogy)
|
|
|
|
|
when (and (eq (org-element-type el) 'headline)
|
|
|
|
|
(not (org-export-low-level-p el info))
|
|
|
|
|
(org-export-numbered-headline-p el info))
|
|
|
|
|
return el))))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
;; We found one.
|
|
|
|
|
(when headline
|
|
|
|
|
(format "<text:bookmark-ref text:reference-format=\"chapter\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
|
2015-04-13 09:24:42 +00:00
|
|
|
|
label
|
2012-12-22 20:54:55 +00:00
|
|
|
|
(mapconcat 'number-to-string (org-export-get-headline-number
|
|
|
|
|
headline info) "."))))
|
|
|
|
|
;; Case 4: Locate a regular headline in the hierarchy. Display
|
2013-11-17 08:12:41 +00:00
|
|
|
|
;; its title.
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(let ((headline (cl-loop for el in (cons destination genealogy)
|
|
|
|
|
when (and (eq (org-element-type el) 'headline)
|
|
|
|
|
(not (org-export-low-level-p el info)))
|
|
|
|
|
return el)))
|
2012-12-22 20:54:55 +00:00
|
|
|
|
;; We found one.
|
|
|
|
|
(when headline
|
|
|
|
|
(format "<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
|
2015-04-13 09:24:42 +00:00
|
|
|
|
label
|
2012-12-22 20:54:55 +00:00
|
|
|
|
(let ((title (org-element-property :title headline)))
|
|
|
|
|
(org-export-data title info)))))
|
|
|
|
|
(error "FIXME?"))))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-link (link desc info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a LINK object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
DESC is the description part of the link, or the empty string.
|
|
|
|
|
INFO is a plist holding contextual information. See
|
|
|
|
|
`org-export-data'."
|
|
|
|
|
(let* ((type (org-element-property :type link))
|
|
|
|
|
(raw-path (org-element-property :path link))
|
|
|
|
|
;; Ensure DESC really exists, or set it to nil.
|
|
|
|
|
(desc (and (not (string= desc "")) desc))
|
|
|
|
|
(imagep (org-export-inline-image-p
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
link (plist-get info :odt-inline-image-rules)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(path (cond
|
2014-04-16 20:46:30 +00:00
|
|
|
|
((member type '("http" "https" "ftp" "mailto"))
|
2014-04-16 20:46:53 +00:00
|
|
|
|
(concat type ":" raw-path))
|
2015-04-20 10:37:13 +00:00
|
|
|
|
((string= type "file") (org-export-file-uri raw-path))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(t raw-path)))
|
2013-04-08 15:49:34 +00:00
|
|
|
|
;; Convert & to & for correct XML representation
|
2015-01-04 20:54:41 +00:00
|
|
|
|
(path (replace-regexp-in-string "&" "&" path)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
(cond
|
2015-01-04 20:54:41 +00:00
|
|
|
|
;; Link type is handled by a special function.
|
2015-02-24 14:54:01 +00:00
|
|
|
|
((org-export-custom-protocol-maybe link desc 'odt))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;; Image file.
|
2015-10-31 23:58:57 +00:00
|
|
|
|
((and (not desc) imagep) (org-odt-link--inline-image link info))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;; Formula file.
|
2015-10-31 23:58:57 +00:00
|
|
|
|
((and (not desc)
|
|
|
|
|
(org-export-inline-image-p
|
|
|
|
|
link (plist-get info :odt-inline-formula-rules)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-link--inline-formula link info))
|
2012-05-18 19:06:12 +00:00
|
|
|
|
;; Radio target: Transcode target's contents and use them as
|
|
|
|
|
;; link's description.
|
2012-03-04 19:52:20 +00:00
|
|
|
|
((string= type "radio")
|
2012-05-18 09:20:00 +00:00
|
|
|
|
(let ((destination (org-export-resolve-radio-link link info)))
|
2014-08-27 22:48:17 +00:00
|
|
|
|
(if (not destination) desc
|
2014-03-23 17:04:22 +00:00
|
|
|
|
(format
|
|
|
|
|
"<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(org-export-get-reference destination info)
|
2014-03-23 17:04:22 +00:00
|
|
|
|
desc))))
|
2013-02-23 12:47:44 +00:00
|
|
|
|
;; Links pointing to a headline: Find destination and build
|
2012-03-04 19:52:20 +00:00
|
|
|
|
;; appropriate referencing command.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
((member type '("custom-id" "fuzzy" "id"))
|
2013-06-25 07:05:46 +00:00
|
|
|
|
(let ((destination (if (string= type "fuzzy")
|
|
|
|
|
(org-export-resolve-fuzzy-link link info)
|
|
|
|
|
(org-export-resolve-id-link link info))))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-element-type destination)
|
2015-09-09 12:30:41 +00:00
|
|
|
|
;; Fuzzy link points to a headline. If there's
|
|
|
|
|
;; a description, create a hyperlink. Otherwise, try to
|
|
|
|
|
;; provide a meaningful description.
|
2013-06-25 07:05:46 +00:00
|
|
|
|
(headline
|
|
|
|
|
(if (not desc) (org-odt-link--infer-description destination info)
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(let ((label
|
|
|
|
|
(or (and (string= type "custom-id")
|
|
|
|
|
(org-element-property :CUSTOM_ID destination))
|
|
|
|
|
(org-export-get-reference destination info))))
|
2013-06-25 07:05:46 +00:00
|
|
|
|
(format
|
|
|
|
|
"<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
|
|
|
|
|
label desc))))
|
2015-09-09 12:30:41 +00:00
|
|
|
|
;; Fuzzy link points to a target. If there's a description,
|
|
|
|
|
;; create a hyperlink. Otherwise, try to provide
|
|
|
|
|
;; a meaningful description.
|
2013-06-25 07:05:46 +00:00
|
|
|
|
(target
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
|
|
|
|
|
(org-export-get-reference destination info)
|
|
|
|
|
(or desc (org-export-get-ordinal destination info))))
|
2015-09-09 12:30:41 +00:00
|
|
|
|
;; Fuzzy link points to some element (e.g., an inline image,
|
|
|
|
|
;; a math formula or a table).
|
2013-06-25 07:05:46 +00:00
|
|
|
|
(otherwise
|
|
|
|
|
(let ((label-reference
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(ignore-errors
|
|
|
|
|
(org-odt-format-label destination info 'reference))))
|
|
|
|
|
(cond
|
|
|
|
|
((not label-reference)
|
|
|
|
|
(org-odt-link--infer-description destination info))
|
|
|
|
|
;; LINK has no description. Create
|
|
|
|
|
;; a cross-reference showing entity's sequence
|
|
|
|
|
;; number.
|
|
|
|
|
((not desc) label-reference)
|
|
|
|
|
;; LINK has description. Insert a hyperlink with
|
|
|
|
|
;; user-provided description.
|
|
|
|
|
(t
|
|
|
|
|
(format
|
|
|
|
|
"<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
|
|
|
|
|
(org-export-get-reference destination info)
|
|
|
|
|
desc))))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;; Coderef: replace link with the reference name or the
|
|
|
|
|
;; equivalent line number.
|
|
|
|
|
((string= type "coderef")
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(let* ((line-no (format "%d" (org-export-resolve-coderef path info)))
|
|
|
|
|
(href (concat "coderef-" path)))
|
|
|
|
|
(format
|
|
|
|
|
(org-export-get-coderef-format path desc)
|
|
|
|
|
(format
|
|
|
|
|
"<text:bookmark-ref text:reference-format=\"number\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
|
|
|
|
|
href line-no))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;; External link with a description part.
|
2012-08-25 20:35:24 +00:00
|
|
|
|
((and path desc)
|
2012-12-19 20:38:22 +00:00
|
|
|
|
(let ((link-contents (org-element-contents link)))
|
|
|
|
|
;; Check if description is a link to an inline image.
|
|
|
|
|
(if (and (not (cdr link-contents))
|
|
|
|
|
(let ((desc-element (car link-contents)))
|
|
|
|
|
(and (eq (org-element-type desc-element) 'link)
|
|
|
|
|
(org-export-inline-image-p
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
desc-element
|
|
|
|
|
(plist-get info :odt-inline-image-rules)))))
|
2012-12-19 20:38:22 +00:00
|
|
|
|
;; Format link as a clickable image.
|
|
|
|
|
(format "\n<draw:a xlink:type=\"simple\" xlink:href=\"%s\">\n%s\n</draw:a>"
|
2012-12-22 20:54:55 +00:00
|
|
|
|
path desc)
|
2012-12-19 20:38:22 +00:00
|
|
|
|
;; Otherwise, format it as a regular link.
|
|
|
|
|
(format "<text:a xlink:type=\"simple\" xlink:href=\"%s\">%s</text:a>"
|
|
|
|
|
path desc))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;; External link without a description part.
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(path
|
|
|
|
|
(format "<text:a xlink:type=\"simple\" xlink:href=\"%s\">%s</text:a>"
|
|
|
|
|
path path))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;; No path, only description. Try to do something useful.
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(t (format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"Emphasis" desc)))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2013-09-25 19:27:29 +00:00
|
|
|
|
;;;; Node Property
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-node-property (node-property _contents _info)
|
2013-09-25 19:27:29 +00:00
|
|
|
|
"Transcode a NODE-PROPERTY element from Org to ODT.
|
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual
|
|
|
|
|
information."
|
|
|
|
|
(org-odt--encode-plain-text
|
|
|
|
|
(format "%s:%s"
|
|
|
|
|
(org-element-property :key node-property)
|
|
|
|
|
(let ((value (org-element-property :value node-property)))
|
|
|
|
|
(if value (concat " " value) "")))))
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Paragraph
|
|
|
|
|
|
2014-07-24 12:48:47 +00:00
|
|
|
|
(defun org-odt--paragraph-style (paragraph)
|
|
|
|
|
"Return style of PARAGRAPH.
|
|
|
|
|
Style is a symbol among `quoted', `centered' and nil."
|
|
|
|
|
(let ((up paragraph))
|
|
|
|
|
(while (and (setq up (org-element-property :parent up))
|
|
|
|
|
(not (memq (org-element-type up)
|
|
|
|
|
'(center-block quote-block section)))))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-element-type up)
|
2014-07-24 12:48:47 +00:00
|
|
|
|
(center-block 'centered)
|
|
|
|
|
(quote-block 'quoted))))
|
|
|
|
|
|
2014-07-25 09:20:49 +00:00
|
|
|
|
(defun org-odt--format-paragraph (paragraph contents info default center quote)
|
2013-03-29 22:09:11 +00:00
|
|
|
|
"Format paragraph according to given styles.
|
|
|
|
|
PARAGRAPH is a paragraph type element. CONTENTS is the
|
2014-07-25 09:20:49 +00:00
|
|
|
|
transcoded contents of that paragraph, as a string. INFO is
|
|
|
|
|
a plist used as a communication channel. DEFAULT, CENTER and
|
|
|
|
|
QUOTE are, respectively, style to use when paragraph belongs to
|
|
|
|
|
no special environment, a center block, or a quote block."
|
2014-07-24 12:48:47 +00:00
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-odt--paragraph-style paragraph)
|
2014-07-24 12:48:47 +00:00
|
|
|
|
(quoted quote)
|
|
|
|
|
(centered center)
|
|
|
|
|
(otherwise default))
|
|
|
|
|
;; If PARAGRAPH is a leading paragraph in an item that has
|
|
|
|
|
;; a checkbox, splice checkbox and paragraph contents
|
|
|
|
|
;; together.
|
|
|
|
|
(concat (let ((parent (org-element-property :parent paragraph)))
|
|
|
|
|
(and (eq (org-element-type parent) 'item)
|
|
|
|
|
(not (org-export-get-previous-element paragraph info))
|
|
|
|
|
(org-odt--checkbox parent)))
|
|
|
|
|
contents)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-03-29 22:09:11 +00:00
|
|
|
|
(defun org-odt-paragraph (paragraph contents info)
|
|
|
|
|
"Transcode a PARAGRAPH element from Org to ODT.
|
|
|
|
|
CONTENTS is the contents of the paragraph, as a string. INFO is
|
|
|
|
|
the plist used as a communication channel."
|
|
|
|
|
(org-odt--format-paragraph
|
2014-07-25 09:20:49 +00:00
|
|
|
|
paragraph contents info
|
2013-03-29 22:09:11 +00:00
|
|
|
|
(or (org-element-property :style paragraph) "Text_20_body")
|
|
|
|
|
"OrgCenter"
|
|
|
|
|
"Quotations"))
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
;;;; Plain List
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-plain-list (plain-list contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a PLAIN-LIST element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is the contents of the list. INFO is a plist holding
|
|
|
|
|
contextual information."
|
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
2012-09-13 15:15:07 +00:00
|
|
|
|
(format "\n<text:list text:style-name=\"%s\" %s>\n%s</text:list>"
|
|
|
|
|
;; Choose style based on list type.
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-element-property :type plain-list)
|
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
2012-09-13 15:15:07 +00:00
|
|
|
|
(ordered "OrgNumberedList")
|
|
|
|
|
(unordered "OrgBulletedList")
|
|
|
|
|
(descriptive-1 "OrgDescriptionList")
|
|
|
|
|
(descriptive-2 "OrgDescriptionList"))
|
|
|
|
|
;; If top-level list, re-start numbering. Otherwise,
|
|
|
|
|
;; continue numbering.
|
|
|
|
|
(format "text:continue-numbering=\"%s\""
|
|
|
|
|
(let* ((parent (org-export-get-parent plain-list)))
|
|
|
|
|
(if (and parent (eq (org-element-type parent) 'item))
|
|
|
|
|
"true" "false")))
|
|
|
|
|
contents))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
;;;; Plain Text
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--encode-tabs-and-spaces (line)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(replace-regexp-in-string
|
2017-01-12 14:27:39 +00:00
|
|
|
|
"\\(\t\\| \\{2,\\}\\)"
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(lambda (s)
|
2017-01-12 14:27:39 +00:00
|
|
|
|
(if (string= s "\t") "<text:tab/>"
|
|
|
|
|
(format " <text:s text:c=\"%d\"/>" (1- (length s)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
line))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--encode-plain-text (text &optional no-whitespace-filling)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (pair '(("&" . "&") ("<" . "<") (">" . ">")))
|
|
|
|
|
(setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(if no-whitespace-filling text
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--encode-tabs-and-spaces text)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-plain-text (text info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a TEXT string from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
TEXT is the string to transcode. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2012-10-26 22:36:00 +00:00
|
|
|
|
(let ((output text))
|
|
|
|
|
;; Protect &, < and >.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(setq output (org-odt--encode-plain-text output t))
|
2012-10-26 22:36:00 +00:00
|
|
|
|
;; Handle smart quotes. Be sure to provide original string since
|
|
|
|
|
;; OUTPUT may have been modified.
|
2013-06-25 06:35:25 +00:00
|
|
|
|
(when (plist-get info :with-smart-quotes)
|
|
|
|
|
(setq output (org-export-activate-smart-quotes output :utf-8 info text)))
|
2012-10-26 22:36:00 +00:00
|
|
|
|
;; Convert special strings.
|
|
|
|
|
(when (plist-get info :with-special-strings)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (pair org-odt-special-string-regexps)
|
|
|
|
|
(setq output
|
|
|
|
|
(replace-regexp-in-string (car pair) (cdr pair) output t nil))))
|
2012-10-26 22:36:00 +00:00
|
|
|
|
;; Handle break preservation if required.
|
|
|
|
|
(when (plist-get info :preserve-breaks)
|
|
|
|
|
(setq output (replace-regexp-in-string
|
2013-10-23 16:49:03 +00:00
|
|
|
|
"\\(\\\\\\\\\\)?[ \t]*\n" "<text:line-break/>" output t)))
|
2012-10-26 22:36:00 +00:00
|
|
|
|
;; Return value.
|
|
|
|
|
output))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2012-04-29 00:11:22 +00:00
|
|
|
|
;;;; Planning
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-planning (planning contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a PLANNING element from Org to ODT.
|
2012-04-29 00:11:22 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"OrgPlanning"
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(concat
|
|
|
|
|
(let ((closed (org-element-property :closed planning)))
|
|
|
|
|
(when closed
|
|
|
|
|
(concat
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
2012-12-07 09:07:12 +00:00
|
|
|
|
"OrgClosedKeyword" org-closed-string)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-timestamp closed contents info))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((deadline (org-element-property :deadline planning)))
|
|
|
|
|
(when deadline
|
|
|
|
|
(concat
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
2012-12-07 09:07:12 +00:00
|
|
|
|
"OrgDeadlineKeyword" org-deadline-string)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-timestamp deadline contents info))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let ((scheduled (org-element-property :scheduled planning)))
|
|
|
|
|
(when scheduled
|
|
|
|
|
(concat
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
2012-12-07 09:07:12 +00:00
|
|
|
|
"OrgScheduledKeyword" org-deadline-string)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-timestamp scheduled contents info)))))))
|
2012-04-29 00:11:22 +00:00
|
|
|
|
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Property Drawer
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-property-drawer (_property-drawer contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a PROPERTY-DRAWER element from Org to ODT.
|
2013-09-25 19:27:29 +00:00
|
|
|
|
CONTENTS holds the contents of the drawer. INFO is a plist
|
|
|
|
|
holding contextual information."
|
|
|
|
|
(and (org-string-nw-p contents)
|
|
|
|
|
(format "<text:p text:style-name=\"OrgFixedWidthBlock\">%s</text:p>"
|
|
|
|
|
contents)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Quote Block
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-quote-block (_quote-block contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a QUOTE-BLOCK element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the block. INFO is a plist
|
|
|
|
|
holding contextual information."
|
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
2012-09-13 15:15:07 +00:00
|
|
|
|
contents)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Section
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-format-section (text style &optional name)
|
|
|
|
|
(let ((default-name (car (org-odt-add-automatic-style "Section"))))
|
2012-08-25 20:35:24 +00:00
|
|
|
|
(format "\n<text:section text:style-name=\"%s\" %s>\n%s\n</text:section>"
|
2012-07-19 16:45:23 +00:00
|
|
|
|
style
|
|
|
|
|
(format "text:name=\"%s\"" (or name default-name))
|
|
|
|
|
text)))
|
|
|
|
|
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-section (_section contents _info) ; FIXME
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a SECTION element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the section. INFO is a plist
|
|
|
|
|
holding contextual information."
|
|
|
|
|
contents)
|
|
|
|
|
|
|
|
|
|
;;;; Radio Target
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-radio-target (radio-target text info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a RADIO-TARGET object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
TEXT is the text of the target. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(org-odt--target text (org-export-get-reference radio-target info)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Special Block
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-special-block (special-block contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a SPECIAL-BLOCK element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the block. INFO is a plist
|
|
|
|
|
holding contextual information."
|
2014-09-17 17:38:06 +00:00
|
|
|
|
(let ((type (org-element-property :type special-block))
|
2014-09-08 09:57:27 +00:00
|
|
|
|
(attributes (org-export-read-attribute :attr_odt special-block)))
|
|
|
|
|
(cond
|
|
|
|
|
;; Annotation.
|
|
|
|
|
((string= type "annotation")
|
|
|
|
|
(let* ((author (or (plist-get attributes :author)
|
|
|
|
|
(let ((author (plist-get info :author)))
|
|
|
|
|
(and author (org-export-data author info)))))
|
|
|
|
|
(date (or (plist-get attributes :date)
|
|
|
|
|
;; FIXME: Is `car' right thing to do below?
|
|
|
|
|
(car (plist-get info :date)))))
|
|
|
|
|
(format "\n<text:p>%s</text:p>"
|
|
|
|
|
(format "<office:annotation>\n%s\n</office:annotation>"
|
|
|
|
|
(concat
|
|
|
|
|
(and author
|
|
|
|
|
(format "<dc:creator>%s</dc:creator>" author))
|
|
|
|
|
(and date
|
|
|
|
|
(format "<dc:date>%s</dc:date>"
|
|
|
|
|
(org-odt--format-timestamp date nil 'iso-date)))
|
|
|
|
|
contents)))))
|
|
|
|
|
;; Textbox.
|
|
|
|
|
((string= type "textbox")
|
|
|
|
|
(let ((width (plist-get attributes :width))
|
|
|
|
|
(height (plist-get attributes :height))
|
|
|
|
|
(style (plist-get attributes :style))
|
|
|
|
|
(extra (plist-get attributes :extra))
|
|
|
|
|
(anchor (plist-get attributes :anchor)))
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Text_20_body" (org-odt--textbox contents width height
|
org-e-html/org-e-odt: Changes to caption handling
* contrib/lisp/org-e-html.el (org-e-html--caption/label-string,
org-e-html--wrap-label, org-e-html--find-verb-separator): Remove
functions.
(org-e-html-center-block, org-e-html-drawer, org-e-html-dynamic-block,
org-e-html-fixed-width, org-e-html-inline-src-block,
org-e-html-inlinetask, org-e-html-latex-environment,
org-e-html-plain-list, org-e-html-quote-block,
org-e-html-special-block, org-e-html-verse-block): Apply functions
removal.
(org-e-html-example-block, org-e-html-src-block): Allow textarea. Use
new caption scheme.
(org-e-html-horizontal-rule): Cleanup.
(org-e-html-link--inline-image, org-e-html-table): Use new caption
scheme.
* contrib/lisp/org-e-odt.el (org-e-odt--wrap-label,
org-e-odt--caption/label-string): Remove functions.
(org-e-odt-format-label): Use new caption scheme.
(org-e-odt-center-block, org-e-odt-drawer, org-e-odt-dynamic-block,
org-e-odt-example-block, org-e-odt-fixed-width,
org-e-odt-horizontal-rule, org-e-odt-inlinetask,
org-e-odt-latex-environment, org-e-odt-plain-list,
org-e-odt-quote-block, org-e-odt-special-block,
org-e-odt-verse-block): Apply functions removal.
In e-html export, textareas are now possible with the following
attribute:
#+ATTR_HTML: :textarea t :width 80 :height 10
:width and :height keywords are optional.
2012-09-13 15:15:07 +00:00
|
|
|
|
style extra anchor))))
|
2014-09-08 09:57:27 +00:00
|
|
|
|
(t contents))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Src Block
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-hfy-face-to-css (fn)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Create custom style for face FN.
|
2013-11-17 08:12:41 +00:00
|
|
|
|
When FN is the default face, use its foreground and background
|
2012-07-19 16:45:23 +00:00
|
|
|
|
properties to create \"OrgSrcBlock\" paragraph style. Otherwise
|
2013-11-17 08:12:41 +00:00
|
|
|
|
use its color attribute to create a character style whose name
|
2012-07-19 16:45:23 +00:00
|
|
|
|
is obtained from FN. Currently all attributes of FN other than
|
|
|
|
|
color are ignored.
|
|
|
|
|
|
|
|
|
|
The style name for a face FN is derived using the following
|
|
|
|
|
operations on the face name in that order - de-dash, CamelCase
|
|
|
|
|
and prefix with \"OrgSrc\". For example,
|
|
|
|
|
`font-lock-function-name-face' is associated with
|
|
|
|
|
\"OrgSrcFontLockFunctionNameFace\"."
|
|
|
|
|
(let* ((css-list (hfy-face-to-style fn))
|
Backport changes from Emacs revs 115081 and 115082
2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca>
Address some byte-compiler warnings.
* ob-abc.el (org-babel-expand-body:abc): Use dolist.
(org-babel-execute:abc): Fix regexp quoting.
* ob-calc.el (org--var-syms): Rename from `var-syms'.
* ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding.
* ob-table.el (sbe): Move debug declaration.
* org-clock.el (org--msg-extra): Rename from `msg-extra'.
* org.el (org-version): Avoid var name starting with _.
(org-inhibit-startup, org-called-with-limited-levels)
(org-link-search-inhibit-query, org-time-was-given)
(org-end-time-was-given, org-def, org-defdecode, org-with-time):
* org-colview.el (org-agenda-overriding-columns-format):
* org-agenda.el (org-agenda-multi, org-depend-tag-blocked)
(org-agenda-show-log-scoped):
* ob-python.el (py-which-bufname, python-shell-buffer-name):
* ob-haskell.el (org-export-copy-to-kill-ring):
* ob-exp.el (org-link-search-inhibit-query):
* ob-R.el (ess-eval-visibly-p):
* ob-core.el (org-src-window-setup): Declare before use.
(org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'.
* ox-odt.el (org-odt-hfy-face-to-css):
* org-src.el (org-src-associate-babel-session, org-src-get-lang-mode):
* org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex)
(org-bibtex-check):
* ob-tangle.el (org-babel-tangle, org-babel-spec-to-string)
(org-babel-tangle-single-block, org-babel-tangle-comment-links):
* ob-table.el (sbe):
* ob-sqlite.el (org-babel-sqlite-expand-vars):
* ob-sql.el (org-babel-sql-expand-vars):
* ob-shen.el (org-babel-execute:shen):
* ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate):
* ob-scala.el (org-babel-scala-evaluate):
* ob-ruby.el (org-babel-ruby-table-or-string)
(org-babel-ruby-evaluate):
* ob-python.el (org-babel-python-table-or-string)
(org-babel-python-evaluate-external-process)
(org-babel-python-evaluate-session):
* ob-picolisp.el (org-babel-execute:picolisp):
* ob-perl.el (org-babel-perl-evaluate):
* ob-maxima.el (org-babel-execute:maxima):
* ob-lisp.el (org-babel-execute:lisp):
* ob-java.el (org-babel-execute:java):
* ob-io.el (org-babel-io-evaluate):
* ob-haskell.el (org-babel-execute:haskell):
* ob-fortran.el (org-babel-execute:fortran):
* ob-exp.el (org-babel-exp-code):
* ob-emacs-lisp.el (org-babel-execute:emacs-lisp):
* ob-ditaa.el (org-babel-execute:ditaa):
* ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash)
(org-babel-parse-header-arguments, org-babel-reassemble-table)
(org-babel-goto-src-block-head, org-babel-mark-block)
(org-babel-expand-noweb-references, org-babel-script-escape)
(org-babel-process-file-name):
* ob-clojure.el (org-babel-execute:clojure):
* ob-calc.el (org-babel-execute:calc):
* ob-awk.el (org-babel-execute:awk):
* ob-abc.el (org-babel-execute:abc):
* ob-R.el (org-babel-expand-body:R):
* ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...).
2013-11-12 Glenn Morris <rgm@gnu.org>
* ox-html.el (org-html-scripts): Add 2013 to copyright years.
(org-html-infojs-template): Copyright holder to FSF.
2013-11-12 19:57:31 +00:00
|
|
|
|
(style-name (concat "OrgSrc"
|
|
|
|
|
(mapconcat
|
|
|
|
|
'capitalize (split-string
|
|
|
|
|
(hfy-face-or-def-to-name fn) "-")
|
|
|
|
|
"")))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(color-val (cdr (assoc "color" css-list)))
|
|
|
|
|
(background-color-val (cdr (assoc "background" css-list)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(style (and org-odt-create-custom-styles-for-srcblocks
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(cond
|
|
|
|
|
((eq fn 'default)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(format org-odt-src-block-paragraph-format
|
2012-07-19 16:45:23 +00:00
|
|
|
|
background-color-val color-val))
|
|
|
|
|
(t
|
|
|
|
|
(format
|
|
|
|
|
"
|
|
|
|
|
<style:style style:name=\"%s\" style:family=\"text\">
|
|
|
|
|
<style:text-properties fo:color=\"%s\"/>
|
|
|
|
|
</style:style>" style-name color-val))))))
|
|
|
|
|
(cons style-name style)))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-htmlfontify-string (line)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(let* ((hfy-html-quote-regex "\\([<\"&> \t]\\)")
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(hfy-html-quote-map '(("\"" """)
|
|
|
|
|
("<" "<")
|
|
|
|
|
("&" "&")
|
|
|
|
|
(">" ">")
|
|
|
|
|
(" " "<text:s/>")
|
2015-10-31 23:58:57 +00:00
|
|
|
|
("\t" "<text:tab/>")))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(hfy-face-to-css 'org-odt-hfy-face-to-css)
|
2015-04-06 06:40:54 +00:00
|
|
|
|
(hfy-optimizations-1 (copy-sequence hfy-optimizations))
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(hfy-optimizations (cl-pushnew 'body-text-only hfy-optimizations-1))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(hfy-begin-span-handler
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(lambda (style _text-block _text-id _text-begins-block-p)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(insert (format "<text:span text:style-name=\"%s\">" style))))
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(hfy-end-span-handler (lambda () (insert "</text:span>"))))
|
2016-06-23 13:20:32 +00:00
|
|
|
|
(with-no-warnings (htmlfontify-string line))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-do-format-code
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(code info &optional lang refs retain-labels num-start)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let* ((lang (or (assoc-default lang org-src-lang-modes) lang))
|
|
|
|
|
(lang-mode (and lang (intern (format "%s-mode" lang))))
|
|
|
|
|
(code-lines (org-split-string code "\n"))
|
|
|
|
|
(code-length (length code-lines))
|
|
|
|
|
(use-htmlfontify-p (and (functionp lang-mode)
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(plist-get info :odt-fontify-srcblocks)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(require 'htmlfontify nil t)
|
|
|
|
|
(fboundp 'htmlfontify-string)))
|
|
|
|
|
(code (if (not use-htmlfontify-p) code
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert code)
|
|
|
|
|
(funcall lang-mode)
|
2016-01-29 05:07:33 +00:00
|
|
|
|
(org-font-lock-ensure)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(buffer-string))))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(fontifier (if use-htmlfontify-p 'org-odt-htmlfontify-string
|
|
|
|
|
'org-odt--encode-plain-text))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(par-style (if use-htmlfontify-p "OrgSrcBlock"
|
|
|
|
|
"OrgFixedWidthBlock"))
|
|
|
|
|
(i 0))
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert (= code-length (length (org-split-string code "\n"))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(setq code
|
|
|
|
|
(org-export-format-code
|
|
|
|
|
code
|
|
|
|
|
(lambda (loc line-num ref)
|
|
|
|
|
(setq par-style
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(concat par-style (and (= (cl-incf i) code-length)
|
|
|
|
|
"LastLine")))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
(setq loc (concat loc (and ref retain-labels (format " (%s)" ref))))
|
|
|
|
|
(setq loc (funcall fontifier loc))
|
|
|
|
|
(when ref
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(setq loc (org-odt--target loc (concat "coderef-" ref))))
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert par-style)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(setq loc (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
par-style loc))
|
|
|
|
|
(if (not line-num) loc
|
|
|
|
|
(format "\n<text:list-item>%s\n</text:list-item>" loc)))
|
|
|
|
|
num-start refs))
|
|
|
|
|
(cond
|
|
|
|
|
((not num-start) code)
|
|
|
|
|
((= num-start 0)
|
|
|
|
|
(format
|
|
|
|
|
"\n<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>%s</text:list>"
|
|
|
|
|
" text:continue-numbering=\"false\"" code))
|
|
|
|
|
(t
|
|
|
|
|
(format
|
|
|
|
|
"\n<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>%s</text:list>"
|
|
|
|
|
" text:continue-numbering=\"true\"" code)))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-format-code (element info)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(let* ((lang (org-element-property :language element))
|
|
|
|
|
;; Extract code and references.
|
|
|
|
|
(code-info (org-export-unravel-code element))
|
|
|
|
|
(code (car code-info))
|
|
|
|
|
(refs (cdr code-info))
|
2018-09-20 09:23:49 +00:00
|
|
|
|
;; Does the source block contain labels?
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(retain-labels (org-element-property :retain-labels element))
|
|
|
|
|
;; Does it have line numbers?
|
2016-05-16 14:58:01 +00:00
|
|
|
|
(num-start (org-export-get-loc element info)))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(org-odt-do-format-code code info lang refs retain-labels num-start)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-src-block (src-block _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a SRC-BLOCK element from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS holds the contents of the item. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(let* ((attributes (org-export-read-attribute :attr_odt src-block))
|
|
|
|
|
(caption (car (org-odt-format-label src-block info 'definition))))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(concat
|
|
|
|
|
(and caption
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Listing" caption))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let ((--src-block (org-odt-format-code src-block info)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(if (not (plist-get attributes :textbox)) --src-block
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Text_20_body"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--textbox --src-block nil nil nil)))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Statistics Cookie
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-statistics-cookie (statistics-cookie _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a STATISTICS-COOKIE object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual information."
|
|
|
|
|
(let ((cookie-value (org-element-property :value statistics-cookie)))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgCode" cookie-value)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
;;;; Strike-Through
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-strike-through (_strike-through contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode STRIKE-THROUGH from Org to ODT.
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
CONTENTS is the text with strike-through markup. INFO is a plist
|
|
|
|
|
holding contextual information."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"Strikethrough" contents))
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Subscript
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-subscript (_subscript contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a SUBSCRIPT object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is the contents of the object. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgSubscript" contents))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Superscript
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-superscript (_superscript contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a SUPERSCRIPT object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is the contents of the object. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgSuperscript" contents))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;;;; Table Cell
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-table-style-spec (element info)
|
org-export: Rewrite topology functions
* contrib/lisp/org-export.el (org-export-get-genealogy,
org-export-get-parent, org-export-get-parent-headline,
org-export-get-parent-table): Rewrite function to use :parent
property. Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code. Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
org-e-ascii--unique-links, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
change.
* contrib/lisp/org-e-html.el (org-e-html-link,
org-e-html-link--inline-image): Use new function and apply signature
change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
org-e-odt-format-label, org-e-odt-link--inline-image): Use new
function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
2012-06-08 19:00:47 +00:00
|
|
|
|
(let* ((table (org-export-get-parent-table element))
|
2012-06-17 09:01:04 +00:00
|
|
|
|
(table-attributes (org-export-read-attribute :attr_odt table))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(table-style (plist-get table-attributes :style)))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(assoc table-style (plist-get info :odt-table-styles))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-get-table-cell-styles (table-cell info)
|
2012-04-22 05:09:19 +00:00
|
|
|
|
"Retrieve styles applicable to a table cell.
|
|
|
|
|
R and C are (zero-based) row and column numbers of the table
|
2013-01-27 22:11:34 +00:00
|
|
|
|
cell. STYLE-SPEC is an entry in `org-odt-table-styles'
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
applicable to the current table. It is nil if the table is not
|
2012-04-22 05:09:19 +00:00
|
|
|
|
associated with any style attributes.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-04-22 05:09:19 +00:00
|
|
|
|
Return a cons of (TABLE-CELL-STYLE-NAME . PARAGRAPH-STYLE-NAME).
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-04-22 05:09:19 +00:00
|
|
|
|
When STYLE-SPEC is nil, style the table cell the conventional way
|
|
|
|
|
- choose cell borders based on row and column groupings and
|
|
|
|
|
choose paragraph alignment based on `org-col-cookies' text
|
|
|
|
|
property. See also
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-get-paragraph-style-cookie-for-table-cell'.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-04-22 05:09:19 +00:00
|
|
|
|
When STYLE-SPEC is non-nil, ignore the above cookie and return
|
|
|
|
|
styles congruent with the ODF-1.2 specification."
|
|
|
|
|
(let* ((table-cell-address (org-export-table-cell-address table-cell info))
|
|
|
|
|
(r (car table-cell-address)) (c (cdr table-cell-address))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(style-spec (org-odt-table-style-spec table-cell info))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(table-dimensions (org-export-table-dimensions
|
org-export: Rewrite topology functions
* contrib/lisp/org-export.el (org-export-get-genealogy,
org-export-get-parent, org-export-get-parent-headline,
org-export-get-parent-table): Rewrite function to use :parent
property. Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code. Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
org-e-ascii--unique-links, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
change.
* contrib/lisp/org-e-html.el (org-e-html-link,
org-e-html-link--inline-image): Use new function and apply signature
change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
org-e-odt-format-label, org-e-odt-link--inline-image): Use new
function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
2012-06-08 19:00:47 +00:00
|
|
|
|
(org-export-get-parent-table table-cell)
|
2012-04-22 05:09:19 +00:00
|
|
|
|
info)))
|
|
|
|
|
(when style-spec
|
|
|
|
|
;; LibreOffice - particularly the Writer - honors neither table
|
|
|
|
|
;; templates nor custom table-cell styles. Inorder to retain
|
2019-11-12 13:44:05 +00:00
|
|
|
|
;; interoperability with LibreOffice, only automatic styles are
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;; used for styling of table-cells. The current implementation is
|
|
|
|
|
;; congruent with ODF-1.2 specification and hence is
|
|
|
|
|
;; future-compatible.
|
|
|
|
|
|
|
|
|
|
;; Additional Note: LibreOffice's AutoFormat facility for tables -
|
|
|
|
|
;; which recognizes as many as 16 different cell types - is much
|
|
|
|
|
;; richer. Unfortunately it is NOT amenable to easy configuration
|
|
|
|
|
;; by hand.
|
|
|
|
|
(let* ((template-name (nth 1 style-spec))
|
|
|
|
|
(cell-style-selectors (nth 2 style-spec))
|
|
|
|
|
(cell-type
|
|
|
|
|
(cond
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-first-column-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= c 0)) "FirstColumn")
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-last-column-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= (1+ c) (cdr table-dimensions)))
|
|
|
|
|
"LastColumn")
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-first-row-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= r 0)) "FirstRow")
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-last-row-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= (1+ r) (car table-dimensions)))
|
|
|
|
|
"LastRow")
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-banding-rows-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= (% r 2) 1)) "EvenRow")
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-banding-rows-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= (% r 2) 0)) "OddRow")
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-banding-columns-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= (% c 2) 1)) "EvenColumn")
|
2016-09-23 10:18:24 +00:00
|
|
|
|
((and (cdr (assq 'use-banding-columns-styles cell-style-selectors))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(= (% c 2) 0)) "OddColumn")
|
|
|
|
|
(t ""))))
|
|
|
|
|
(concat template-name cell-type)))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-table-cell (table-cell contents info)
|
2012-04-22 05:09:19 +00:00
|
|
|
|
"Transcode a TABLE-CELL element from Org to ODT.
|
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
2012-04-22 07:58:19 +00:00
|
|
|
|
(let* ((table-cell-address (org-export-table-cell-address table-cell info))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(r (car table-cell-address))
|
|
|
|
|
(c (cdr table-cell-address))
|
|
|
|
|
(horiz-span (or (org-export-table-cell-width table-cell info) 0))
|
org-export: Rewrite topology functions
* contrib/lisp/org-export.el (org-export-get-genealogy,
org-export-get-parent, org-export-get-parent-headline,
org-export-get-parent-table): Rewrite function to use :parent
property. Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code. Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
org-e-ascii--unique-links, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
change.
* contrib/lisp/org-e-html.el (org-e-html-link,
org-e-html-link--inline-image): Use new function and apply signature
change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
org-e-odt-format-label, org-e-odt-link--inline-image): Use new
function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
2012-06-08 19:00:47 +00:00
|
|
|
|
(table-row (org-export-get-parent table-cell))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(custom-style-prefix (org-odt-get-table-cell-styles
|
2012-04-22 05:09:19 +00:00
|
|
|
|
table-cell info))
|
|
|
|
|
(paragraph-style
|
|
|
|
|
(or
|
|
|
|
|
(and custom-style-prefix
|
|
|
|
|
(format "%sTableParagraph" custom-style-prefix))
|
|
|
|
|
(concat
|
|
|
|
|
(cond
|
|
|
|
|
((and (= 1 (org-export-table-row-group table-row info))
|
|
|
|
|
(org-export-table-has-header-p
|
org-export: Rewrite topology functions
* contrib/lisp/org-export.el (org-export-get-genealogy,
org-export-get-parent, org-export-get-parent-headline,
org-export-get-parent-table): Rewrite function to use :parent
property. Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code. Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
org-e-ascii--unique-links, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
change.
* contrib/lisp/org-e-html.el (org-e-html-link,
org-e-html-link--inline-image): Use new function and apply signature
change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
org-e-odt-format-label, org-e-odt-link--inline-image): Use new
function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
2012-06-08 19:00:47 +00:00
|
|
|
|
(org-export-get-parent-table table-row) info))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
"OrgTableHeading")
|
org-export: Rewrite topology functions
* contrib/lisp/org-export.el (org-export-get-genealogy,
org-export-get-parent, org-export-get-parent-headline,
org-export-get-parent-table): Rewrite function to use :parent
property. Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code. Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
org-e-ascii--unique-links, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
change.
* contrib/lisp/org-e-html.el (org-e-html-link,
org-e-html-link--inline-image): Use new function and apply signature
change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
org-e-odt-format-label, org-e-odt-link--inline-image): Use new
function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
2012-06-08 19:00:47 +00:00
|
|
|
|
((let* ((table (org-export-get-parent-table table-cell))
|
2012-06-17 09:01:04 +00:00
|
|
|
|
(table-attrs (org-export-read-attribute :attr_odt table))
|
2013-03-08 23:58:31 +00:00
|
|
|
|
(table-header-columns
|
|
|
|
|
(let ((cols (plist-get table-attrs :header-columns)))
|
|
|
|
|
(and cols (read cols)))))
|
2012-05-26 18:20:38 +00:00
|
|
|
|
(<= c (cond ((wholenump table-header-columns)
|
|
|
|
|
(- table-header-columns 1))
|
|
|
|
|
(table-header-columns 0)
|
|
|
|
|
(t -1))))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
"OrgTableHeading")
|
|
|
|
|
(t "OrgTableContents"))
|
|
|
|
|
(capitalize (symbol-name (org-export-table-cell-alignment
|
|
|
|
|
table-cell info))))))
|
|
|
|
|
(cell-style-name
|
|
|
|
|
(or
|
|
|
|
|
(and custom-style-prefix (format "%sTableCell"
|
|
|
|
|
custom-style-prefix))
|
|
|
|
|
(concat
|
|
|
|
|
"OrgTblCell"
|
|
|
|
|
(when (or (org-export-table-row-starts-rowgroup-p table-row info)
|
|
|
|
|
(zerop r)) "T")
|
|
|
|
|
(when (org-export-table-row-ends-rowgroup-p table-row info) "B")
|
|
|
|
|
(when (and (org-export-table-cell-starts-colgroup-p table-cell info)
|
|
|
|
|
(not (zerop c)) ) "L"))))
|
|
|
|
|
(cell-attributes
|
|
|
|
|
(concat
|
|
|
|
|
(format " table:style-name=\"%s\"" cell-style-name)
|
|
|
|
|
(and (> horiz-span 0)
|
|
|
|
|
(format " table:number-columns-spanned=\"%d\""
|
|
|
|
|
(1+ horiz-span))))))
|
2012-04-22 07:58:19 +00:00
|
|
|
|
(unless contents (setq contents ""))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(concat
|
2016-07-25 14:34:48 +00:00
|
|
|
|
(cl-assert paragraph-style)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "\n<table:table-cell%s>\n%s\n</table:table-cell>"
|
|
|
|
|
cell-attributes
|
2012-09-04 08:45:14 +00:00
|
|
|
|
(let ((table-cell-contents (org-element-contents table-cell)))
|
2016-10-25 11:13:26 +00:00
|
|
|
|
(if (eq (org-element-class (car table-cell-contents)) 'element)
|
2012-09-04 08:45:14 +00:00
|
|
|
|
contents
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
paragraph-style contents))))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(let (s)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dotimes (_ horiz-span s)
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(setq s (concat s "\n<table:covered-table-cell/>"))))
|
|
|
|
|
"\n")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Table Row
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-table-row (table-row contents info)
|
2012-04-22 05:09:19 +00:00
|
|
|
|
"Transcode a TABLE-ROW element from Org to ODT.
|
|
|
|
|
CONTENTS is the contents of the row. INFO is a plist used as a
|
|
|
|
|
communication channel."
|
|
|
|
|
;; Rules are ignored since table separators are deduced from
|
|
|
|
|
;; borders of the current row.
|
|
|
|
|
(when (eq (org-element-property :type table-row) 'standard)
|
|
|
|
|
(let* ((rowgroup-tags
|
|
|
|
|
(if (and (= 1 (org-export-table-row-group table-row info))
|
|
|
|
|
(org-export-table-has-header-p
|
org-export: Rewrite topology functions
* contrib/lisp/org-export.el (org-export-get-genealogy,
org-export-get-parent, org-export-get-parent-headline,
org-export-get-parent-table): Rewrite function to use :parent
property. Remove communication channel from signature.
(org-export-get-parent-element): Rename from
`org-export-get-parent-paragraph'.
(org-export-data, org-export-table-row-is-special-p)
org-export-table-row-group, org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p, org-export-table-cell-address,
org-export-first-sibling-p, org-export-last-sibling-p,
org-export-resolve-fuzzy-link, org-export-get-ordinal): Apply
signature change.
(org-export--skip-p, org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders):
Refactor code. Apply signature change.
* contrib/lisp/org-e-ascii.el (org-e-ascii--current-text-width,
org-e-ascii--unique-links, org-e-ascii-inlinetask,
org-e-ascii-item, org-e-ascii-paragraph, org-e-ascii-quote-section,
org-e-ascii-section, org-e-ascii--table-cell-width): Apply signature
change.
* contrib/lisp/org-e-html.el (org-e-html-link,
org-e-html-link--inline-image): Use new function and apply signature
change.
(org-e-html-item, org-e-html-standalone-image-p, org-e-html-paragraph,
org-e-html-section, org-e-html-table-cell, org-e-html-table-row,
org-e-html-footnote-reference): Apply signature change.
* contrib/lisp/org-e-latex.el (org-e-latex-link--inline-image): Use
new function and apply signature change.
(org-e-latex-footnote-reference, org-e-latex-item,
org-e-latex-table-cell, org-e-latex-table-row): Apply signature
change.
* contrib/lisp/org-e-odt.el (org-e-odt-format-formula,
org-e-odt-format-label, org-e-odt-link--inline-image): Use new
function and apply signature change.
(org-e-odt-item, org-e-odt-standalone-image-p, org-e-odt-paragraph,
org-e-odt-plain-list, org-e-odt-table-style-spec,
org-e-odt-get-table-cell-styles, org-e-odt-table-cell,
org-e-odt-table-row, org-e-odt-table, org-e-odt-footnote-reference,
org-e-odt-enumerate-element): Apply signature change.
2012-06-08 19:00:47 +00:00
|
|
|
|
(org-export-get-parent-table table-row) info))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;; If the row belongs to the first rowgroup and the
|
|
|
|
|
;; table has more than one row groups, then this row
|
|
|
|
|
;; belongs to the header row group.
|
|
|
|
|
'("\n<table:table-header-rows>" . "\n</table:table-header-rows>")
|
|
|
|
|
;; Otherwise, it belongs to non-header row group.
|
|
|
|
|
'("\n<table:table-rows>" . "\n</table:table-rows>"))))
|
|
|
|
|
(concat
|
|
|
|
|
;; Does this row begin a rowgroup?
|
|
|
|
|
(when (org-export-table-row-starts-rowgroup-p table-row info)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(car rowgroup-tags))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;; Actual table row
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "\n<table:table-row>\n%s\n</table:table-row>" contents)
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;; Does this row end a rowgroup?
|
|
|
|
|
(when (org-export-table-row-ends-rowgroup-p table-row info)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(cdr rowgroup-tags))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-04-22 05:09:19 +00:00
|
|
|
|
|
|
|
|
|
;;;; Table
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-table-first-row-data-cells (table info)
|
2012-04-22 07:58:19 +00:00
|
|
|
|
(let ((table-row
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-element-map table 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(unless (eq (org-element-property :type row) 'rule) row))
|
|
|
|
|
info 'first-match))
|
2012-04-22 07:58:19 +00:00
|
|
|
|
(special-column-p (org-export-table-has-special-column-p table)))
|
|
|
|
|
(if (not special-column-p) (org-element-contents table-row)
|
|
|
|
|
(cdr (org-element-contents table-row)))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt--table (table contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a TABLE element from Org to ODT.
|
2012-05-23 21:21:25 +00:00
|
|
|
|
CONTENTS is the contents of the table. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-element-property :type table)
|
2012-06-03 11:55:37 +00:00
|
|
|
|
;; Case 1: table.el doesn't support export to OD format. Strip
|
|
|
|
|
;; such tables from export.
|
|
|
|
|
(table.el
|
|
|
|
|
(prog1 nil
|
|
|
|
|
(message
|
|
|
|
|
(concat
|
2013-01-27 22:11:34 +00:00
|
|
|
|
"(ox-odt): Found table.el-type table in the source Org file."
|
2012-06-03 11:55:37 +00:00
|
|
|
|
" table.el doesn't support export to ODT format."
|
|
|
|
|
" Stripping the table from export."))))
|
|
|
|
|
;; Case 2: Native Org tables.
|
|
|
|
|
(otherwise
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((captions (org-odt-format-label table info 'definition))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(caption (car captions)) (short-caption (cdr captions))
|
2012-06-17 09:01:04 +00:00
|
|
|
|
(attributes (org-export-read-attribute :attr_odt table))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(custom-table-style (nth 1 (org-odt-table-style-spec table info)))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(table-column-specs
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(lambda (table info)
|
|
|
|
|
(let* ((table-style (or custom-table-style "OrgTable"))
|
|
|
|
|
(column-style (format "%sColumn" table-style)))
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (table-cell)
|
|
|
|
|
(let ((width (1+ (or (org-export-table-cell-width
|
|
|
|
|
table-cell info) 0)))
|
|
|
|
|
(s (format
|
|
|
|
|
"\n<table:table-column table:style-name=\"%s\"/>"
|
|
|
|
|
column-style))
|
|
|
|
|
out)
|
|
|
|
|
(dotimes (_ width out) (setq out (concat s out)))))
|
|
|
|
|
(org-odt-table-first-row-data-cells table info) "\n")))))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(concat
|
|
|
|
|
;; caption.
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(when caption
|
|
|
|
|
(format "\n<text:p text:style-name=\"%s\">%s</text:p>"
|
|
|
|
|
"Table" caption))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;; begin table.
|
|
|
|
|
(let* ((automatic-name
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-add-automatic-style "Table" attributes)))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
(format
|
2012-12-17 07:31:10 +00:00
|
|
|
|
"\n<table:table table:style-name=\"%s\"%s>"
|
|
|
|
|
(or custom-table-style (cdr automatic-name) "OrgTable")
|
|
|
|
|
(concat (when short-caption
|
|
|
|
|
(format " table:name=\"%s\"" short-caption)))))
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;; column specification.
|
2012-06-03 11:55:37 +00:00
|
|
|
|
(funcall table-column-specs table info)
|
2012-04-22 05:09:19 +00:00
|
|
|
|
;; actual contents.
|
|
|
|
|
"\n" contents
|
|
|
|
|
;; end table.
|
|
|
|
|
"</table:table>")))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-table (table contents info)
|
2012-06-03 11:55:37 +00:00
|
|
|
|
"Transcode a TABLE element from Org to ODT.
|
|
|
|
|
CONTENTS is the contents of the table. INFO is a plist holding
|
2012-08-25 20:35:24 +00:00
|
|
|
|
contextual information.
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
Use `org-odt--table' to typeset the table. Handle details
|
2012-08-25 20:35:24 +00:00
|
|
|
|
pertaining to indentation here."
|
2012-12-09 08:35:07 +00:00
|
|
|
|
(let* ((--element-preceded-by-table-p
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(lambda (element info)
|
|
|
|
|
(cl-loop for el in (org-export-get-previous-element element info t)
|
|
|
|
|
thereis (eq (org-element-type el) 'table))))
|
2012-06-05 14:01:54 +00:00
|
|
|
|
(--walk-list-genealogy-and-collect-tags
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(lambda (table info)
|
|
|
|
|
(let* ((genealogy (org-element-lineage table))
|
|
|
|
|
(list-genealogy
|
|
|
|
|
(when (eq (org-element-type (car genealogy)) 'item)
|
|
|
|
|
(cl-loop for el in genealogy
|
|
|
|
|
when (memq (org-element-type el)
|
|
|
|
|
'(item plain-list))
|
|
|
|
|
collect el)))
|
|
|
|
|
(llh-genealogy
|
|
|
|
|
(apply #'nconc
|
|
|
|
|
(cl-loop
|
|
|
|
|
for el in genealogy
|
|
|
|
|
when (and (eq (org-element-type el) 'headline)
|
|
|
|
|
(org-export-low-level-p el info))
|
|
|
|
|
collect
|
|
|
|
|
(list el
|
|
|
|
|
(assq 'headline
|
|
|
|
|
(org-element-contents
|
|
|
|
|
(org-export-get-parent el)))))))
|
|
|
|
|
parent-list)
|
|
|
|
|
(nconc
|
|
|
|
|
;; Handle list genealogy.
|
|
|
|
|
(cl-loop
|
|
|
|
|
for el in list-genealogy collect
|
|
|
|
|
(cl-case (org-element-type el)
|
|
|
|
|
(plain-list
|
|
|
|
|
(setq parent-list el)
|
|
|
|
|
(cons "</text:list>"
|
|
|
|
|
(format "\n<text:list text:style-name=\"%s\" %s>"
|
|
|
|
|
(cl-case (org-element-property :type el)
|
|
|
|
|
(ordered "OrgNumberedList")
|
|
|
|
|
(unordered "OrgBulletedList")
|
|
|
|
|
(descriptive-1 "OrgDescriptionList")
|
|
|
|
|
(descriptive-2 "OrgDescriptionList"))
|
|
|
|
|
"text:continue-numbering=\"true\"")))
|
|
|
|
|
(item
|
|
|
|
|
(cond
|
|
|
|
|
((not parent-list)
|
|
|
|
|
(if (funcall --element-preceded-by-table-p table info)
|
|
|
|
|
'("</text:list-header>" . "<text:list-header>")
|
|
|
|
|
'("</text:list-item>" . "<text:list-header>")))
|
|
|
|
|
((funcall --element-preceded-by-table-p
|
|
|
|
|
parent-list info)
|
|
|
|
|
'("</text:list-header>" . "<text:list-header>"))
|
|
|
|
|
(t '("</text:list-item>" . "<text:list-item>"))))))
|
|
|
|
|
;; Handle low-level headlines.
|
|
|
|
|
(cl-loop for el in llh-genealogy
|
|
|
|
|
with step = 'item collect
|
|
|
|
|
(cl-case step
|
|
|
|
|
(plain-list
|
|
|
|
|
(setq step 'item) ; Flip-flop
|
|
|
|
|
(setq parent-list el)
|
|
|
|
|
(cons "</text:list>"
|
|
|
|
|
(format "\n<text:list text:style-name=\"%s\" %s>"
|
|
|
|
|
(if (org-export-numbered-headline-p
|
|
|
|
|
el info)
|
|
|
|
|
"OrgNumberedList"
|
|
|
|
|
"OrgBulletedList")
|
|
|
|
|
"text:continue-numbering=\"true\"")))
|
|
|
|
|
(item
|
|
|
|
|
(setq step 'plain-list) ; Flip-flop
|
|
|
|
|
(cond
|
|
|
|
|
((not parent-list)
|
|
|
|
|
(if (funcall --element-preceded-by-table-p table info)
|
|
|
|
|
'("</text:list-header>" . "<text:list-header>")
|
|
|
|
|
'("</text:list-item>" . "<text:list-header>")))
|
|
|
|
|
((let ((section? (org-export-get-previous-element
|
|
|
|
|
parent-list info)))
|
|
|
|
|
(and section?
|
|
|
|
|
(eq (org-element-type section?) 'section)
|
|
|
|
|
(assq 'table (org-element-contents section?))))
|
|
|
|
|
'("</text:list-header>" . "<text:list-header>"))
|
|
|
|
|
(t
|
|
|
|
|
'("</text:list-item>" . "<text:list-item>"))))))))))
|
2012-06-05 14:01:54 +00:00
|
|
|
|
(close-open-tags (funcall --walk-list-genealogy-and-collect-tags
|
|
|
|
|
table info)))
|
|
|
|
|
;; OpenDocument schema does not permit table to occur within a
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; list item.
|
|
|
|
|
|
|
|
|
|
;; One solution - the easiest and lightweight, in terms of
|
|
|
|
|
;; implementation - is to put the table in an indented text box
|
|
|
|
|
;; and make the text box part of the list-item. Unfortunately if
|
|
|
|
|
;; the table is big and spans multiple pages, the text box could
|
|
|
|
|
;; overflow. In this case, the following attribute will come
|
|
|
|
|
;; handy.
|
|
|
|
|
|
|
|
|
|
;; ,---- From OpenDocument-v1.1.pdf
|
|
|
|
|
;; | 15.27.28 Overflow behavior
|
|
|
|
|
;; |
|
|
|
|
|
;; | For text boxes contained within text document, the
|
|
|
|
|
;; | style:overflow-behavior property specifies the behavior of text
|
|
|
|
|
;; | boxes where the containing text does not fit into the text
|
|
|
|
|
;; | box.
|
|
|
|
|
;; |
|
|
|
|
|
;; | If the attribute's value is clip, the text that does not fit
|
|
|
|
|
;; | into the text box is not displayed.
|
|
|
|
|
;; |
|
|
|
|
|
;; | If the attribute value is auto-create-new-frame, a new frame
|
|
|
|
|
;; | will be created on the next page, with the same position and
|
|
|
|
|
;; | dimensions of the original frame.
|
|
|
|
|
;; |
|
|
|
|
|
;; | If the style:overflow-behavior property's value is
|
|
|
|
|
;; | auto-create-new-frame and the text box has a minimum width or
|
|
|
|
|
;; | height specified, then the text box will grow until the page
|
|
|
|
|
;; | bounds are reached before a new frame is created.
|
|
|
|
|
;; `----
|
|
|
|
|
|
|
|
|
|
;; Unfortunately, LibreOffice-3.4.6 doesn't honor
|
|
|
|
|
;; auto-create-new-frame property and always resorts to clipping
|
|
|
|
|
;; the text box. This results in table being truncated.
|
|
|
|
|
|
|
|
|
|
;; So we solve the problem the hard (and fun) way using list
|
|
|
|
|
;; continuations.
|
|
|
|
|
|
|
|
|
|
;; The problem only becomes more interesting if you take in to
|
|
|
|
|
;; account the following facts:
|
|
|
|
|
;;
|
|
|
|
|
;; - Description lists are simulated as plain lists.
|
|
|
|
|
;; - Low-level headlines can be listified.
|
2016-10-11 16:00:08 +00:00
|
|
|
|
;; - In Org mode, a table can occur not only as a regular list
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; item, but also within description lists and low-level
|
|
|
|
|
;; headlines.
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; See `org-odt-translate-description-lists' and
|
|
|
|
|
;; `org-odt-translate-low-level-headlines' for how this is
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; tackled.
|
|
|
|
|
|
2012-06-05 14:01:54 +00:00
|
|
|
|
(concat "\n"
|
|
|
|
|
;; Discontinue the list.
|
|
|
|
|
(mapconcat 'car close-open-tags "\n")
|
|
|
|
|
;; Put the table in an indented section.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((table (org-odt--table table contents info))
|
2012-06-05 14:01:54 +00:00
|
|
|
|
(level (/ (length (mapcar 'car close-open-tags)) 2))
|
|
|
|
|
(style (format "OrgIndentedSection-Level-%d" level)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(when table (org-odt-format-section table style)))
|
2012-06-05 14:01:54 +00:00
|
|
|
|
;; Continue the list.
|
|
|
|
|
(mapconcat 'cdr (nreverse close-open-tags) "\n"))))
|
2012-06-03 11:55:37 +00:00
|
|
|
|
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Target
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-target (target _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a TARGET object from Org to ODT.
|
2012-03-04 19:52:20 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist holding contextual
|
|
|
|
|
information."
|
2015-04-13 09:24:42 +00:00
|
|
|
|
(org-odt--target "" (org-export-get-reference target info)))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2012-04-29 00:23:09 +00:00
|
|
|
|
;;;; Timestamp
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-timestamp (timestamp _contents info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a TIMESTAMP object from Org to ODT.
|
2012-04-29 00:11:22 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(let ((type (org-element-property :type timestamp)))
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
(if (not (plist-get info :odt-use-date-fields))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let ((value (org-odt-plain-text
|
2013-01-10 20:42:21 +00:00
|
|
|
|
(org-timestamp-translate timestamp) info)))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case (org-element-property :type timestamp)
|
2012-12-07 09:07:12 +00:00
|
|
|
|
((active active-range)
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgActiveTimestamp" value))
|
|
|
|
|
((inactive inactive-range)
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgInactiveTimestamp" value))
|
|
|
|
|
(otherwise value)))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case type
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(active
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgActiveTimestamp"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(format "<%s>" (org-odt--format-timestamp timestamp))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(inactive
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgInactiveTimestamp"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(format "[%s]" (org-odt--format-timestamp timestamp))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(active-range
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgActiveTimestamp"
|
|
|
|
|
(format "<%s>–<%s>"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--format-timestamp timestamp)
|
|
|
|
|
(org-odt--format-timestamp timestamp 'end))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(inactive-range
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgInactiveTimestamp"
|
|
|
|
|
(format "[%s]–[%s]"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--format-timestamp timestamp)
|
|
|
|
|
(org-odt--format-timestamp timestamp 'end))))
|
2012-12-07 09:07:12 +00:00
|
|
|
|
(otherwise
|
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"OrgDiaryTimestamp"
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-plain-text (org-timestamp-translate timestamp)
|
ox-odt: Use options instead of hard-coded variables
* lisp/ox-odt.el (org-odt-styles-dir,
org-odt-create-custom-styles-for-srcblocks, org-odt-table-styles,
org-odt-get-table-cell-styles): Fix docstring.
(org-odt-format-headline-function,
org-odt-format-inlinetask-function): Change default value.
(org-odt-template, org-odt-drawer, org-odt-format-headline--wrap,
org-odt-inlinetask, org-odt--enumerate, org-odt--image-size,
org-odt--enumerable-image-p, org-odt--enumerable-latex-image-p,
org-odt--enumerable-formula-p, org-odt-link, org-odt-table-style-spec,
org-odt-timestamp): Use option instead of hard-coded variables.
(org-odt-format-headline): Remove function.
(org-odt-do-format-code): Change signature. Use options instead of
hard-coded variables.
(org-odt-fixed-width, org-odt-latex-environment,
org-odt-link--inline-image, org-odt-format-code): Apply signature
change.
(org-odt-format-headline-default-function,
org-odt-format-inlinetask-default-function): New functions.
(org-odt-link--inline-image): Fix indentation.
2014-07-28 15:24:40 +00:00
|
|
|
|
info)))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
;;;; Underline
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-underline (_underline contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode UNDERLINE from Org to ODT.
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
CONTENTS is the text with underline markup. INFO is a plist
|
|
|
|
|
holding contextual information."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
|
|
|
|
"Underline" contents))
|
org-element: Define new objects (bold, code, italic, ...)
* contrib/lisp/org-e-ascii.el (org-e-ascii-option-alist): Fix typo.
(org-e-ascii-bold, org-e-ascii-code, org-e-ascii-strike-through,
org-e-ascii-underline): New functions.
(org-e-ascii-emphasis): Remove function.
* contrib/lisp/org-e-html.el (org-e-html-text-markup-alist): Variable
renamed from `org-e-html-emphasis-alist'. Change value type.
(org-e-html-bold, org-e-html-italic, org-e-html-strike-through,
org-e-html-underline): New functions.
(org-e-html-verbatim): Update function.
(org-e-html-emphasis): Remove function.
* contrib/lisp/org-e-latex.el (org-e-latex-text-markup-alist):
Variable renamed from `org-e-latex-emphasis-alist'. Change value
type.
(org-e-latex-center-block): Fix docstring.
(org-e-latex--text-markup, org-e-latex-bold, org-e-latex-code,
org-e-latex-italic, org-e-latex-strike-through,
org-e-latex-underline): New functions.
(org-e-latex-verbatim): Update function.
(org-e-latex-emphasis): Remove function.
* contrib/lisp/org-e-odt.el (org-e-odt-bold, org-e-odt-code,
org-e-odt-italic, org-e-odt-strike-through, org-e-odt-underline):
New functions.
(org-e-odt-verbatim): Update function.
(org-e-odt-center-block): Fix docstring.
(org-e-odt-emphasis): Remove function.
* contrib/lisp/org-element.el (org-element-bold-parser):
(org-element-bold-interpreter, org-element-code-parser,
org-element-code-interpreter, org-element-italic-parser,
org-element-italic-interpreter, org-element-strike-through-parser,
org-element-strike-through-interpreter, org-element-underline-parser,
org-element-underline-interpreter): New functions.
(org-element-emphasis-parser, org-element-emphasis-interpreter):
Remove functions.
(org-element-verbatim-parser, org-element-verbatim-interpreter,
org-element-text-markup-successor): Update function.
(org-element-object-successor-alist): Add associations for new object
types.
(org-element-recursive-objects): Add `bold', `italic',
`strike-through' and `underline' as recursive types.
(org-element-object-restrictions): Add restrictions for new recursive
object types.
* contrib/lisp/org-export.el (org-export-filters-alist): Add filters
for new object types.
(org-export-with-todo-keywords): Add missing keywords.
(org-export-filter-center-block-functions,
org-export-filter-drawer-functions,
org-export-filter-dynamic-block-functions,
org-export-filter-headline-functions,
org-export-filter-inlinetask-functions,
org-export-filter-plain-list-functions,
org-export-filter-item-functions, org-export-filter-comment-functions,
org-export-filter-comment-block-functions,
org-export-filter-example-block-functions,
org-export-filter-export-block-functions,
org-export-filter-fixed-width-functions,
org-export-filter-footnote-definition-functions,
org-export-filter-horizontal-rule-functions,
org-export-filter-keyword-functions,
org-export-filter-latex-environment-functions,
org-export-filter-babel-call-functions,
org-export-filter-paragraph-functions,
org-export-filter-property-drawer-functions,
org-export-filter-quote-section-functions,
org-export-filter-quote-block-functions,
org-export-filter-section-functions,
org-export-filter-special-block-functions,
org-export-filter-src-block-functions,
org-export-filter-table-functions,
org-export-filter-table-cell-functions,
org-export-filter-table-row-functions,
org-export-filter-verse-block-functions,
org-export-filter-entity-functions,
org-export-filter-export-snippet-functions,
org-export-filter-footnote-reference-functions,
org-export-filter-inline-babel-call-functions,
org-export-filter-inline-src-block-functions,
org-export-filter-latex-fragment-functions,
org-export-filter-line-break-functions,
org-export-filter-link-functions, org-export-filter-macro-functions,
org-export-filter-radio-target-functions,
org-export-filter-statistics-cookie-functions,
org-export-filter-subscript-functions,
org-export-filter-superscript-functions,
org-export-filter-target-functions,
org-export-filter-time-stamp-functions,
org-export-filter-verbatim-functions): Fix docstring.
(org-export-filter-bold-functions, org-export-filter-code-functions,
org-export-filter-italic-functions,
org-export-filter-strike-through-functions,
org-export-filter-underline-functions): New variables.
(org-export-filter-emphasis-functions): Remove variable.
* testing/lisp/test-org-element.el: Add tests.
2012-04-28 16:00:50 +00:00
|
|
|
|
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;;; Verbatim
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-verbatim (verbatim _contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a VERBATIM object from Org to ODT.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
CONTENTS is nil. INFO is a plist used as a communication
|
|
|
|
|
channel."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(format "<text:span text:style-name=\"%s\">%s</text:span>"
|
2013-03-13 16:02:34 +00:00
|
|
|
|
"OrgCode" (org-odt--encode-plain-text
|
|
|
|
|
(org-element-property :value verbatim))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Verse Block
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-verse-block (_verse-block contents _info)
|
2012-05-25 18:39:53 +00:00
|
|
|
|
"Transcode a VERSE-BLOCK element from Org to ODT.
|
2012-04-25 20:15:29 +00:00
|
|
|
|
CONTENTS is verse block contents. INFO is a plist holding
|
|
|
|
|
contextual information."
|
2017-01-12 14:27:39 +00:00
|
|
|
|
(format "\n<text:p text:style-name=\"OrgVerse\">%s</text:p>"
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
;; Replace leading tabs and spaces.
|
|
|
|
|
"^[ \t]+" #'org-odt--encode-tabs-and-spaces
|
|
|
|
|
;; Add line breaks to each line of verse.
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"\\(<text:line-break/>\\)?[ \t]*$" "<text:line-break/>" contents))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;;; Filters
|
|
|
|
|
|
2016-12-17 10:36:49 +00:00
|
|
|
|
;;; Images
|
|
|
|
|
|
|
|
|
|
(defun org-odt--translate-image-links (data _backend info)
|
2016-12-17 10:38:53 +00:00
|
|
|
|
(org-export-insert-image-links data info org-odt-inline-image-rules))
|
2016-12-17 10:36:49 +00:00
|
|
|
|
|
2012-09-13 20:41:03 +00:00
|
|
|
|
;;;; LaTeX fragments
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt--translate-latex-fragments (tree _backend info)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let ((processing-type (plist-get info :with-latex))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(count 0))
|
|
|
|
|
;; Normalize processing-type to one of dvipng, mathml or verbatim.
|
|
|
|
|
;; If the desired converter is not available, force verbatim
|
|
|
|
|
;; processing.
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case processing-type
|
2012-09-13 20:41:03 +00:00
|
|
|
|
((t mathml)
|
|
|
|
|
(if (and (fboundp 'org-format-latex-mathml-available-p)
|
|
|
|
|
(org-format-latex-mathml-available-p))
|
|
|
|
|
(setq processing-type 'mathml)
|
|
|
|
|
(message "LaTeX to MathML converter not available.")
|
|
|
|
|
(setq processing-type 'verbatim)))
|
2013-07-14 06:18:53 +00:00
|
|
|
|
((dvipng imagemagick)
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(unless (and (org-check-external-command "latex" "" t)
|
2013-07-14 06:18:53 +00:00
|
|
|
|
(org-check-external-command
|
|
|
|
|
(if (eq processing-type 'dvipng) "dvipng" "convert") "" t))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(message "LaTeX to PNG converter not available.")
|
|
|
|
|
(setq processing-type 'verbatim)))
|
|
|
|
|
(otherwise
|
|
|
|
|
(message "Unknown LaTeX option. Forcing verbatim.")
|
|
|
|
|
(setq processing-type 'verbatim)))
|
|
|
|
|
|
|
|
|
|
;; Store normalized value for later use.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(when (plist-get info :with-latex)
|
|
|
|
|
(plist-put info :with-latex processing-type))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
(message "Formatting LaTeX using %s" processing-type)
|
|
|
|
|
|
|
|
|
|
;; Convert `latex-fragment's and `latex-environment's.
|
2013-07-14 06:18:53 +00:00
|
|
|
|
(when (memq processing-type '(mathml dvipng imagemagick))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-element-map tree '(latex-fragment latex-environment)
|
|
|
|
|
(lambda (latex-*)
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-incf count)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((latex-frag (org-element-property :value latex-*))
|
|
|
|
|
(input-file (plist-get info :input-file))
|
|
|
|
|
(cache-dir (file-name-directory input-file))
|
|
|
|
|
(cache-subdir (concat
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case processing-type
|
2013-07-14 06:18:53 +00:00
|
|
|
|
((dvipng imagemagick) "ltxpng/")
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(mathml "ltxmathml/"))
|
|
|
|
|
(file-name-sans-extension
|
|
|
|
|
(file-name-nondirectory input-file))))
|
|
|
|
|
(display-msg
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-case processing-type
|
2015-02-26 20:39:05 +00:00
|
|
|
|
((dvipng imagemagick)
|
|
|
|
|
(format "Creating LaTeX Image %d..." count))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(mathml (format "Creating MathML snippet %d..." count))))
|
|
|
|
|
;; Get an Org-style link to PNG image or the MathML
|
|
|
|
|
;; file.
|
2017-06-25 21:06:37 +00:00
|
|
|
|
(link
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert latex-frag)
|
|
|
|
|
;; When converting to a PNG image, make sure to
|
|
|
|
|
;; copy all LaTeX header specifications from the
|
|
|
|
|
;; Org source.
|
|
|
|
|
(unless (eq processing-type 'mathml)
|
|
|
|
|
(let ((h (plist-get info :latex-header)))
|
|
|
|
|
(when h
|
|
|
|
|
(insert "\n"
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"^" "#+LATEX_HEADER: " h)))))
|
|
|
|
|
(org-format-latex cache-subdir nil nil cache-dir
|
|
|
|
|
nil display-msg nil
|
|
|
|
|
processing-type)
|
|
|
|
|
(goto-char (point-min))
|
2017-09-05 20:33:29 +00:00
|
|
|
|
(skip-chars-forward " \t\n")
|
2017-06-25 21:06:37 +00:00
|
|
|
|
(org-element-link-parser))))
|
|
|
|
|
(if (not (eq 'link (org-element-type link)))
|
|
|
|
|
(message "LaTeX Conversion failed.")
|
2015-02-26 14:41:35 +00:00
|
|
|
|
;; Conversion succeeded. Parse above Org-style link to
|
|
|
|
|
;; a `link' object.
|
2017-06-25 21:06:37 +00:00
|
|
|
|
(let ((replacement
|
|
|
|
|
(cl-case (org-element-type latex-*)
|
|
|
|
|
;;LaTeX environment. Mimic a "standalone image
|
|
|
|
|
;; or formula" by enclosing the `link' in
|
|
|
|
|
;; a `paragraph'. Copy over original
|
|
|
|
|
;; attributes, captions to the enclosing
|
|
|
|
|
;; paragraph.
|
|
|
|
|
(latex-environment
|
|
|
|
|
(org-element-adopt-elements
|
|
|
|
|
(list 'paragraph
|
|
|
|
|
(list :style "OrgFormula"
|
|
|
|
|
:name
|
|
|
|
|
(org-element-property :name latex-*)
|
|
|
|
|
:caption
|
|
|
|
|
(org-element-property :caption latex-*)))
|
|
|
|
|
link))
|
|
|
|
|
;; LaTeX fragment. No special action.
|
|
|
|
|
(latex-fragment link))))
|
2015-02-26 14:41:35 +00:00
|
|
|
|
;; Note down the object that link replaces.
|
|
|
|
|
(org-element-put-property replacement :replaces
|
|
|
|
|
(list (org-element-type latex-*)
|
|
|
|
|
(list :value latex-frag)))
|
|
|
|
|
;; Restore blank after initial element or object.
|
|
|
|
|
(org-element-put-property
|
|
|
|
|
replacement :post-blank
|
|
|
|
|
(org-element-property :post-blank latex-*))
|
|
|
|
|
;; Replace now.
|
|
|
|
|
(org-element-set-element latex-* replacement)))))
|
2015-02-25 22:45:15 +00:00
|
|
|
|
info nil nil t)))
|
2012-09-13 20:41:03 +00:00
|
|
|
|
tree)
|
|
|
|
|
|
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;;;; Description lists
|
|
|
|
|
|
|
|
|
|
;; This translator is necessary to handle indented tables in a uniform
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; manner. See comment in `org-odt--table'.
|
2012-08-25 20:35:24 +00:00
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt--translate-description-lists (tree _backend info)
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;; OpenDocument has no notion of a description list. So simulate it
|
|
|
|
|
;; using plain lists. Description lists in the exported document
|
|
|
|
|
;; are typeset in the same manner as they are in a typical HTML
|
|
|
|
|
;; document.
|
|
|
|
|
;;
|
|
|
|
|
;; Specifically, a description list like this:
|
|
|
|
|
;;
|
|
|
|
|
;; ,----
|
|
|
|
|
;; | - term-1 :: definition-1
|
|
|
|
|
;; | - term-2 :: definition-2
|
|
|
|
|
;; `----
|
|
|
|
|
;;
|
|
|
|
|
;; gets translated in to the following form:
|
|
|
|
|
;;
|
|
|
|
|
;; ,----
|
|
|
|
|
;; | - term-1
|
|
|
|
|
;; | - definition-1
|
|
|
|
|
;; | - term-2
|
|
|
|
|
;; | - definition-2
|
|
|
|
|
;; `----
|
|
|
|
|
;;
|
|
|
|
|
;; Further effect is achieved by fixing the OD styles as below:
|
|
|
|
|
;;
|
|
|
|
|
;; 1. Set the :type property of the simulated lists to
|
|
|
|
|
;; `descriptive-1' and `descriptive-2'. Map these to list-styles
|
|
|
|
|
;; that has *no* bullets whatsoever.
|
|
|
|
|
;;
|
|
|
|
|
;; 2. The paragraph containing the definition term is styled to be
|
|
|
|
|
;; in bold.
|
|
|
|
|
;;
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-element-map tree 'plain-list
|
|
|
|
|
(lambda (el)
|
2016-09-25 15:29:06 +00:00
|
|
|
|
(when (eq (org-element-property :type el) 'descriptive)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-element-set-element
|
|
|
|
|
el
|
|
|
|
|
(apply 'org-element-adopt-elements
|
|
|
|
|
(list 'plain-list (list :type 'descriptive-1))
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (item)
|
2012-09-04 09:15:51 +00:00
|
|
|
|
(org-element-adopt-elements
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(list 'item (list :checkbox (org-element-property
|
|
|
|
|
:checkbox item)))
|
|
|
|
|
(list 'paragraph (list :style "Text_20_body_20_bold")
|
|
|
|
|
(or (org-element-property :tag item) "(no term)"))
|
|
|
|
|
(org-element-adopt-elements
|
|
|
|
|
(list 'plain-list (list :type 'descriptive-2))
|
|
|
|
|
(apply 'org-element-adopt-elements
|
|
|
|
|
(list 'item nil)
|
|
|
|
|
(org-element-contents item)))))
|
|
|
|
|
(org-element-contents el)))))
|
|
|
|
|
nil)
|
|
|
|
|
info)
|
2012-08-25 20:35:24 +00:00
|
|
|
|
tree)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2012-09-04 08:45:14 +00:00
|
|
|
|
;;;; List tables
|
|
|
|
|
|
|
|
|
|
;; Lists that are marked with attribute `:list-table' are called as
|
|
|
|
|
;; list tables. They will be rendered as a table within the exported
|
|
|
|
|
;; document.
|
|
|
|
|
|
|
|
|
|
;; Consider an example. The following list table
|
|
|
|
|
;;
|
|
|
|
|
;; #+attr_odt :list-table t
|
|
|
|
|
;; - Row 1
|
|
|
|
|
;; - 1.1
|
|
|
|
|
;; - 1.2
|
|
|
|
|
;; - 1.3
|
|
|
|
|
;; - Row 2
|
|
|
|
|
;; - 2.1
|
|
|
|
|
;; - 2.2
|
|
|
|
|
;; - 2.3
|
|
|
|
|
;;
|
|
|
|
|
;; will be exported as though it were an Org table like the one show
|
|
|
|
|
;; below.
|
|
|
|
|
;;
|
|
|
|
|
;; | Row 1 | 1.1 | 1.2 | 1.3 |
|
|
|
|
|
;; | Row 2 | 2.1 | 2.2 | 2.3 |
|
|
|
|
|
;;
|
|
|
|
|
;; Note that org-tables are NOT multi-line and each line is mapped to
|
|
|
|
|
;; a unique row in the exported document. So if an exported table
|
|
|
|
|
;; needs to contain a single paragraph (with copious text) it needs to
|
|
|
|
|
;; be typed up in a single line. Editing such long lines using the
|
|
|
|
|
;; table editor will be a cumbersome task. Furthermore inclusion of
|
|
|
|
|
;; multi-paragraph text in a table cell is well-nigh impossible.
|
|
|
|
|
;;
|
|
|
|
|
;; A LIST-TABLE circumvents above problems.
|
|
|
|
|
;;
|
|
|
|
|
;; Note that in the example above the list items could be paragraphs
|
|
|
|
|
;; themselves and the list can be arbitrarily deep.
|
|
|
|
|
;;
|
|
|
|
|
;; Inspired by following thread:
|
2017-11-26 06:45:41 +00:00
|
|
|
|
;; https://lists.gnu.org/r/emacs-orgmode/2011-03/msg01101.html
|
2012-09-04 08:45:14 +00:00
|
|
|
|
|
|
|
|
|
;; Translate lists to tables
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt--translate-list-tables (tree _backend info)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-element-map tree 'plain-list
|
|
|
|
|
(lambda (l1-list)
|
|
|
|
|
(when (org-export-read-attribute :attr_odt l1-list :list-table)
|
|
|
|
|
;; Replace list with table.
|
|
|
|
|
(org-element-set-element
|
|
|
|
|
l1-list
|
|
|
|
|
;; Build replacement table.
|
|
|
|
|
(apply 'org-element-adopt-elements
|
|
|
|
|
(list 'table '(:type org :attr_odt (":style \"GriddedTable\"")))
|
|
|
|
|
(org-element-map l1-list 'item
|
|
|
|
|
(lambda (l1-item)
|
|
|
|
|
(let* ((l1-item-contents (org-element-contents l1-item))
|
|
|
|
|
l1-item-leading-text l2-list)
|
|
|
|
|
;; Remove Level-2 list from the Level-item. It
|
|
|
|
|
;; will be subsequently attached as table-cells.
|
|
|
|
|
(let ((cur l1-item-contents) prev)
|
|
|
|
|
(while (and cur (not (eq (org-element-type (car cur))
|
|
|
|
|
'plain-list)))
|
|
|
|
|
(setq prev cur)
|
|
|
|
|
(setq cur (cdr cur)))
|
|
|
|
|
(when prev
|
|
|
|
|
(setcdr prev nil)
|
|
|
|
|
(setq l2-list (car cur)))
|
|
|
|
|
(setq l1-item-leading-text l1-item-contents))
|
|
|
|
|
;; Level-1 items start a table row.
|
|
|
|
|
(apply 'org-element-adopt-elements
|
|
|
|
|
(list 'table-row (list :type 'standard))
|
|
|
|
|
;; Leading text of level-1 item define
|
|
|
|
|
;; the first table-cell.
|
|
|
|
|
(apply 'org-element-adopt-elements
|
|
|
|
|
(list 'table-cell nil)
|
|
|
|
|
l1-item-leading-text)
|
|
|
|
|
;; Level-2 items define subsequent
|
|
|
|
|
;; table-cells of the row.
|
|
|
|
|
(org-element-map l2-list 'item
|
|
|
|
|
(lambda (l2-item)
|
|
|
|
|
(apply 'org-element-adopt-elements
|
|
|
|
|
(list 'table-cell nil)
|
|
|
|
|
(org-element-contents l2-item)))
|
|
|
|
|
info nil 'item))))
|
|
|
|
|
info nil 'item))))
|
|
|
|
|
nil)
|
|
|
|
|
info)
|
2012-09-04 08:45:14 +00:00
|
|
|
|
tree)
|
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;; Interactive functions
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-create-manifest-file-entry (&rest args)
|
|
|
|
|
(push args org-odt-manifest-file-entries))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-write-manifest-file ()
|
|
|
|
|
(make-directory (concat org-odt-zip-dir "META-INF"))
|
|
|
|
|
(let ((manifest-file (concat org-odt-zip-dir "META-INF/manifest.xml")))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(with-current-buffer
|
|
|
|
|
(let ((nxml-auto-insert-xml-declaration-flag nil))
|
|
|
|
|
(find-file-noselect manifest-file t))
|
|
|
|
|
(insert
|
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|
|
|
|
<manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\" manifest:version=\"1.2\">\n")
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (file-entry org-odt-manifest-file-entries)
|
|
|
|
|
(let* ((version (nth 2 file-entry))
|
|
|
|
|
(extra (if (not version) ""
|
|
|
|
|
(format " manifest:version=\"%s\"" version))))
|
|
|
|
|
(insert
|
|
|
|
|
(format org-odt-manifest-file-entry-tag
|
|
|
|
|
(nth 0 file-entry) (nth 1 file-entry) extra))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(insert "\n</manifest:manifest>"))))
|
2012-07-14 12:50:52 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defmacro org-odt--export-wrap (out-file &rest body)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
`(let* ((--out-file ,out-file)
|
|
|
|
|
(out-file-type (file-name-extension --out-file))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-xml-files '("META-INF/manifest.xml" "content.xml"
|
2015-10-31 23:58:57 +00:00
|
|
|
|
"meta.xml" "styles.xml"))
|
2012-11-03 12:48:24 +00:00
|
|
|
|
;; Initialize temporary workarea. All files that end up in
|
|
|
|
|
;; the exported document get parked/created here.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-zip-dir (file-name-as-directory
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(make-temp-file (format "%s-" out-file-type) t)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-manifest-file-entries nil)
|
2012-07-14 12:50:52 +00:00
|
|
|
|
(--cleanup-xml-buffers
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(lambda ()
|
|
|
|
|
;; Kill all XML buffers.
|
|
|
|
|
(dolist (file org-odt-xml-files)
|
|
|
|
|
(let ((buf (find-buffer-visiting
|
|
|
|
|
(concat org-odt-zip-dir file))))
|
|
|
|
|
(when buf
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(kill-buffer buf)))))
|
|
|
|
|
;; Delete temporary directory and also other embedded
|
|
|
|
|
;; files that get copied there.
|
|
|
|
|
(delete-directory org-odt-zip-dir t))))
|
2013-01-14 19:52:21 +00:00
|
|
|
|
(condition-case err
|
2012-09-03 14:20:18 +00:00
|
|
|
|
(progn
|
|
|
|
|
(unless (executable-find "zip")
|
|
|
|
|
;; Not at all OSes ship with zip by default
|
|
|
|
|
(error "Executable \"zip\" needed for creating OpenDocument files"))
|
|
|
|
|
;; Do export. This creates a bunch of xml files ready to be
|
|
|
|
|
;; saved and zipped.
|
|
|
|
|
(progn ,@body)
|
|
|
|
|
;; Create a manifest entry for content.xml.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-create-manifest-file-entry "text/xml" "content.xml")
|
2012-09-03 14:20:18 +00:00
|
|
|
|
;; Write mimetype file
|
|
|
|
|
(let* ((mimetypes
|
|
|
|
|
'(("odt" . "application/vnd.oasis.opendocument.text")
|
|
|
|
|
("odf" . "application/vnd.oasis.opendocument.formula")))
|
|
|
|
|
(mimetype (cdr (assoc-string out-file-type mimetypes t))))
|
|
|
|
|
(unless mimetype
|
|
|
|
|
(error "Unknown OpenDocument backend %S" out-file-type))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(write-region mimetype nil (concat org-odt-zip-dir "mimetype"))
|
|
|
|
|
(org-odt-create-manifest-file-entry mimetype "/" "1.2"))
|
2012-09-03 14:20:18 +00:00
|
|
|
|
;; Write out the manifest entries before zipping
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-write-manifest-file)
|
2012-09-03 14:20:18 +00:00
|
|
|
|
;; Save all XML files.
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (file org-odt-xml-files)
|
|
|
|
|
(let ((buf (find-buffer-visiting
|
|
|
|
|
(concat org-odt-zip-dir file))))
|
|
|
|
|
(when buf
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
;; Prettify output if needed.
|
|
|
|
|
(when org-odt-prettify-xml
|
|
|
|
|
(indent-region (point-min) (point-max)))
|
|
|
|
|
(save-buffer 0)))))
|
2012-09-03 14:20:18 +00:00
|
|
|
|
;; Run zip.
|
|
|
|
|
(let* ((target --out-file)
|
|
|
|
|
(target-name (file-name-nondirectory target))
|
|
|
|
|
(cmds `(("zip" "-mX0" ,target-name "mimetype")
|
|
|
|
|
("zip" "-rmTq" ,target-name "."))))
|
|
|
|
|
;; If a file with same name as the desired output file
|
|
|
|
|
;; exists, remove it.
|
|
|
|
|
(when (file-exists-p target)
|
|
|
|
|
(delete-file target))
|
|
|
|
|
;; Zip up the xml files.
|
|
|
|
|
(let ((coding-system-for-write 'no-conversion) exitcode err-string)
|
|
|
|
|
(message "Creating ODT file...")
|
|
|
|
|
;; Switch temporarily to content.xml. This way Zip
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; process will inherit `org-odt-zip-dir' as the current
|
2012-09-03 14:20:18 +00:00
|
|
|
|
;; directory.
|
|
|
|
|
(with-current-buffer
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(find-file-noselect (concat org-odt-zip-dir "content.xml") t)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (cmd cmds)
|
|
|
|
|
(message "Running %s" (mapconcat 'identity cmd " "))
|
|
|
|
|
(setq err-string
|
|
|
|
|
(with-output-to-string
|
|
|
|
|
(setq exitcode
|
|
|
|
|
(apply 'call-process (car cmd)
|
|
|
|
|
nil standard-output nil (cdr cmd)))))
|
|
|
|
|
(or (zerop exitcode)
|
|
|
|
|
(error (concat "Unable to create OpenDocument file."
|
|
|
|
|
" Zip failed with error (%s)")
|
|
|
|
|
err-string)))))
|
2012-11-03 12:48:24 +00:00
|
|
|
|
;; Move the zip file from temporary work directory to
|
|
|
|
|
;; user-mandated location.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(rename-file (concat org-odt-zip-dir target-name) target)
|
2012-11-03 12:48:24 +00:00
|
|
|
|
(message "Created %s" (expand-file-name target))
|
2012-09-03 14:20:18 +00:00
|
|
|
|
;; Cleanup work directory and work files.
|
|
|
|
|
(funcall --cleanup-xml-buffers)
|
|
|
|
|
;; Open the OpenDocument file in archive-mode for
|
|
|
|
|
;; examination.
|
|
|
|
|
(find-file-noselect target t)
|
|
|
|
|
;; Return exported file.
|
|
|
|
|
(cond
|
|
|
|
|
;; Case 1: Conversion desired on exported file. Run the
|
|
|
|
|
;; converter on the OpenDocument file. Return the
|
|
|
|
|
;; converted file.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt-preferred-output-format
|
|
|
|
|
(or (org-odt-convert target org-odt-preferred-output-format)
|
2012-09-03 14:20:18 +00:00
|
|
|
|
target))
|
|
|
|
|
;; Case 2: No further conversion. Return exported
|
|
|
|
|
;; OpenDocument file.
|
|
|
|
|
(t target))))
|
|
|
|
|
(error
|
|
|
|
|
;; Cleanup work directory and work files.
|
|
|
|
|
(funcall --cleanup-xml-buffers)
|
|
|
|
|
(message "OpenDocument export failed: %s"
|
|
|
|
|
(error-message-string err))))))
|
2012-07-14 12:50:52 +00:00
|
|
|
|
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;;;; Export to OpenDocument formula
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-export-as-odf (latex-frag &optional odf-file)
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Export LATEX-FRAG as OpenDocument formula file ODF-FILE.
|
|
|
|
|
Use `org-create-math-formula' to convert LATEX-FRAG first to
|
|
|
|
|
MathML. When invoked as an interactive command, use
|
|
|
|
|
`org-latex-regexps' to infer LATEX-FRAG from currently active
|
|
|
|
|
region. If no LaTeX fragments are found, prompt for it. Push
|
2013-03-15 12:39:45 +00:00
|
|
|
|
MathML source to kill ring depending on the value of
|
|
|
|
|
`org-export-copy-to-kill-ring'."
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(interactive
|
|
|
|
|
`(,(let (frag)
|
|
|
|
|
(setq frag (and (setq frag (and (region-active-p)
|
|
|
|
|
(buffer-substring (region-beginning)
|
|
|
|
|
(region-end))))
|
2016-07-25 13:51:23 +00:00
|
|
|
|
(cl-loop for e in org-latex-regexps
|
|
|
|
|
thereis (when (string-match (nth 1 e) frag)
|
|
|
|
|
(match-string (nth 2 e) frag)))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
(read-string "LaTeX Fragment: " frag nil frag))
|
|
|
|
|
,(let ((odf-filename (expand-file-name
|
|
|
|
|
(concat
|
|
|
|
|
(file-name-sans-extension
|
|
|
|
|
(or (file-name-nondirectory buffer-file-name)))
|
|
|
|
|
"." "odf")
|
|
|
|
|
(file-name-directory buffer-file-name))))
|
|
|
|
|
(read-file-name "ODF filename: " nil odf-filename nil
|
|
|
|
|
(file-name-nondirectory odf-filename)))))
|
|
|
|
|
(let ((filename (or odf-file
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(concat
|
|
|
|
|
(file-name-sans-extension
|
|
|
|
|
(or (file-name-nondirectory buffer-file-name)))
|
|
|
|
|
"." "odf")
|
|
|
|
|
(file-name-directory buffer-file-name)))))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--export-wrap
|
2012-07-19 16:45:23 +00:00
|
|
|
|
filename
|
|
|
|
|
(let* ((buffer (progn
|
|
|
|
|
(require 'nxml-mode)
|
|
|
|
|
(let ((nxml-auto-insert-xml-declaration-flag nil))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(find-file-noselect (concat org-odt-zip-dir
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"content.xml") t))))
|
|
|
|
|
(coding-system-for-write 'utf-8)
|
|
|
|
|
(save-buffer-coding-system 'utf-8))
|
|
|
|
|
(set-buffer buffer)
|
|
|
|
|
(set-buffer-file-coding-system coding-system-for-write)
|
|
|
|
|
(let ((mathml (org-create-math-formula latex-frag)))
|
|
|
|
|
(unless mathml (error "No Math formula created"))
|
|
|
|
|
(insert mathml)
|
2012-07-19 17:45:44 +00:00
|
|
|
|
;; Add MathML to kill ring, if needed.
|
2013-03-15 12:39:45 +00:00
|
|
|
|
(when (org-export--copy-to-kill-ring-p)
|
2012-07-19 17:45:44 +00:00
|
|
|
|
(org-kill-new (buffer-string))))))))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-export-as-odf-and-open ()
|
2012-07-19 16:45:23 +00:00
|
|
|
|
"Export LaTeX fragment as OpenDocument formula and immediately open it.
|
2013-01-27 22:11:34 +00:00
|
|
|
|
Use `org-odt-export-as-odf' to read LaTeX fragment and OpenDocument
|
2012-07-19 16:45:23 +00:00
|
|
|
|
formula file."
|
|
|
|
|
(interactive)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-open-file (call-interactively 'org-odt-export-as-odf) 'system))
|
2012-07-19 16:45:23 +00:00
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
|
|
|
|
|
;;;; Export to OpenDocument Text
|
|
|
|
|
|
2012-06-01 19:42:24 +00:00
|
|
|
|
;;;###autoload
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-export-to-odt (&optional async subtreep visible-only ext-plist)
|
2012-12-19 20:38:22 +00:00
|
|
|
|
"Export current buffer to a ODT file.
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
If narrowing is active in the current buffer, only export its
|
|
|
|
|
narrowed part.
|
|
|
|
|
|
|
|
|
|
If a region is active, export that region.
|
|
|
|
|
|
2012-12-02 16:24:19 +00:00
|
|
|
|
A non-nil optional argument ASYNC means the process should happen
|
|
|
|
|
asynchronously. The resulting file should be accessible through
|
|
|
|
|
the `org-export-stack' interface.
|
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
When optional argument SUBTREEP is non-nil, export the sub-tree
|
|
|
|
|
at point, extracting information from the headline properties
|
|
|
|
|
first.
|
|
|
|
|
|
|
|
|
|
When optional argument VISIBLE-ONLY is non-nil, don't export
|
|
|
|
|
contents of hidden elements.
|
|
|
|
|
|
|
|
|
|
EXT-PLIST, when provided, is a property list with external
|
|
|
|
|
parameters overriding Org default settings, but still inferior to
|
|
|
|
|
file-local settings.
|
|
|
|
|
|
|
|
|
|
Return output file's name."
|
|
|
|
|
(interactive)
|
2012-12-02 16:24:19 +00:00
|
|
|
|
(let ((outfile (org-export-output-file-name ".odt" subtreep)))
|
|
|
|
|
(if async
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-export-async-start (lambda (f) (org-export-add-to-stack f 'odt))
|
2012-12-02 16:24:19 +00:00
|
|
|
|
`(expand-file-name
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--export-wrap
|
2012-12-02 16:24:19 +00:00
|
|
|
|
,outfile
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((org-odt-embedded-images-count 0)
|
|
|
|
|
(org-odt-embedded-formulas-count 0)
|
|
|
|
|
(org-odt-automatic-styles nil)
|
|
|
|
|
(org-odt-object-counters nil)
|
2012-12-02 16:24:19 +00:00
|
|
|
|
;; Let `htmlfontify' know that we are interested in
|
|
|
|
|
;; collecting styles.
|
|
|
|
|
(hfy-user-sheet-assoc nil))
|
|
|
|
|
;; Initialize content.xml and kick-off the export
|
|
|
|
|
;; process.
|
|
|
|
|
(let ((out-buf
|
|
|
|
|
(progn
|
|
|
|
|
(require 'nxml-mode)
|
|
|
|
|
(let ((nxml-auto-insert-xml-declaration-flag nil))
|
|
|
|
|
(find-file-noselect
|
Export back-ends: Apply changes to export functions
* contrib/lisp/ox-confluence.el (org-confluence-export-as-confluence):
* contrib/lisp/ox-deck.el (org-deck-export-as-html,
org-deck-export-to-html):
* contrib/lisp/ox-freemind.el (org-freemind-export-to-freemind):
* contrib/lisp/ox-groff.el (org-groff-export-to-groff,
org-groff-export-to-pdf):
* contrib/lisp/ox-koma-letter.el (org-koma-letter-export-as-latex,
org-koma-letter-export-to-latex, org-koma-letter-export-to-pdf):
* contrib/lisp/ox-rss.el (org-rss-export-as-rss,
org-rss-export-to-rss):
* contrib/lisp/ox-s5.el (org-s5-export-as-html,
org-s5-export-to-html):
* contrib/lisp/ox-taskjuggler.el (org-taskjuggler-export):
* lisp/ob-haskell.el:
* lisp/ox-ascii.el (org-ascii-export-as-ascii,
org-ascii-export-to-ascii):
* lisp/ox-beamer.el (org-beamer-export-as-latex,
org-beamer-export-to-latex, org-beamer-export-to-pdf):
* lisp/ox-html.el (org-html-export-as-html, org-html-export-to-html):
* lisp/ox-icalendar.el (org-icalendar-export-to-ics):
* lisp/ox-latex.el (org-latex-export-as-latex,
org-latex-export-to-pdf):
* lisp/ox-man.el (org-man-export-to-man, org-man-export-to-pdf):
* lisp/ox-md.el (org-md-export-as-markdown,
org-md-export-to-markdown):
* lisp/ox-odt.el (org-odt-export-to-odt):
* lisp/ox-org.el (org-org-export-as-org, org-org-export-to-org):
* lisp/ox-publish.el (org-publish-org-to):
* lisp/ox-texinfo.el (org-texinfo-export-to-texinfo,
org-texinfo-export-to-info):
* testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-file):
2013-08-07 08:35:42 +00:00
|
|
|
|
(concat org-odt-zip-dir "content.xml") t))))
|
|
|
|
|
(output (org-export-as
|
|
|
|
|
'odt ,subtreep ,visible-only nil ,ext-plist)))
|
|
|
|
|
(with-current-buffer out-buf
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert output)))))))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(org-odt--export-wrap
|
2012-12-02 16:24:19 +00:00
|
|
|
|
outfile
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let* ((org-odt-embedded-images-count 0)
|
|
|
|
|
(org-odt-embedded-formulas-count 0)
|
|
|
|
|
(org-odt-automatic-styles nil)
|
|
|
|
|
(org-odt-object-counters nil)
|
2012-12-02 16:24:19 +00:00
|
|
|
|
;; Let `htmlfontify' know that we are interested in collecting
|
|
|
|
|
;; styles.
|
|
|
|
|
(hfy-user-sheet-assoc nil))
|
|
|
|
|
;; Initialize content.xml and kick-off the export process.
|
Export back-ends: Apply changes to export functions
* contrib/lisp/ox-confluence.el (org-confluence-export-as-confluence):
* contrib/lisp/ox-deck.el (org-deck-export-as-html,
org-deck-export-to-html):
* contrib/lisp/ox-freemind.el (org-freemind-export-to-freemind):
* contrib/lisp/ox-groff.el (org-groff-export-to-groff,
org-groff-export-to-pdf):
* contrib/lisp/ox-koma-letter.el (org-koma-letter-export-as-latex,
org-koma-letter-export-to-latex, org-koma-letter-export-to-pdf):
* contrib/lisp/ox-rss.el (org-rss-export-as-rss,
org-rss-export-to-rss):
* contrib/lisp/ox-s5.el (org-s5-export-as-html,
org-s5-export-to-html):
* contrib/lisp/ox-taskjuggler.el (org-taskjuggler-export):
* lisp/ob-haskell.el:
* lisp/ox-ascii.el (org-ascii-export-as-ascii,
org-ascii-export-to-ascii):
* lisp/ox-beamer.el (org-beamer-export-as-latex,
org-beamer-export-to-latex, org-beamer-export-to-pdf):
* lisp/ox-html.el (org-html-export-as-html, org-html-export-to-html):
* lisp/ox-icalendar.el (org-icalendar-export-to-ics):
* lisp/ox-latex.el (org-latex-export-as-latex,
org-latex-export-to-pdf):
* lisp/ox-man.el (org-man-export-to-man, org-man-export-to-pdf):
* lisp/ox-md.el (org-md-export-as-markdown,
org-md-export-to-markdown):
* lisp/ox-odt.el (org-odt-export-to-odt):
* lisp/ox-org.el (org-org-export-as-org, org-org-export-to-org):
* lisp/ox-publish.el (org-publish-org-to):
* lisp/ox-texinfo.el (org-texinfo-export-to-texinfo,
org-texinfo-export-to-info):
* testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-file):
2013-08-07 08:35:42 +00:00
|
|
|
|
(let ((output (org-export-as 'odt subtreep visible-only nil ext-plist))
|
|
|
|
|
(out-buf (progn
|
2012-12-02 16:24:19 +00:00
|
|
|
|
(require 'nxml-mode)
|
|
|
|
|
(let ((nxml-auto-insert-xml-declaration-flag nil))
|
|
|
|
|
(find-file-noselect
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(concat org-odt-zip-dir "content.xml") t)))))
|
Export back-ends: Apply changes to export functions
* contrib/lisp/ox-confluence.el (org-confluence-export-as-confluence):
* contrib/lisp/ox-deck.el (org-deck-export-as-html,
org-deck-export-to-html):
* contrib/lisp/ox-freemind.el (org-freemind-export-to-freemind):
* contrib/lisp/ox-groff.el (org-groff-export-to-groff,
org-groff-export-to-pdf):
* contrib/lisp/ox-koma-letter.el (org-koma-letter-export-as-latex,
org-koma-letter-export-to-latex, org-koma-letter-export-to-pdf):
* contrib/lisp/ox-rss.el (org-rss-export-as-rss,
org-rss-export-to-rss):
* contrib/lisp/ox-s5.el (org-s5-export-as-html,
org-s5-export-to-html):
* contrib/lisp/ox-taskjuggler.el (org-taskjuggler-export):
* lisp/ob-haskell.el:
* lisp/ox-ascii.el (org-ascii-export-as-ascii,
org-ascii-export-to-ascii):
* lisp/ox-beamer.el (org-beamer-export-as-latex,
org-beamer-export-to-latex, org-beamer-export-to-pdf):
* lisp/ox-html.el (org-html-export-as-html, org-html-export-to-html):
* lisp/ox-icalendar.el (org-icalendar-export-to-ics):
* lisp/ox-latex.el (org-latex-export-as-latex,
org-latex-export-to-pdf):
* lisp/ox-man.el (org-man-export-to-man, org-man-export-to-pdf):
* lisp/ox-md.el (org-md-export-as-markdown,
org-md-export-to-markdown):
* lisp/ox-odt.el (org-odt-export-to-odt):
* lisp/ox-org.el (org-org-export-as-org, org-org-export-to-org):
* lisp/ox-publish.el (org-publish-org-to):
* lisp/ox-texinfo.el (org-texinfo-export-to-texinfo,
org-texinfo-export-to-info):
* testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-file):
2013-08-07 08:35:42 +00:00
|
|
|
|
(with-current-buffer out-buf (erase-buffer) (insert output))))))))
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
2012-08-25 20:35:24 +00:00
|
|
|
|
;;;; Convert between OpenDocument and other formats
|
2012-04-05 11:43:14 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-reachable-p (in-fmt out-fmt)
|
2012-04-05 11:43:14 +00:00
|
|
|
|
"Return non-nil if IN-FMT can be converted to OUT-FMT."
|
|
|
|
|
(catch 'done
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(let ((reachable-formats (org-odt-do-reachable-formats in-fmt)))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(dolist (e reachable-formats)
|
|
|
|
|
(let ((out-fmt-spec (assoc out-fmt (cdr e))))
|
|
|
|
|
(when out-fmt-spec
|
|
|
|
|
(throw 'done (cons (car e) out-fmt-spec))))))))
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-do-convert (in-file out-fmt &optional open)
|
2013-01-27 22:11:34 +00:00
|
|
|
|
"Workhorse routine for `org-odt-convert'."
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(require 'browse-url)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(let* ((in-file (let ((f (expand-file-name (or in-file buffer-file-name))))
|
|
|
|
|
(if (file-readable-p f) f
|
|
|
|
|
(error "Cannot read %s" in-file))))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(in-fmt (file-name-extension in-file))
|
|
|
|
|
(out-fmt (or out-fmt (error "Output format unspecified")))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(how (or (org-odt-reachable-p in-fmt out-fmt)
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(error "Cannot convert from %s format to %s format?"
|
|
|
|
|
in-fmt out-fmt)))
|
|
|
|
|
(convert-process (car how))
|
|
|
|
|
(out-file (concat (file-name-sans-extension in-file) "."
|
|
|
|
|
(nth 1 (or (cdr how) out-fmt))))
|
|
|
|
|
(extra-options (or (nth 2 (cdr how)) ""))
|
|
|
|
|
(out-dir (file-name-directory in-file))
|
|
|
|
|
(cmd (format-spec convert-process
|
|
|
|
|
`((?i . ,(shell-quote-argument in-file))
|
|
|
|
|
(?I . ,(browse-url-file-url in-file))
|
|
|
|
|
(?f . ,out-fmt)
|
|
|
|
|
(?o . ,out-file)
|
|
|
|
|
(?O . ,(browse-url-file-url out-file))
|
|
|
|
|
(?d . , (shell-quote-argument out-dir))
|
|
|
|
|
(?D . ,(browse-url-file-url out-dir))
|
|
|
|
|
(?x . ,extra-options)))))
|
|
|
|
|
(when (file-exists-p out-file)
|
|
|
|
|
(delete-file out-file))
|
|
|
|
|
|
|
|
|
|
(message "Executing %s" cmd)
|
|
|
|
|
(let ((cmd-output (shell-command-to-string cmd)))
|
|
|
|
|
(message "%s" cmd-output))
|
|
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
((file-exists-p out-file)
|
|
|
|
|
(message "Exported to %s" out-file)
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(when open
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(message "Opening %s..." out-file)
|
2012-09-03 14:20:18 +00:00
|
|
|
|
(org-open-file out-file 'system))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
out-file)
|
|
|
|
|
(t
|
|
|
|
|
(message "Export to %s failed" out-file)
|
|
|
|
|
nil))))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-do-reachable-formats (in-fmt)
|
2012-04-05 11:43:14 +00:00
|
|
|
|
"Return verbose info about formats to which IN-FMT can be converted.
|
|
|
|
|
Return a list where each element is of the
|
|
|
|
|
form (CONVERTER-PROCESS . OUTPUT-FMT-ALIST). See
|
2013-01-27 22:11:34 +00:00
|
|
|
|
`org-odt-convert-processes' for CONVERTER-PROCESS and see
|
|
|
|
|
`org-odt-convert-capabilities' for OUTPUT-FMT-ALIST."
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(let* ((converter
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(and org-odt-convert-process
|
|
|
|
|
(cadr (assoc-string org-odt-convert-process
|
|
|
|
|
org-odt-convert-processes t))))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(capabilities
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(and org-odt-convert-process
|
|
|
|
|
(cadr (assoc-string org-odt-convert-process
|
|
|
|
|
org-odt-convert-processes t))
|
|
|
|
|
org-odt-convert-capabilities))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
reachable-formats)
|
|
|
|
|
(when converter
|
|
|
|
|
(dolist (c capabilities)
|
|
|
|
|
(when (member in-fmt (nth 1 c))
|
|
|
|
|
(push (cons converter (nth 2 c)) reachable-formats))))
|
|
|
|
|
reachable-formats))
|
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-reachable-formats (in-fmt)
|
2012-04-05 11:43:14 +00:00
|
|
|
|
"Return list of formats to which IN-FMT can be converted.
|
|
|
|
|
The list of the form (OUTPUT-FMT-1 OUTPUT-FMT-2 ...)."
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(copy-sequence
|
|
|
|
|
(apply #'append (mapcar
|
|
|
|
|
(lambda (e) (mapcar #'car (cdr e)))
|
|
|
|
|
(org-odt-do-reachable-formats in-fmt)))))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(defun org-odt-convert-read-params ()
|
|
|
|
|
"Return IN-FILE and OUT-FMT params for `org-odt-do-convert'.
|
2012-04-05 11:43:14 +00:00
|
|
|
|
This is a helper routine for interactive use."
|
|
|
|
|
(let* ((input (if (featurep 'ido) 'ido-completing-read 'completing-read))
|
|
|
|
|
(in-file (read-file-name "File to be converted: "
|
|
|
|
|
nil buffer-file-name t))
|
|
|
|
|
(in-fmt (file-name-extension in-file))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(out-fmt-choices (org-odt-reachable-formats in-fmt))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(out-fmt
|
|
|
|
|
(or (and out-fmt-choices
|
2013-02-12 21:26:39 +00:00
|
|
|
|
(funcall input "Output format: "
|
2012-04-05 11:43:14 +00:00
|
|
|
|
out-fmt-choices nil nil nil))
|
|
|
|
|
(error
|
|
|
|
|
"No known converter or no known output formats for %s files"
|
|
|
|
|
in-fmt))))
|
|
|
|
|
(list in-file out-fmt)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(defun org-odt-convert (&optional in-file out-fmt open)
|
2012-04-05 11:43:14 +00:00
|
|
|
|
"Convert IN-FILE to format OUT-FMT using a command line converter.
|
|
|
|
|
IN-FILE is the file to be converted. If unspecified, it defaults
|
|
|
|
|
to variable `buffer-file-name'. OUT-FMT is the desired output
|
2015-10-31 23:58:57 +00:00
|
|
|
|
format. Use `org-odt-convert-process' as the converter. If OPEN
|
|
|
|
|
is non-nil then the newly converted file is opened using
|
|
|
|
|
`org-open-file'."
|
2012-04-05 11:43:14 +00:00
|
|
|
|
(interactive
|
2013-01-27 22:11:34 +00:00
|
|
|
|
(append (org-odt-convert-read-params) current-prefix-arg))
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(org-odt-do-convert in-file out-fmt open))
|
2012-04-05 11:43:14 +00:00
|
|
|
|
|
2012-02-22 14:44:21 +00:00
|
|
|
|
;;; Library Initializations
|
|
|
|
|
|
2015-10-31 23:58:57 +00:00
|
|
|
|
(dolist (desc org-odt-file-extensions)
|
|
|
|
|
;; Let Emacs open all OpenDocument files in archive mode.
|
|
|
|
|
(add-to-list 'auto-mode-alist
|
|
|
|
|
(cons (concat "\\." (car desc) "\\'") 'archive-mode)))
|
2013-01-27 22:11:34 +00:00
|
|
|
|
|
|
|
|
|
(provide 'ox-odt)
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;; Local variables:
|
|
|
|
|
;; generated-autoload-file: "org-loaddefs.el"
|
|
|
|
|
;; End:
|
2012-02-22 14:44:21 +00:00
|
|
|
|
|
2013-01-27 22:11:34 +00:00
|
|
|
|
;;; ox-odt.el ends here
|