2015-08-14 17:50:51 -04:00
|
|
|
|
;;; test-ox.el --- Tests for ox.el -*- lexical-binding: t; -*-
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
2019-01-01 05:50:56 -05:00
|
|
|
|
;; Copyright (C) 2012-2016, 2019 Nicolas Goaziou
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
|
|
|
|
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
|
|
|
|
|
|
2012-12-13 11:24:19 -05:00
|
|
|
|
;; This file is not part of GNU Emacs.
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
2012-12-13 11:24:19 -05:00
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
2012-12-13 11:24:19 -05:00
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2021-03-20 03:27:57 -04:00
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
2012-02-29 12:38:54 -05:00
|
|
|
|
|
2015-11-06 07:04:20 -05:00
|
|
|
|
(require 'cl-lib)
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(require 'ox)
|
|
|
|
|
(require 'org-inlinetask)
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(defun org-test-default-backend ()
|
2023-04-20 08:11:19 -04:00
|
|
|
|
"Return a default export backend.
|
|
|
|
|
This backend simply returns parsed data as Org syntax."
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-create-backend
|
2015-08-14 17:50:51 -04:00
|
|
|
|
:transcoders
|
|
|
|
|
(mapcar (lambda (type)
|
|
|
|
|
(cons type
|
|
|
|
|
(lambda (o c _)
|
|
|
|
|
(funcall
|
|
|
|
|
(intern (format "org-element-%s-interpreter" type))
|
|
|
|
|
o c))))
|
|
|
|
|
(append org-element-all-elements org-element-all-objects))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
(defmacro org-test-with-parsed-data (data &rest body)
|
|
|
|
|
"Execute body with parsed data available.
|
|
|
|
|
DATA is a string containing the data to be parsed. BODY is the
|
|
|
|
|
body to execute. Parse tree is available under the `tree'
|
2015-01-23 17:59:23 -05:00
|
|
|
|
variable, and communication channel under `info'."
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
(declare (debug (form body)) (indent 1))
|
|
|
|
|
`(org-test-with-temp-text ,data
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(org-export--delete-comment-trees)
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
2015-11-05 04:54:43 -05:00
|
|
|
|
(info (org-combine-plists
|
|
|
|
|
(org-export--get-export-attributes)
|
|
|
|
|
(org-export-get-environment))))
|
2015-03-23 19:06:56 -04:00
|
|
|
|
(org-export--prune-tree tree info)
|
|
|
|
|
(org-export--remove-uninterpreted-data tree info)
|
2015-01-23 17:59:23 -05:00
|
|
|
|
(let ((info (org-combine-plists
|
2015-11-05 04:56:59 -05:00
|
|
|
|
info (org-export--collect-tree-properties tree info))))
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(ignore info) ;; Don't warn if the var is unused.
|
2015-01-23 17:59:23 -05:00
|
|
|
|
,@body))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
2012-05-26 07:44:13 -04:00
|
|
|
|
|
|
|
|
|
|
2012-09-01 06:59:57 -04:00
|
|
|
|
;;; Internal Tests
|
|
|
|
|
|
2022-10-07 05:46:15 -04:00
|
|
|
|
(ert-deftest test-org-export/org-export-copy-buffer ()
|
|
|
|
|
"Test `org-export-copy-buffer' specifications."
|
2022-10-09 02:31:10 -04:00
|
|
|
|
;; The copy must not overwrite the original file.
|
2022-10-07 05:46:15 -04:00
|
|
|
|
(org-test-with-temp-text-in-file
|
|
|
|
|
"* Heading"
|
|
|
|
|
(let ((file (buffer-file-name)))
|
|
|
|
|
(with-current-buffer (org-export-copy-buffer)
|
2022-10-09 02:31:10 -04:00
|
|
|
|
(insert "This must not go into the original file.")
|
2022-10-07 05:46:15 -04:00
|
|
|
|
(save-buffer)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"* Heading"
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents file)
|
2022-10-09 02:31:10 -04:00
|
|
|
|
(buffer-string)))))))
|
|
|
|
|
;; The copy must not show when re-opening the original file.
|
|
|
|
|
(org-test-with-temp-text-in-file
|
|
|
|
|
"* Heading"
|
|
|
|
|
(let ((file (buffer-file-name))
|
|
|
|
|
(buffer-copy (generate-new-buffer " *Org export copy*")))
|
|
|
|
|
(org-export-with-buffer-copy
|
|
|
|
|
:to-buffer buffer-copy
|
|
|
|
|
(insert "This must not show as the original file.")
|
|
|
|
|
(save-buffer))
|
|
|
|
|
;; Unassign the original buffer from file.
|
|
|
|
|
(setq buffer-file-name nil)
|
|
|
|
|
(should-not
|
|
|
|
|
(equal buffer-copy (get-file-buffer file))))))
|
2022-10-07 05:46:15 -04:00
|
|
|
|
|
2012-09-01 06:59:57 -04:00
|
|
|
|
(ert-deftest test-org-export/bind-keyword ()
|
|
|
|
|
"Test reading #+BIND: keywords."
|
2013-01-27 17:11:34 -05:00
|
|
|
|
;; Test with `org-export-allow-bind-keywords' set to t.
|
2012-09-01 06:59:57 -04:00
|
|
|
|
(should
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-test-with-temp-text "#+BIND: test-ox-var value"
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(let ((org-export-allow-bind-keywords t))
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-export-get-environment)
|
|
|
|
|
(eq test-ox-var 'value))))
|
2013-01-27 17:11:34 -05:00
|
|
|
|
;; Test with `org-export-allow-bind-keywords' set to nil.
|
2012-09-01 06:59:57 -04:00
|
|
|
|
(should-not
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-test-with-temp-text "#+BIND: test-ox-var value"
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(let ((org-export-allow-bind-keywords nil))
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-export-get-environment)
|
|
|
|
|
(boundp 'test-ox-var))))
|
2012-09-01 08:19:42 -04:00
|
|
|
|
;; BIND keywords are case-insensitive.
|
|
|
|
|
(should
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-test-with-temp-text "#+bind: test-ox-var value"
|
2013-03-29 16:21:48 -04:00
|
|
|
|
(let ((org-export-allow-bind-keywords t))
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-export-get-environment)
|
|
|
|
|
(eq test-ox-var 'value))))
|
2013-03-29 16:21:48 -04:00
|
|
|
|
;; Preserve order of BIND keywords.
|
|
|
|
|
(should
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-test-with-temp-text "#+BIND: test-ox-var 1\n#+BIND: test-ox-var 2"
|
2013-03-29 16:21:48 -04:00
|
|
|
|
(let ((org-export-allow-bind-keywords t))
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-export-get-environment)
|
|
|
|
|
(eq test-ox-var 2))))
|
2013-03-29 16:21:48 -04:00
|
|
|
|
;; Read BIND keywords in setup files.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+SETUPFILE: \"%s/examples/setupfile.org\"" org-test-dir)
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(let ((org-export-allow-bind-keywords t))
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(org-export-get-environment)
|
2022-09-15 23:30:16 -04:00
|
|
|
|
;; `variable' is bound inside the setupfile.
|
2013-04-01 09:18:47 -04:00
|
|
|
|
(eq variable 'value))))
|
|
|
|
|
;; Verify that bound variables are seen during export.
|
|
|
|
|
(should
|
|
|
|
|
(equal "Yes\n"
|
|
|
|
|
(org-test-with-temp-text "#+BIND: test-ox-var value"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(let ((org-export-allow-bind-keywords t))
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
2013-04-01 09:18:47 -04:00
|
|
|
|
'((section . (lambda (s c i)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(if (eq test-ox-var 'value) "Yes" "No")))))))))))
|
2012-05-26 07:44:13 -04:00
|
|
|
|
|
2012-02-22 18:57:59 -05:00
|
|
|
|
(ert-deftest test-org-export/parse-option-keyword ()
|
|
|
|
|
"Test reading all standard #+OPTIONS: items."
|
|
|
|
|
(should
|
2015-09-09 16:50:08 -04:00
|
|
|
|
(let ((options
|
|
|
|
|
(org-export--parse-option-keyword
|
|
|
|
|
"H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t \
|
|
|
|
|
*:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil \
|
|
|
|
|
stat:t title:t")))
|
|
|
|
|
(and (eq (plist-get options :headline-levels) 1)
|
|
|
|
|
(eq (plist-get options :section-numbers) t)
|
|
|
|
|
(eq (plist-get options :preserve-breaks) t)
|
|
|
|
|
(eq (plist-get options :time-stamp-file) t)
|
|
|
|
|
(eq (plist-get options :with-archived-trees) t)
|
|
|
|
|
(eq (plist-get options :with-author) t)
|
|
|
|
|
(eq (plist-get options :with-drawers) t)
|
|
|
|
|
(eq (plist-get options :with-email) t)
|
|
|
|
|
(eq (plist-get options :with-emphasize) t)
|
|
|
|
|
(eq (plist-get options :with-entities) t)
|
|
|
|
|
(eq (plist-get options :with-fixed-width) t)
|
|
|
|
|
(eq (plist-get options :with-footnotes) t)
|
|
|
|
|
(eq (plist-get options :with-priority) t)
|
|
|
|
|
(eq (plist-get options :with-special-strings) t)
|
|
|
|
|
(eq (plist-get options :with-sub-superscript) t)
|
|
|
|
|
(eq (plist-get options :with-toc) t)
|
|
|
|
|
(eq (plist-get options :with-tables) t)
|
|
|
|
|
(eq (plist-get options :with-tags) t)
|
|
|
|
|
(eq (plist-get options :with-tasks) t)
|
|
|
|
|
(eq (plist-get options :with-timestamps) t)
|
|
|
|
|
(eq (plist-get options :with-todo-keywords) t)
|
|
|
|
|
(eq (plist-get options :with-inlinetasks) nil)
|
|
|
|
|
(eq (plist-get options :with-statistics-cookies) t)
|
|
|
|
|
(eq (plist-get options :with-title) t))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
;; Test some special values.
|
|
|
|
|
(should
|
2015-09-09 16:50:08 -04:00
|
|
|
|
(let ((options
|
|
|
|
|
(org-export--parse-option-keyword
|
|
|
|
|
"arch:headline d:(\"TEST\") ^:{} toc:1 tags:not-in-toc tasks:todo \
|
|
|
|
|
num:2 <:active")))
|
|
|
|
|
(and (eq (plist-get options :with-archived-trees) 'headline)
|
|
|
|
|
(eq (plist-get options :with-sub-superscript) '{})
|
|
|
|
|
(eq (plist-get options :with-toc) 1)
|
|
|
|
|
(eq (plist-get options :with-tags) 'not-in-toc)
|
|
|
|
|
(eq (plist-get options :with-tasks) 'todo)
|
|
|
|
|
(eq (plist-get options :section-numbers) 2)
|
|
|
|
|
(eq (plist-get options :with-timestamps) 'active)
|
|
|
|
|
(equal (plist-get options :with-drawers) '("TEST")))))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Test backend specific values.
|
2015-04-22 08:05:37 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-export--parse-option-keyword
|
|
|
|
|
"opt:t" (org-export-create-backend :options '((:option nil "opt"))))
|
2015-09-09 16:50:08 -04:00
|
|
|
|
'(:option t)))
|
|
|
|
|
;; More than one property can refer to the same option item.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(:opt1 t :opt2 t)
|
|
|
|
|
(org-export--parse-option-keyword
|
|
|
|
|
"opt:t"
|
|
|
|
|
(org-export-create-backend
|
2021-04-10 06:06:47 -04:00
|
|
|
|
:options '((:opt1 nil "opt") (:opt2 nil "opt"))))))
|
|
|
|
|
;; Ignore options with a missing value.
|
|
|
|
|
(should
|
|
|
|
|
(let ((options (org-export--parse-option-keyword "H: num:t")))
|
|
|
|
|
(and (not (plist-get options :headline-levels))
|
2022-11-16 23:49:29 -05:00
|
|
|
|
(plist-get options :section-numbers))))
|
|
|
|
|
;; Parse spaces inside brackets.
|
|
|
|
|
(let ((options (org-export--parse-option-keyword "html-postamble:\"test space\"" 'html)))
|
|
|
|
|
(should (equal "test space" (plist-get options :html-postamble)))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-inbuffer-options ()
|
|
|
|
|
"Test reading all standard export keywords."
|
2013-02-26 17:32:36 -05:00
|
|
|
|
;; Properties should follow buffer order.
|
2012-02-22 18:57:59 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2013-02-26 17:32:36 -05:00
|
|
|
|
(org-test-with-temp-text "#+LANGUAGE: fr\n#+CREATOR: Me\n#+EMAIL: email"
|
2012-07-24 10:04:35 -04:00
|
|
|
|
(org-export--get-inbuffer-options))
|
2013-02-26 17:32:36 -05:00
|
|
|
|
'(:language "fr" :creator "Me" :email "email")))
|
|
|
|
|
;; Test `space' behaviour.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2023-04-20 08:11:19 -04:00
|
|
|
|
(let ((backend (org-export-create-backend
|
2015-04-05 04:23:28 -04:00
|
|
|
|
:options '((:keyword "KEYWORD" nil nil space)))))
|
|
|
|
|
(org-test-with-temp-text "#+KEYWORD: With\n#+KEYWORD: spaces"
|
2023-04-20 08:11:19 -04:00
|
|
|
|
(org-export--get-inbuffer-options backend)))
|
2015-04-05 04:23:28 -04:00
|
|
|
|
'(:keyword "With spaces")))
|
2013-02-26 17:32:36 -05:00
|
|
|
|
;; Test `newline' behaviour.
|
2015-04-05 04:23:28 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2023-04-20 08:11:19 -04:00
|
|
|
|
(let ((backend (org-export-create-backend
|
2015-04-05 04:23:28 -04:00
|
|
|
|
:options '((:keyword "KEYWORD" nil nil newline)))))
|
|
|
|
|
(org-test-with-temp-text "#+KEYWORD: With\n#+KEYWORD: two lines"
|
2023-04-20 08:11:19 -04:00
|
|
|
|
(org-export--get-inbuffer-options backend)))
|
2015-04-05 04:23:28 -04:00
|
|
|
|
'(:keyword "With\ntwo lines")))
|
2013-02-26 17:32:36 -05:00
|
|
|
|
;; Test `split' behaviour.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-test-with-temp-text "#+SELECT_TAGS: a\n#+SELECT_TAGS: b"
|
|
|
|
|
(org-export--get-inbuffer-options))
|
|
|
|
|
'(:select-tags ("a" "b"))))
|
2015-04-09 08:08:34 -04:00
|
|
|
|
;; Test `parse' behaviour. `parse' implies `space' but preserve
|
|
|
|
|
;; line breaks. Multi-line objects are allowed.
|
2015-04-05 04:23:28 -04:00
|
|
|
|
(should
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-test-with-temp-text "#+TITLE: *bold*"
|
|
|
|
|
(plist-get (org-export--get-inbuffer-options) :title))
|
|
|
|
|
'bold #'identity nil t))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-test-with-temp-text "#+TITLE: Some title\n#+TITLE: with spaces"
|
|
|
|
|
(plist-get (org-export--get-inbuffer-options) :title))
|
2015-04-09 08:08:34 -04:00
|
|
|
|
'("Some title with spaces")))
|
|
|
|
|
(should
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-test-with-temp-text "#+TITLE: Some title\\\\\n#+TITLE: with spaces"
|
|
|
|
|
(plist-get (org-export--get-inbuffer-options) :title))
|
|
|
|
|
'line-break #'identity nil t))
|
|
|
|
|
(should
|
|
|
|
|
(org-element-map
|
|
|
|
|
(org-test-with-temp-text "#+TITLE: *bold\n#+TITLE: sentence*"
|
|
|
|
|
(plist-get (org-export--get-inbuffer-options) :title))
|
|
|
|
|
'bold #'identity nil t))
|
2013-02-26 17:32:36 -05:00
|
|
|
|
;; Options set through SETUPFILE.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+DESCRIPTION: l1
|
|
|
|
|
#+LANGUAGE: es
|
|
|
|
|
#+SELECT_TAGS: a
|
|
|
|
|
#+TITLE: a
|
|
|
|
|
#+SETUPFILE: \"%s/examples/setupfile.org\"
|
|
|
|
|
#+LANGUAGE: fr
|
|
|
|
|
#+SELECT_TAGS: c
|
|
|
|
|
#+TITLE: c"
|
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export--get-inbuffer-options))
|
2015-04-09 08:08:34 -04:00
|
|
|
|
'(:language "fr" :select-tags ("a" "b" "c") :title ("a b c"))))
|
2017-06-13 11:41:14 -04:00
|
|
|
|
;; Options set through SETUPFILE specified using a URL.
|
2022-07-20 11:35:38 -04:00
|
|
|
|
(let ((buffer (generate-new-buffer "url-retrieve-output"))
|
|
|
|
|
(org-resource-download-policy t))
|
2017-06-13 11:41:14 -04:00
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Simulate successful retrieval of a setupfile from URL.
|
|
|
|
|
(cl-letf (((symbol-function 'url-retrieve-synchronously)
|
|
|
|
|
(lambda (&rest_)
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(insert "HTTP/1.1 200 OK
|
|
|
|
|
|
|
|
|
|
# Contents of http://link-to-my-setupfile.org
|
|
|
|
|
#+BIND: variable value
|
|
|
|
|
#+DESCRIPTION: l2
|
|
|
|
|
#+LANGUAGE: en
|
|
|
|
|
#+SELECT_TAGS: b
|
|
|
|
|
#+TITLE: b
|
|
|
|
|
#+PROPERTY: a 1
|
|
|
|
|
"))
|
|
|
|
|
buffer)))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+DESCRIPTION: l1
|
|
|
|
|
#+LANGUAGE: es
|
|
|
|
|
#+SELECT_TAGS: a
|
|
|
|
|
#+TITLE: a
|
|
|
|
|
#+SETUPFILE: \"http://link-to-my-setupfile.org\"
|
|
|
|
|
#+LANGUAGE: fr
|
|
|
|
|
#+SELECT_TAGS: c
|
|
|
|
|
#+TITLE: c"
|
|
|
|
|
(org-export--get-inbuffer-options))
|
|
|
|
|
'(:language "fr" :select-tags ("a" "b" "c") :title ("a b c")))))
|
|
|
|
|
(kill-buffer buffer)))
|
2013-07-22 09:13:42 -04:00
|
|
|
|
;; More than one property can refer to the same buffer keyword.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(:k2 "value" :k1 "value")
|
|
|
|
|
(let ((backend (org-export-create-backend
|
|
|
|
|
:options '((:k1 "KEYWORD")
|
|
|
|
|
(:k2 "KEYWORD")))))
|
|
|
|
|
(org-test-with-temp-text "#+KEYWORD: value"
|
2015-03-23 19:32:15 -04:00
|
|
|
|
(org-export--get-inbuffer-options backend)))))
|
|
|
|
|
;; Keywords in commented subtrees are ignored.
|
|
|
|
|
(should-not
|
|
|
|
|
(equal "Me"
|
|
|
|
|
(org-test-with-parsed-data "* COMMENT H1\n#+AUTHOR: Me"
|
2015-04-05 04:23:28 -04:00
|
|
|
|
(plist-get info :author))))
|
2015-03-23 19:32:15 -04:00
|
|
|
|
(should-not
|
|
|
|
|
(equal "Mine"
|
|
|
|
|
(org-test-with-parsed-data "* COMMENT H1\n** H2\n#+EMAIL: Mine"
|
2020-05-19 20:29:33 -04:00
|
|
|
|
(plist-get info :email))))
|
|
|
|
|
;; Keywords can be set to an empty value.
|
|
|
|
|
(should-not
|
|
|
|
|
(let ((user-full-name "Me"))
|
|
|
|
|
(org-test-with-parsed-data "#+AUTHOR:"
|
|
|
|
|
(plist-get info :author)))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
2012-07-04 17:30:23 -04:00
|
|
|
|
(ert-deftest test-org-export/get-subtree-options ()
|
|
|
|
|
"Test setting options from headline's properties."
|
|
|
|
|
;; EXPORT_TITLE.
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '("Subtree Title")
|
|
|
|
|
(org-test-with-temp-text "#+TITLE: Title
|
|
|
|
|
* Headline<point>
|
2012-07-04 17:30:23 -04:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:EXPORT_TITLE: Subtree Title
|
|
|
|
|
:END:
|
|
|
|
|
Paragraph"
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(plist-get (org-export-get-environment nil t) :title))))
|
2012-07-04 17:30:23 -04:00
|
|
|
|
;; EXPORT_OPTIONS.
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 2
|
|
|
|
|
(org-test-with-temp-text "#+OPTIONS: H:1
|
|
|
|
|
* Headline<point>
|
2012-07-04 17:30:23 -04:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:EXPORT_OPTIONS: H:2
|
|
|
|
|
:END:
|
|
|
|
|
Paragraph"
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(plist-get (org-export-get-environment nil t) :headline-levels))))
|
2012-07-25 06:25:58 -04:00
|
|
|
|
;; EXPORT_DATE.
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '("29-03-2012")
|
|
|
|
|
(org-test-with-temp-text "#+DATE: today
|
|
|
|
|
* Headline<point>
|
2012-07-04 17:30:23 -04:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:EXPORT_DATE: 29-03-2012
|
|
|
|
|
:END:
|
|
|
|
|
Paragraph"
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(plist-get (org-export-get-environment nil t) :date))))
|
2012-11-18 08:44:20 -05:00
|
|
|
|
;; Properties with `split' behaviour are stored as a list of
|
|
|
|
|
;; strings.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("a" "b")
|
|
|
|
|
(org-test-with-temp-text "#+EXCLUDE_TAGS: noexport
|
2015-06-23 16:09:43 -04:00
|
|
|
|
* Headline<point>
|
2012-11-18 08:44:20 -05:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:EXPORT_EXCLUDE_TAGS: a b
|
|
|
|
|
:END:
|
|
|
|
|
Paragraph"
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(plist-get (org-export-get-environment nil t) :exclude-tags))))
|
2012-11-18 08:44:20 -05:00
|
|
|
|
;; Handle :PROPERTY+: syntax.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("a" "b")
|
|
|
|
|
(org-test-with-temp-text "#+EXCLUDE_TAGS: noexport
|
2015-06-23 16:09:43 -04:00
|
|
|
|
* Headline<point>
|
2012-11-18 08:44:20 -05:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:EXPORT_EXCLUDE_TAGS: a
|
|
|
|
|
:EXPORT_EXCLUDE_TAGS+: b
|
|
|
|
|
:END:
|
|
|
|
|
Paragraph"
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(plist-get (org-export-get-environment nil t) :exclude-tags))))
|
2012-07-25 06:25:58 -04:00
|
|
|
|
;; Export properties are case-insensitive.
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '("29-03-2012")
|
|
|
|
|
(org-test-with-temp-text "* Headline
|
2012-07-25 06:25:58 -04:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:EXPORT_Date: 29-03-2012
|
|
|
|
|
:END:
|
|
|
|
|
Paragraph"
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(plist-get (org-export-get-environment nil t) :date))))
|
2013-01-26 12:05:56 -05:00
|
|
|
|
;; Still grab correct options when section above is empty.
|
|
|
|
|
(should
|
2022-10-18 00:07:37 -04:00
|
|
|
|
(equal '("H12")
|
2015-06-23 16:09:43 -04:00
|
|
|
|
(org-test-with-temp-text "* H1\n** H11\n** H12<point>"
|
|
|
|
|
(plist-get (org-export-get-environment nil t) :title))))
|
|
|
|
|
;; More than one property can refer to the same node property.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("1" "1")
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\n:PROPERTIES:\n:EXPORT_A: 1\n:END:\n<point>"
|
|
|
|
|
(let* ((backend (org-export-create-backend
|
|
|
|
|
:options '((:k1 "A")
|
|
|
|
|
(:k2 "A"))))
|
|
|
|
|
(options (org-export-get-environment backend t)))
|
|
|
|
|
(list (plist-get options :k1) (plist-get options :k2)))))))
|
2012-07-04 17:30:23 -04:00
|
|
|
|
|
2022-12-13 03:44:59 -05:00
|
|
|
|
(ert-deftest test-org-export/get-ordinal ()
|
|
|
|
|
"Test specifications for `org-export-get-ordinal'."
|
|
|
|
|
;; Table numbering with, without predicates, and with other types.
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+title: Table numbering test
|
|
|
|
|
#+options: author:nil toc:nil
|
|
|
|
|
|
|
|
|
|
#+caption: Should be Table 1
|
|
|
|
|
| h1 | h2 | h3 |
|
|
|
|
|
|----------+----------+----------|
|
|
|
|
|
| abcdefgh | ijklmnop | qrstuvwx |
|
|
|
|
|
|
|
|
|
|
#+caption: Should be Table 2
|
|
|
|
|
| h1 | h2 | h3 |
|
|
|
|
|
|----------+----------+----------|
|
|
|
|
|
| abcdefgh | ijklmnop | qrstuvwx |
|
|
|
|
|
|
|
|
|
|
#+caption: Should be Table 3
|
|
|
|
|
| h1 | h2 | h3 |
|
|
|
|
|
|----------+----------+----------|
|
|
|
|
|
| abcdefgh | ijklmnop | qrstuvwx |
|
|
|
|
|
|
|
|
|
|
#+caption: Should be Table 4
|
|
|
|
|
| h1 | h2 | h3 |
|
|
|
|
|
|----------+----------+----------|
|
|
|
|
|
| abcdefgh | ijklmnop | qrstuvwx |"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'org
|
|
|
|
|
:transcoders
|
|
|
|
|
'((table
|
|
|
|
|
.
|
|
|
|
|
(lambda (table contents info)
|
|
|
|
|
(let ((from-third (lambda (table info)
|
|
|
|
|
(<= 3 (org-export-get-ordinal table info)))))
|
|
|
|
|
(pcase (org-element-interpret-data (org-export-get-caption table))
|
|
|
|
|
("Should be Table 1"
|
|
|
|
|
(should (= 1 (org-export-get-ordinal table info)))
|
|
|
|
|
(should (= 2 (org-export-get-ordinal table info '(section))))
|
|
|
|
|
(should (= 1 (org-export-get-ordinal table info nil #'org-ascii--has-caption-p)))
|
2024-01-25 07:28:14 -05:00
|
|
|
|
(should-not (org-export-get-ordinal table info nil from-third)))
|
2022-12-13 03:44:59 -05:00
|
|
|
|
("Should be Table 2"
|
|
|
|
|
(should (= 2 (org-export-get-ordinal table info)))
|
|
|
|
|
(should (= 3 (org-export-get-ordinal table info '(section))))
|
|
|
|
|
(should (= 2 (org-export-get-ordinal table info nil #'org-ascii--has-caption-p)))
|
2024-01-25 07:28:14 -05:00
|
|
|
|
(should-not (org-export-get-ordinal table info nil from-third)))
|
2022-12-13 03:44:59 -05:00
|
|
|
|
("Should be Table 3"
|
|
|
|
|
(should (= 3 (org-export-get-ordinal table info)))
|
|
|
|
|
(should (= 4 (org-export-get-ordinal table info '(section))))
|
|
|
|
|
(should (= 3 (org-export-get-ordinal table info nil #'org-ascii--has-caption-p)))
|
|
|
|
|
(should (= 1 (org-export-get-ordinal table info nil from-third))))
|
|
|
|
|
("Should be Table 4"
|
|
|
|
|
(should (= 4 (org-export-get-ordinal table info)))
|
|
|
|
|
(should (= 5 (org-export-get-ordinal table info '(section))))
|
|
|
|
|
(should (= 4 (org-export-get-ordinal table info nil #'org-ascii--has-caption-p)))
|
|
|
|
|
(should (= 2 (org-export-get-ordinal table info nil from-third))))))
|
|
|
|
|
"")))))))
|
|
|
|
|
|
2013-05-08 09:34:53 -04:00
|
|
|
|
(ert-deftest test-org-export/set-title ()
|
|
|
|
|
"Test title setting."
|
2014-06-15 16:39:29 -04:00
|
|
|
|
;; Without TITLE keyword.
|
2013-05-08 09:34:53 -04:00
|
|
|
|
(should
|
2014-06-15 16:39:29 -04:00
|
|
|
|
(equal
|
|
|
|
|
""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "Test"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((template . (lambda (text info)
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(plist-get info :title)))))))))))
|
2014-06-15 16:39:29 -04:00
|
|
|
|
;; With a blank TITLE keyword.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "#+TITLE:\nTest"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((template . (lambda (text info)
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(plist-get info :title)))))))))))
|
2014-06-15 16:39:29 -04:00
|
|
|
|
;; With a non-empty TITLE keyword.
|
2013-05-08 09:34:53 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"Title"
|
2014-06-15 16:39:29 -04:00
|
|
|
|
(org-test-with-temp-text "#+TITLE: Title\nTest"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((template . (lambda (text info)
|
|
|
|
|
(org-element-interpret-data
|
2013-11-11 07:16:43 -05:00
|
|
|
|
(plist-get info :title))))))))))
|
2014-06-15 16:39:29 -04:00
|
|
|
|
;; When exporting a subtree, its heading becomes the headline of the
|
|
|
|
|
;; document...
|
2013-05-08 09:34:53 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2014-06-15 16:39:29 -04:00
|
|
|
|
"Headline"
|
|
|
|
|
(org-test-with-temp-text "* Headline\nBody"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((template . (lambda (text info)
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(plist-get info :title))))))
|
|
|
|
|
'subtree))))
|
|
|
|
|
;; ... unless there is an EXPORT_TITLE property at the root of the
|
|
|
|
|
;; subtree.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"B"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* A\n :PROPERTIES:\n :EXPORT_TITLE: B\n :END:\nBody"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((template . (lambda (text info)
|
|
|
|
|
(org-element-interpret-data
|
2014-06-15 16:39:29 -04:00
|
|
|
|
(plist-get info :title))))))
|
|
|
|
|
'subtree)))))
|
2013-05-08 09:34:53 -04:00
|
|
|
|
|
2012-02-22 18:57:59 -05:00
|
|
|
|
(ert-deftest test-org-export/handle-options ()
|
|
|
|
|
"Test if export options have an impact on output."
|
2013-03-02 08:34:45 -05:00
|
|
|
|
;; Test exclude tags for headlines and inlinetasks.
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "* Head1 :noexp:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:exclude-tags ("noexp")))))))
|
2015-11-10 17:38:04 -05:00
|
|
|
|
(should
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(equal "#+filetags: noexp\n"
|
2015-11-10 17:38:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "#+FILETAGS: noexp\n* Head1"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:exclude-tags ("noexp")))))))
|
2018-02-03 18:11:18 -05:00
|
|
|
|
;; Excluding a tag excludes its whole group.
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "* Head1 :baz:"
|
|
|
|
|
(let ((org-tag-alist '((:startgrouptag)
|
|
|
|
|
("foo") (:grouptags) ("bar") ("baz")
|
|
|
|
|
(:endgrouptag))))
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:exclude-tags ("foo"))))))))
|
2013-03-02 08:34:45 -05:00
|
|
|
|
;; Test include tags for headlines and inlinetasks.
|
|
|
|
|
(should
|
2015-11-10 17:38:04 -05:00
|
|
|
|
(equal (org-test-with-temp-text "* H1\n* H2\n** Sub :exp:\n*** Sub Sub\n* H3"
|
2013-03-02 08:34:45 -05:00
|
|
|
|
(let ((org-tags-column 0))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
2015-11-10 17:38:04 -05:00
|
|
|
|
nil nil nil '(:select-tags ("exp")))))
|
|
|
|
|
"* H2\n** Sub :exp:\n*** Sub Sub\n"))
|
2018-02-03 18:11:18 -05:00
|
|
|
|
;; Including a tag includes its whole group.
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
|
|
|
|
"\\`\\* H2"
|
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "* H1\n* H2 :bar:"
|
|
|
|
|
(let ((org-tag-alist '((:startgrouptag)
|
|
|
|
|
("foo") (:grouptags) ("bar") ("baz")
|
|
|
|
|
(:endgrouptag))))
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:select-tags ("foo"))))))))
|
2013-09-25 12:49:39 -04:00
|
|
|
|
;; If there is an include tag, ignore the section before the first
|
|
|
|
|
;; headline, if any.
|
|
|
|
|
(should
|
2015-11-10 17:38:04 -05:00
|
|
|
|
(equal (org-test-with-temp-text "First section\n* H1 :exp:\nBody"
|
2013-09-25 12:49:39 -04:00
|
|
|
|
(let ((org-tags-column 0))
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
2015-11-10 17:38:04 -05:00
|
|
|
|
nil nil nil '(:select-tags ("exp")))))
|
|
|
|
|
"* H1 :exp:\nBody\n"))
|
|
|
|
|
(should
|
|
|
|
|
(equal (org-test-with-temp-text "#+FILETAGS: exp\nFirst section\n* H1\nBody"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:select-tags ("exp"))))
|
|
|
|
|
"* H1\nBody\n"))
|
2013-09-25 12:49:39 -04:00
|
|
|
|
(should-not
|
2015-11-10 17:38:04 -05:00
|
|
|
|
(equal (org-test-with-temp-text "* H1 :exp:\nBody"
|
2013-09-25 12:49:39 -04:00
|
|
|
|
(let ((org-tags-column 0))
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
2015-11-10 17:38:04 -05:00
|
|
|
|
nil nil nil '(:select-tags ("exp")))))
|
|
|
|
|
"* H1 :exp:\n"))
|
2012-02-23 08:52:25 -05:00
|
|
|
|
;; Test mixing include tags and exclude tags.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"\\* Head1[ \t]+:export:\n\\*\\* Sub-Head2\n"
|
|
|
|
|
(org-test-with-temp-text "
|
2012-02-23 08:52:25 -05:00
|
|
|
|
* Head1 :export:
|
|
|
|
|
** Sub-Head1 :noexport:
|
|
|
|
|
** Sub-Head2
|
|
|
|
|
* Head2 :noexport:
|
|
|
|
|
** Sub-Head1 :export:"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend) nil nil nil
|
|
|
|
|
'(:select-tags ("export") :exclude-tags ("noexport"))))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
;; Ignore tasks.
|
2013-03-02 08:34:45 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let ((org-todo-keywords '((sequence "TODO" "DONE")))
|
|
|
|
|
org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
2013-03-02 08:34:45 -05:00
|
|
|
|
(org-test-with-temp-text "* TODO Head1"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-tasks nil))))))
|
2013-03-02 08:34:45 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "* TODO Head1\n"
|
|
|
|
|
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
|
|
|
|
|
(org-test-with-temp-text "* TODO Head1"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-tasks t))))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
;; Archived tree.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
2021-11-20 05:37:52 -05:00
|
|
|
|
(org-test-with-temp-text "* Head1 :ARCHIVE:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-archived-trees nil))))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(string-match
|
2021-11-20 05:37:52 -05:00
|
|
|
|
"\\* Head1[ \t]+:ARCHIVE:"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "* Head1 :archive:\nbody\n** Sub-head 2"
|
2021-11-20 05:37:52 -05:00
|
|
|
|
(org-export-as (org-test-default-backend) nil nil nil
|
|
|
|
|
'(:with-archived-trees headline)))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(string-match
|
2021-11-20 05:37:52 -05:00
|
|
|
|
"\\`\\* Head1[ \t]+:ARCHIVE:\n\\'"
|
|
|
|
|
(org-test-with-temp-text "* Head1 :ARCHIVE:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-archived-trees t)))))
|
2015-10-18 17:02:15 -04:00
|
|
|
|
;; Broken links. Depending on `org-export-with-broken-links', raise
|
|
|
|
|
;; an error, ignore link or mark is as broken in output.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "[[#broken][link]]"
|
|
|
|
|
(let ((backend
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (_e c _i) c))
|
|
|
|
|
(paragraph . (lambda (_e c _i) c))
|
|
|
|
|
(link . (lambda (l c i) (org-export-resolve-id-link l i)))))))
|
|
|
|
|
(org-export-as backend nil nil nil '(:with-broken-links nil)))))
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "[[#broken][link]]"
|
|
|
|
|
(let ((backend
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (_e c _i) c))
|
|
|
|
|
(paragraph . (lambda (_e c _i) c))
|
|
|
|
|
(link . (lambda (l c i) (org-export-resolve-id-link l i)))))))
|
|
|
|
|
(org-export-as backend nil nil nil '(:with-broken-links t)))))
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "[[#broken][link]]"
|
|
|
|
|
(let ((backend
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (_e c _i) c))
|
|
|
|
|
(paragraph . (lambda (_e c _i) c))
|
|
|
|
|
(link . (lambda (l c i) (org-export-resolve-id-link l i)))))))
|
|
|
|
|
(org-string-nw-p
|
|
|
|
|
(org-export-as backend nil nil nil '(:with-broken-links mark))))))
|
2013-01-27 17:11:34 -05:00
|
|
|
|
;; Clocks.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(string-match "CLOCK: \\[2012-04-29 .* 10:45\\]"
|
2013-10-29 09:53:21 -04:00
|
|
|
|
(org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-clocks t)))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-clocks nil))))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
;; Drawers.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text ":TEST:\ncontents\n:END:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-drawers nil))))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal ":TEST:\ncontents\n:END:\n"
|
2013-10-20 08:40:09 -04:00
|
|
|
|
(org-test-with-temp-text ":TEST:\ncontents\n:END:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-drawers t)))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal ":FOO:\nkeep\n:END:\n"
|
2013-10-20 08:40:09 -04:00
|
|
|
|
(org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-drawers ("FOO"))))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal ":FOO:\nkeep\n:END:\n"
|
2013-10-20 08:40:09 -04:00
|
|
|
|
(org-test-with-temp-text ":FOO:\nkeep\n:END:\n:BAR:\nremove\n:END:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-drawers (not "BAR"))))))
|
2014-01-04 19:13:54 -05:00
|
|
|
|
;; Fixed-width.
|
|
|
|
|
(should
|
|
|
|
|
(equal ": A\n"
|
|
|
|
|
(org-test-with-temp-text ": A"
|
|
|
|
|
(org-export-as (org-test-default-backend) nil nil nil
|
|
|
|
|
'(:with-fixed-width t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text ": A"
|
|
|
|
|
(org-export-as (org-test-default-backend) nil nil nil
|
|
|
|
|
'(:with-fixed-width nil))))))
|
2013-04-21 03:58:40 -04:00
|
|
|
|
;; Footnotes.
|
|
|
|
|
(should
|
|
|
|
|
(equal "Footnote?"
|
|
|
|
|
(let ((org-footnote-section nil))
|
|
|
|
|
(org-test-with-temp-text "Footnote?[fn:1]\n\n[fn:1] Def"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-trim (org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-footnotes nil)))))))
|
2013-04-21 03:58:40 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal "Footnote?[fn:1]\n\n[fn:1] Def"
|
|
|
|
|
(let ((org-footnote-section nil))
|
|
|
|
|
(org-test-with-temp-text "Footnote?[fn:1]\n\n[fn:1] Def"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-trim (org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-footnotes t)))))))
|
2012-08-16 06:46:49 -04:00
|
|
|
|
;; Inlinetasks.
|
|
|
|
|
(when (featurep 'org-inlinetask)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let ((org-inlinetask-min-level 15)
|
|
|
|
|
org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
2012-08-16 06:46:49 -04:00
|
|
|
|
(org-test-with-temp-text "*************** Task"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-inlinetasks nil))))))
|
2012-08-16 06:46:49 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let ((org-inlinetask-min-level 15)
|
|
|
|
|
org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
2012-08-16 06:46:49 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"*************** Task\nContents\n*************** END"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-inlinetasks nil)))))))
|
2013-01-27 17:11:34 -05:00
|
|
|
|
;; Plannings.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(string-match
|
2014-08-31 09:39:35 -04:00
|
|
|
|
"* H\nCLOSED: \\[2012-04-29 .* 10:45\\]"
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(let ((org-closed-string "CLOSED:"))
|
2014-08-31 09:39:35 -04:00
|
|
|
|
(org-test-with-temp-text "* H\nCLOSED: [2012-04-29 sun. 10:45]"
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-planning t))))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
2014-08-31 09:39:35 -04:00
|
|
|
|
(equal "* H\n"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(let ((org-closed-string "CLOSED:"))
|
2014-08-31 09:39:35 -04:00
|
|
|
|
(org-test-with-temp-text "* H\nCLOSED: [2012-04-29 sun. 10:45]"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-planning nil))))))
|
2013-09-25 15:27:29 -04:00
|
|
|
|
;; Property Drawers.
|
|
|
|
|
(should
|
|
|
|
|
(equal "* H1\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n :PROPERTIES:\n :PROP: value\n :END:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-properties nil)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "* H1\n:PROPERTIES:\n:PROP: value\n:END:\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n :PROPERTIES:\n :PROP: value\n :END:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-properties t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "* H1\n:PROPERTIES:\n:B: 2\n:END:\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H1\n :PROPERTIES:\n :A: 1\n :B: 2\n:END:"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-properties ("B"))))))
|
2012-08-27 06:31:05 -04:00
|
|
|
|
;; Statistics cookies.
|
|
|
|
|
(should
|
2015-09-10 03:32:58 -04:00
|
|
|
|
(equal "* Stats"
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-trim
|
2015-09-10 03:32:58 -04:00
|
|
|
|
(org-test-with-temp-text "* Stats [0/0]"
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-statistics-cookies nil)))))))
|
2014-01-04 19:13:54 -05:00
|
|
|
|
;; Tables.
|
|
|
|
|
(should
|
|
|
|
|
(equal "| A |\n"
|
|
|
|
|
(org-test-with-temp-text "| A |"
|
|
|
|
|
(org-export-as (org-test-default-backend) nil nil nil
|
|
|
|
|
'(:with-tables t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "| A |"
|
|
|
|
|
(org-export-as (org-test-default-backend) nil nil nil
|
|
|
|
|
'(:with-tables nil)))))))
|
2013-04-14 16:20:16 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/with-timestamps ()
|
|
|
|
|
"Test `org-export-with-timestamps' specifications."
|
|
|
|
|
;; t value.
|
|
|
|
|
(should
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(string-match
|
|
|
|
|
"\\[2012-04-29 .*? 10:45\\]<2012-04-29 .*? 10:45>"
|
2013-04-14 16:20:16 -04:00
|
|
|
|
(org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-timestamps t)))))
|
2013-04-14 16:20:16 -04:00
|
|
|
|
;; nil value.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-trim
|
|
|
|
|
(org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-timestamps nil)))))))
|
2013-04-14 16:20:16 -04:00
|
|
|
|
;; `active' value.
|
|
|
|
|
(should
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(string-match
|
|
|
|
|
"<2012-03-29 .*?>\n\nParagraph <2012-03-29 .*?>\\[2012-03-29 .*?\\]"
|
2013-04-14 16:20:16 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"<2012-03-29 Thu>[2012-03-29 Thu]
|
|
|
|
|
|
|
|
|
|
Paragraph <2012-03-29 Thu>[2012-03-29 Thu]"
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-timestamps active)))))
|
2013-04-14 16:20:16 -04:00
|
|
|
|
;; `inactive' value.
|
|
|
|
|
(should
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(string-match
|
|
|
|
|
"\\[2012-03-29 .*?\\]\n\nParagraph <2012-03-29 .*?>\\[2012-03-29 .*?\\]"
|
2013-04-14 16:20:16 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"<2012-03-29 Thu>[2012-03-29 Thu]
|
|
|
|
|
|
|
|
|
|
Paragraph <2012-03-29 Thu>[2012-03-29 Thu]"
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-timestamps inactive))))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/comment-tree ()
|
|
|
|
|
"Test if export process ignores commented trees."
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let (org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
|
|
|
|
(org-test-with-temp-text "* COMMENT Head1"
|
|
|
|
|
(org-export-as (org-test-default-backend)))))))
|
2013-12-20 15:28:45 -05:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/uninterpreted ()
|
|
|
|
|
"Test handling of uninterpreted elements."
|
|
|
|
|
;; Entities.
|
|
|
|
|
(should
|
|
|
|
|
(equal "dummy\n"
|
|
|
|
|
(org-test-with-temp-text "\\alpha"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((entity . (lambda (e c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-entities t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "\\alpha\n"
|
|
|
|
|
(org-test-with-temp-text "\\alpha"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((entity . (lambda (e c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-entities nil)))))
|
|
|
|
|
;; Emphasis.
|
|
|
|
|
(should
|
|
|
|
|
(equal "dummy\n"
|
|
|
|
|
(org-test-with-temp-text "*bold*"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((bold . (lambda (b c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-emphasize t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "*bold*\n"
|
|
|
|
|
(org-test-with-temp-text "*bold*"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((bold . (lambda (b c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-emphasize nil)))))
|
2017-02-13 10:29:54 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "/simple/ /example/\n"
|
|
|
|
|
(org-test-with-temp-text "/simple/ /example/"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((bold . (lambda (b c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-emphasize nil)))))
|
2013-12-20 15:28:45 -05:00
|
|
|
|
;; LaTeX environment.
|
|
|
|
|
(should
|
|
|
|
|
(equal "dummy\n"
|
|
|
|
|
(org-test-with-temp-text "\\begin{equation}\n1+1=2\n\\end{equation}"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((latex-environment . (lambda (l c i) "dummy"))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-latex t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "\\begin{equation}\n1+1=2\n\\end{equation}\n"
|
|
|
|
|
(org-test-with-temp-text "\\begin{equation}\n1+1=2\n\\end{equation}"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((latex-environment . (lambda (l c i) "dummy"))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-latex verbatim)))))
|
|
|
|
|
;; LaTeX fragment.
|
|
|
|
|
(should
|
|
|
|
|
(equal "dummy\n"
|
|
|
|
|
(org-test-with-temp-text "$1$"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((latex-fragment . (lambda (l c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-latex t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "$1$\n"
|
|
|
|
|
(org-test-with-temp-text "$1$"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((latex-fragment . (lambda (l c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-latex verbatim)))))
|
2019-07-09 06:36:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal "$1$ \n"
|
|
|
|
|
(org-test-with-temp-text "$1$ "
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
2013-12-20 15:28:45 -05:00
|
|
|
|
:transcoders '((latex-fragment . (lambda (l c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-latex verbatim)))))
|
|
|
|
|
;; Sub/superscript.
|
|
|
|
|
(should
|
|
|
|
|
(equal "adummy\n"
|
|
|
|
|
(org-test-with-temp-text "a_b"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "a_b\n"
|
|
|
|
|
(org-test-with-temp-text "a_b"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript nil)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "a_b\n"
|
|
|
|
|
(org-test-with-temp-text "a_b"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript {})))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "adummy\n"
|
|
|
|
|
(org-test-with-temp-text "a_{b}"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
2013-12-26 06:23:27 -05:00
|
|
|
|
nil nil nil '(:with-sub-superscript {})))))
|
2015-12-11 18:38:39 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "a_entity\n"
|
|
|
|
|
(org-test-with-temp-text "a_\\alpha"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((entity . (lambda (e c i) "entity"))
|
|
|
|
|
(subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript nil)))))
|
2017-03-14 13:10:07 -04:00
|
|
|
|
;; Handle uninterpreted objects in parsed keywords.
|
2013-12-26 06:23:27 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "a_b"
|
|
|
|
|
(org-test-with-temp-text "#+TITLE: a_b"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((subscript . (lambda (s c i) "dummy"))
|
2017-03-23 11:41:26 -04:00
|
|
|
|
(template . (lambda (c i)
|
|
|
|
|
(org-export-data (plist-get i :title) i)))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript nil)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "a_b"
|
|
|
|
|
(org-test-with-temp-text "#+FOO: a_b"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:options
|
|
|
|
|
'((:foo "FOO" nil nil parse))
|
|
|
|
|
:transcoders
|
|
|
|
|
'((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(template . (lambda (c i)
|
|
|
|
|
(org-export-data (plist-get i :foo) i)))
|
2013-12-26 06:23:27 -05:00
|
|
|
|
(section . (lambda (s c i) c))))
|
2014-03-29 17:39:09 -04:00
|
|
|
|
nil nil nil '(:with-sub-superscript nil)))))
|
2017-03-14 13:10:07 -04:00
|
|
|
|
;; Objects in parsed keywords are "uninterpreted" before filters are
|
|
|
|
|
;; applied.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "#+TITLE: a_b"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:filters
|
|
|
|
|
'((:filter-options
|
|
|
|
|
(lambda (i _)
|
|
|
|
|
(org-element-map (plist-get i :title) 'subscript
|
|
|
|
|
(lambda (_) (error "There should be no subscript here")))))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript nil))))
|
2015-08-25 07:59:03 -04:00
|
|
|
|
;; Handle uninterpreted objects in captions.
|
|
|
|
|
(should
|
|
|
|
|
(equal "adummy\n"
|
|
|
|
|
(org-test-with-temp-text "#+CAPTION: a_b\nParagraph"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i)
|
|
|
|
|
(org-export-data (org-export-get-caption p) i)))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "a_b\n"
|
|
|
|
|
(org-test-with-temp-text "#+CAPTION: a_b\nParagraph"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i)
|
|
|
|
|
(org-export-data (org-export-get-caption p) i)))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript nil)))))
|
2014-03-29 17:39:09 -04:00
|
|
|
|
;; Special case: multiples uninterpreted objects in a row.
|
|
|
|
|
(should
|
|
|
|
|
(equal "a_b_c_d\n"
|
|
|
|
|
(org-test-with-temp-text "a_b_c_d"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((subscript . (lambda (s c i) "dummy"))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))))
|
|
|
|
|
nil nil nil '(:with-sub-superscript {}))))))
|
2012-02-22 18:57:59 -05:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/export-scope ()
|
|
|
|
|
"Test all export scopes."
|
2016-11-11 04:05:20 -05:00
|
|
|
|
;; Subtree.
|
|
|
|
|
(should
|
|
|
|
|
(equal "text\n*** H3\n"
|
|
|
|
|
(org-test-with-temp-text "* H1\n<point>** H2\ntext\n*** H3"
|
|
|
|
|
(org-export-as (org-test-default-backend) 'subtree))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "text\n*** H3\n"
|
|
|
|
|
(org-test-with-temp-text "* H1\n** H2\n<point>text\n*** H3"
|
|
|
|
|
(org-export-as (org-test-default-backend) 'subtree))))
|
2012-03-22 11:49:19 -04:00
|
|
|
|
;; Subtree with a code block calling another block outside.
|
2016-11-11 04:05:20 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal ": 3\n"
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
<point>* Head1
|
2012-03-22 11:49:19 -04:00
|
|
|
|
#+BEGIN_SRC emacs-lisp :noweb yes :exports results
|
|
|
|
|
<<test>>
|
|
|
|
|
#+END_SRC
|
|
|
|
|
* Head2
|
|
|
|
|
#+NAME: test
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
\(+ 1 2)
|
|
|
|
|
#+END_SRC"
|
2016-11-12 21:54:20 -05:00
|
|
|
|
(let ((org-export-use-babel t))
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(org-export-as (org-test-default-backend) 'subtree)))))
|
2016-11-11 04:05:20 -05:00
|
|
|
|
;; Subtree export should ignore leading planning line and property
|
|
|
|
|
;; drawer.
|
|
|
|
|
(should
|
|
|
|
|
(equal "Text\n"
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
<point>* H
|
|
|
|
|
SCHEDULED: <2012-03-29 Thu>
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:
|
|
|
|
|
Text"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
'subtree nil nil
|
|
|
|
|
'(:with-planning t :with-properties t)))))
|
2023-01-12 04:20:08 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
* H
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:A: 1
|
|
|
|
|
:END:<point>
|
|
|
|
|
* H2"
|
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
'subtree))))
|
2016-11-11 04:05:20 -05:00
|
|
|
|
;; Visible.
|
|
|
|
|
(should
|
|
|
|
|
(equal "* H1\n"
|
|
|
|
|
(org-test-with-temp-text "* H1\n** H2\ntext\n*** H3"
|
|
|
|
|
(org-cycle)
|
|
|
|
|
(org-export-as (org-test-default-backend) nil 'visible))))
|
|
|
|
|
;; Region.
|
|
|
|
|
(should
|
|
|
|
|
(equal "text\n"
|
|
|
|
|
(org-test-with-temp-text "* H1\n** H2\n<point>text\n*** H3"
|
|
|
|
|
(transient-mark-mode 1)
|
|
|
|
|
(push-mark (point) t t)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
org-export: Internal changes to back-end definition
* contrib/lisp/org-export.el (org-export-registered-backends): New
variable.
(org-export-define-backend, org-export-define-derived-backend): Use
new variable. Also redefine how sub-menus are defined.
(org-export-backend-filters, org-export-backend-menu,
org-export-backend-options, org-export-backend-translate-table): New
functions.
(org-export-get-environment, org-export--parse-option-keyword,
org-export--get-subtree-options, org-export--get-inbuffer-options,
org-export--get-global-options, org-export-install-filters,
org-export-with-backend): Access to data stored in new variable.
(org-export-dispatch-ui): Display sub-menus according to new
definition.
(org-export-dispatch-menu-entries): Removed variable.
* contrib/lisp/org-e-beamer.el: Use new sub-menu definition.
(org-e-beamer--format-section, org-e-beamer-item,
org-e-beamer-keyword): Use `org-export-with-backend' instead of
relying on removed variables.
* testing/lisp/test-org-export.el: Update tests.
This patch gets rid of "invisible" variables, that is variables
defvar'ed within a macro.
2012-11-12 17:21:05 -05:00
|
|
|
|
;; Body only.
|
2016-11-19 17:06:17 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal "Text\n"
|
|
|
|
|
(org-test-with-temp-text "Text"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((template . (lambda (b _i) (format "BEGIN\n%sEND" b)))
|
|
|
|
|
(section . (lambda (_s c _i) c))
|
|
|
|
|
(paragraph . (lambda (_p c _i) c))))
|
|
|
|
|
nil nil 'body-only))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "BEGIN\nText\nEND"
|
|
|
|
|
(org-test-with-temp-text "Text"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((template . (lambda (b _i) (format "BEGIN\n%sEND" b)))
|
|
|
|
|
(section . (lambda (_s c _i) c))
|
|
|
|
|
(paragraph . (lambda (_p c _i) c))))))))
|
|
|
|
|
;; Pathological case: Body only on an empty buffer is expected to
|
|
|
|
|
;; return an empty string, not nil.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text ""
|
|
|
|
|
(org-export-as (org-test-default-backend) nil nil t))))
|
2012-02-23 15:06:17 -05:00
|
|
|
|
|
2013-02-15 09:06:01 -05:00
|
|
|
|
(ert-deftest test-org-export/output-file-name ()
|
|
|
|
|
"Test `org-export-output-file-name' specifications."
|
|
|
|
|
;; Export from a file: name is built from original file name.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text-in-file "Test"
|
2016-12-20 11:10:46 -05:00
|
|
|
|
(equal (file-name-base (buffer-file-name))
|
|
|
|
|
(file-name-base (org-export-output-file-name ".ext")))))
|
|
|
|
|
;; When #+EXPORT_FILE_NAME is defined, use it.
|
|
|
|
|
(should
|
|
|
|
|
(equal "test.ext"
|
|
|
|
|
(org-test-with-temp-text-in-file "#+EXPORT_FILE_NAME: test"
|
|
|
|
|
(org-export-output-file-name ".ext" t))))
|
2013-02-15 09:06:01 -05:00
|
|
|
|
;; When exporting to subtree, check EXPORT_FILE_NAME property first.
|
|
|
|
|
(should
|
2016-12-20 11:10:46 -05:00
|
|
|
|
(equal "test.ext"
|
|
|
|
|
(org-test-with-temp-text-in-file
|
|
|
|
|
"* Test\n :PROPERTIES:\n :EXPORT_FILE_NAME: test\n :END:"
|
|
|
|
|
(org-export-output-file-name ".ext" t))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "property.ext"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+EXPORT_FILE_NAME: keyword
|
|
|
|
|
* Test<point>
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:EXPORT_FILE_NAME: property
|
|
|
|
|
:END:"
|
|
|
|
|
(org-export-output-file-name ".ext" t))))
|
2013-02-15 09:06:01 -05:00
|
|
|
|
;; From a buffer not associated to a file, too.
|
|
|
|
|
(should
|
2016-12-20 11:10:46 -05:00
|
|
|
|
(equal "test.ext"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* Test\n :PROPERTIES:\n :EXPORT_FILE_NAME: test\n :END:"
|
|
|
|
|
(org-export-output-file-name ".ext" t))))
|
2013-02-15 09:06:01 -05:00
|
|
|
|
;; When provided name is absolute, preserve it.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "* Test\n :PROPERTIES:\n :EXPORT_FILE_NAME: %s\n :END:"
|
|
|
|
|
(expand-file-name "test"))
|
|
|
|
|
(file-name-absolute-p (org-export-output-file-name ".ext" t))))
|
|
|
|
|
;; When PUB-DIR argument is provided, use it.
|
|
|
|
|
(should
|
2016-12-20 11:10:46 -05:00
|
|
|
|
(equal "dir/"
|
|
|
|
|
(org-test-with-temp-text-in-file "Test"
|
|
|
|
|
(file-name-directory
|
|
|
|
|
(org-export-output-file-name ".ext" nil "dir/")))))
|
|
|
|
|
;; PUB-DIR has precedence over EXPORT_FILE_NAME keyword or property.
|
|
|
|
|
(should
|
|
|
|
|
(equal "pub-dir/"
|
|
|
|
|
(org-test-with-temp-text-in-file
|
|
|
|
|
"#+EXPORT_FILE_NAME: /dir/keyword\nTest"
|
|
|
|
|
(file-name-directory
|
|
|
|
|
(org-export-output-file-name ".ext" nil "pub-dir/")))))
|
2013-02-15 09:06:01 -05:00
|
|
|
|
;; When returned name would overwrite original file, add EXTENSION
|
|
|
|
|
;; another time.
|
|
|
|
|
(should
|
2016-12-20 11:10:46 -05:00
|
|
|
|
(equal "normal.org.org"
|
|
|
|
|
(org-test-at-id "75282ba2-f77a-4309-a970-e87c149fe125"
|
|
|
|
|
(org-export-output-file-name ".org")))))
|
2013-02-15 09:06:01 -05:00
|
|
|
|
|
2012-02-23 15:06:17 -05:00
|
|
|
|
(ert-deftest test-org-export/expand-include ()
|
|
|
|
|
"Test file inclusion in an Org buffer."
|
2012-10-29 06:31:19 -04:00
|
|
|
|
;; Error when file isn't specified.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "#+INCLUDE: dummy.org"
|
|
|
|
|
(org-export-expand-include-keyword)))
|
2017-04-23 13:48:50 -04:00
|
|
|
|
;; Refuse to expand keywords in commented headings.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "* COMMENT H1\n#+INCLUDE: dummy.org"
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
t))
|
2012-02-23 15:06:17 -05:00
|
|
|
|
;; Full insertion with recursive inclusion.
|
2014-10-02 13:41:31 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file
|
|
|
|
|
(expand-file-name "examples/include.org" org-test-dir))
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
(regexp-quote "#+INCLUDE: \"include2.org\"")
|
|
|
|
|
"Success!" (buffer-string)))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
2012-02-23 15:06:17 -05:00
|
|
|
|
;; Localized insertion.
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\""
|
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(should (equal (buffer-string)
|
|
|
|
|
"Small Org file with an include keyword.\n")))
|
|
|
|
|
;; Insertion with constraints on headlines level.
|
2013-02-18 14:49:43 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"* Top heading\n** Heading\nbody\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format
|
2014-10-02 13:41:31 -04:00
|
|
|
|
"* Top heading\n#+INCLUDE: \"%s/examples/include.org\" :lines \"9-11\""
|
2013-02-18 14:49:43 -05:00
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"* Top heading\n* Heading\nbody\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format
|
2014-10-02 13:41:31 -04:00
|
|
|
|
"* Top heading\n#+INCLUDE: \"%s/examples/include.org\" :lines \"9-11\" :minlevel 1"
|
2013-02-18 14:49:43 -05:00
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
2012-02-23 15:06:17 -05:00
|
|
|
|
;; Inclusion within an example block.
|
2014-06-07 05:54:02 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN_EXAMPLE\nSmall Org file with an include keyword.\n#+END_EXAMPLE\n"
|
|
|
|
|
(org-test-with-temp-text
|
2015-08-02 19:06:32 -04:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org\" :lines \"1-2\" EXAMPLE"
|
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
2012-02-23 15:06:17 -05:00
|
|
|
|
;; Inclusion within a src-block.
|
2014-06-07 05:54:02 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp\n(+ 2 1)\n#+END_SRC\n"
|
|
|
|
|
(org-test-with-temp-text
|
2015-08-02 19:06:32 -04:00
|
|
|
|
(format
|
|
|
|
|
"#+INCLUDE: \"%s/examples/include.org\" :lines \"4-5\" SRC emacs-lisp"
|
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
2014-06-07 05:54:02 -04:00
|
|
|
|
;; Inclusion within an html export-block.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-02-03 10:16:54 -05:00
|
|
|
|
"#+BEGIN_EXPORT html\n<p>HTML!</p>\n#+END_EXPORT\n"
|
2014-06-07 05:54:02 -04:00
|
|
|
|
(org-test-with-temp-text
|
2015-08-02 19:06:32 -04:00
|
|
|
|
(format
|
2015-02-03 10:16:54 -05:00
|
|
|
|
"#+INCLUDE: \"%s/examples/include.html\" EXPORT html"
|
2015-08-02 19:06:32 -04:00
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
2014-06-07 05:54:02 -04:00
|
|
|
|
;; Inclusion within an center paragraph
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"#+BEGIN_CENTER\nSuccess!\n#+END_CENTER\n"
|
|
|
|
|
(org-test-with-temp-text
|
2015-08-02 19:06:32 -04:00
|
|
|
|
(format
|
|
|
|
|
"#+INCLUDE: \"%s/examples/include2.org\" CENTER"
|
|
|
|
|
org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
2014-03-26 10:34:59 -04:00
|
|
|
|
;; Footnotes labels are local to each included file.
|
|
|
|
|
(should
|
|
|
|
|
(= 6
|
|
|
|
|
(length
|
|
|
|
|
(delete-dups
|
|
|
|
|
(let ((contents "
|
2015-12-16 12:22:27 -05:00
|
|
|
|
Footnotes[fn:1], [fn:test], [fn:test] and [fn:inline:inline footnote].
|
2014-03-26 10:34:59 -04:00
|
|
|
|
\[fn:1] Footnote 1
|
|
|
|
|
\[fn:test] Footnote \"test\""))
|
|
|
|
|
(org-test-with-temp-text-in-file contents
|
|
|
|
|
(let ((file1 (buffer-file-name)))
|
|
|
|
|
(org-test-with-temp-text-in-file contents
|
|
|
|
|
(let ((file2 (buffer-file-name)))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+INCLUDE: \"%s\"\n#+INCLUDE: \"%s\""
|
|
|
|
|
file1 file2)
|
|
|
|
|
(org-export-expand-include-keyword)
|
2014-04-12 10:17:13 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer)
|
|
|
|
|
'footnote-reference
|
2015-09-06 15:54:57 -04:00
|
|
|
|
(lambda (r) (org-element-property :label r)))))))))))))
|
2014-03-26 10:34:59 -04:00
|
|
|
|
;; Footnotes labels are not local to each include keyword.
|
|
|
|
|
(should
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(= 3
|
2014-03-26 10:34:59 -04:00
|
|
|
|
(length
|
|
|
|
|
(delete-dups
|
|
|
|
|
(let ((contents "
|
2015-12-16 12:22:27 -05:00
|
|
|
|
Footnotes[fn:1], [fn:test] and [fn:inline:inline footnote].
|
2014-03-26 10:34:59 -04:00
|
|
|
|
\[fn:1] Footnote 1
|
|
|
|
|
\[fn:test] Footnote \"test\""))
|
|
|
|
|
(org-test-with-temp-text-in-file contents
|
|
|
|
|
(let ((file (buffer-file-name)))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+INCLUDE: \"%s\"\n#+INCLUDE: \"%s\"" file file)
|
|
|
|
|
(org-export-expand-include-keyword)
|
2014-04-12 10:17:13 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer)
|
|
|
|
|
'footnote-reference
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(lambda (ref) (org-element-property :label ref)))))))))))
|
2014-12-09 06:40:52 -05:00
|
|
|
|
;; Footnotes are supported by :lines-like elements and unnecessary
|
|
|
|
|
;; footnotes are dropped.
|
|
|
|
|
(should
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(= 3
|
2014-12-09 06:40:52 -05:00
|
|
|
|
(length
|
|
|
|
|
(delete-dups
|
|
|
|
|
(let ((contents "
|
|
|
|
|
* foo
|
|
|
|
|
Footnotes[fn:1]
|
|
|
|
|
* bar
|
2015-12-16 12:22:27 -05:00
|
|
|
|
Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
|
2014-12-09 06:40:52 -05:00
|
|
|
|
|
|
|
|
|
\[fn:1] Footnote 1
|
|
|
|
|
\[fn:2] Footnote 1
|
|
|
|
|
* Footnotes
|
|
|
|
|
\[fn:test] Footnote \"test\"
|
|
|
|
|
"))
|
|
|
|
|
(org-test-with-temp-text-in-file contents
|
|
|
|
|
(let ((file (buffer-file-name)))
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s::*bar\"\n" file)
|
2014-12-09 06:40:52 -05:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-element-map (org-element-parse-buffer)
|
|
|
|
|
'footnote-definition
|
|
|
|
|
(lambda (ref) (org-element-property :label ref)))))))))))
|
2014-09-28 15:05:17 -04:00
|
|
|
|
;; If only-contents is non-nil only include contents of element.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"body\n"
|
|
|
|
|
(org-test-with-temp-text
|
2015-08-02 19:06:32 -04:00
|
|
|
|
(concat
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::*Heading\" "
|
|
|
|
|
org-test-dir)
|
2015-08-02 19:06:32 -04:00
|
|
|
|
":only-contents t")
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
|
|
|
|
;; Headings can be included via CUSTOM_ID.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text
|
2015-08-02 19:06:32 -04:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::#ah\"" org-test-dir)
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(looking-at "* Another heading")))
|
|
|
|
|
;; Named objects can be included.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"| 1 |\n"
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::tbl\" :only-contents t"
|
|
|
|
|
org-test-dir)
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
|
|
|
|
;; Including non-existing elements should result in an error.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::*non-existing heading\""
|
|
|
|
|
org-test-dir)
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(org-export-expand-include-keyword)))
|
|
|
|
|
;; Lines work relatively to an included element.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"2\n3\n"
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::#ah\" :only-contents t \
|
|
|
|
|
:lines \"2-3\""
|
|
|
|
|
org-test-dir)
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
|
|
|
|
;; Properties should be dropped from headlines.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::#ht\" :only-contents t"
|
|
|
|
|
org-test-dir)
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::tbl\"" org-test-dir)
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
|
|
|
|
;; Properties should be dropped, drawers should not be.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
":LOGBOOK:\ndrawer\n:END:\ncontent\n"
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::#dh\" :only-contents t"
|
|
|
|
|
org-test-dir)
|
2014-09-28 15:05:17 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
2014-12-18 10:48:49 -05:00
|
|
|
|
(buffer-string))))
|
|
|
|
|
;; Adjacent INCLUDE-keywords should have the same :minlevel if unspecified.
|
|
|
|
|
(should
|
2015-11-06 07:04:20 -05:00
|
|
|
|
(cl-every (lambda (level) (zerop (1- level)))
|
2017-04-23 13:48:50 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(concat
|
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::#ah\"\n"
|
|
|
|
|
org-test-dir)
|
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include.org::*Heading\""
|
|
|
|
|
org-test-dir))
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-element-map (org-element-parse-buffer) 'headline
|
|
|
|
|
(lambda (head) (org-element-property :level head))))))
|
2014-12-18 10:48:49 -05:00
|
|
|
|
;; INCLUDE does not insert induced :minlevel for src-blocks.
|
|
|
|
|
(should-not
|
|
|
|
|
(equal
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "#+INCLUDE: \"%s/examples/include2.org\" src emacs-lisp"
|
|
|
|
|
org-test-dir)
|
2014-12-18 10:48:49 -05:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format
|
|
|
|
|
"#+INCLUDE: \"%s/examples/include2.org\" src emacs-lisp :minlevel 1"
|
|
|
|
|
org-test-dir)
|
2014-12-18 10:48:49 -05:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(buffer-string))))
|
|
|
|
|
;; INCLUDE assigns the relative :minlevel conditional on narrowing.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text-in-file
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "* h1\n<point>#+INCLUDE: \"%s/examples/include.org::#ah\""
|
|
|
|
|
org-test-dir)
|
2014-12-18 10:48:49 -05:00
|
|
|
|
(narrow-to-region (point) (point-max))
|
|
|
|
|
(org-export-expand-include-keyword)
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(eq 2 (org-current-level))))
|
2014-12-18 10:48:49 -05:00
|
|
|
|
;; If :minlevel is present do not alter it.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format
|
|
|
|
|
"* h1\n<point>#+INCLUDE: \"%s/examples/include.org::#ah\" :minlevel 3"
|
|
|
|
|
org-test-dir)
|
2014-12-18 10:48:49 -05:00
|
|
|
|
(narrow-to-region (point) (point-max))
|
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(eq 3 (org-current-level)))))
|
2012-02-25 07:08:40 -05:00
|
|
|
|
|
2019-02-11 19:15:55 -05:00
|
|
|
|
(ert-deftest test-org-export/expand-include/links ()
|
2018-03-18 11:08:37 -04:00
|
|
|
|
"Test links modifications when including files."
|
|
|
|
|
;; Preserve relative plain links.
|
|
|
|
|
(should
|
|
|
|
|
(string-prefix-p
|
|
|
|
|
"file:org-includee-"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "file:foo.org" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
2023-08-18 04:11:17 -04:00
|
|
|
|
(org-mode)
|
2018-03-18 11:08:37 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-trim (buffer-string)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
|
|
|
|
;; Preserve relative angular links.
|
|
|
|
|
(should
|
|
|
|
|
(string-prefix-p
|
|
|
|
|
"<file:org-includee-"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "<file:foo.org>" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
2023-08-18 04:11:17 -04:00
|
|
|
|
(org-mode)
|
2018-03-18 11:08:37 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-trim (buffer-string)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
|
|
|
|
;; Preserve relative bracket links without description.
|
|
|
|
|
(should
|
|
|
|
|
(string-prefix-p
|
|
|
|
|
"[[file:org-includee-"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "[[file:foo.org]]" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
2023-08-18 04:11:17 -04:00
|
|
|
|
(org-mode)
|
2018-03-18 11:08:37 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-trim (buffer-string)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
2020-02-11 13:10:54 -05:00
|
|
|
|
;; Preserve blanks after the link.
|
2020-02-11 12:59:52 -05:00
|
|
|
|
(should
|
|
|
|
|
(string-suffix-p
|
|
|
|
|
"foo.org]] :tag:"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "[[file:foo.org]] :tag:" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
2023-08-18 04:11:17 -04:00
|
|
|
|
(org-mode)
|
2020-02-11 12:59:52 -05:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-trim (buffer-string)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
2018-03-18 11:08:37 -04:00
|
|
|
|
;; Preserve relative bracket links with description.
|
|
|
|
|
(should
|
|
|
|
|
(string-prefix-p
|
|
|
|
|
"[[file:org-includee-"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "[[file:foo.org][description]]" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
2023-08-18 04:11:17 -04:00
|
|
|
|
(org-mode)
|
2018-03-18 11:08:37 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-trim (buffer-string)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
|
|
|
|
;; Preserve absolute links.
|
|
|
|
|
(should
|
|
|
|
|
(string=
|
|
|
|
|
"[[file:/foo/bar.org]]"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "[[file:/foo/bar.org]]" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
2023-08-18 04:11:17 -04:00
|
|
|
|
(org-mode)
|
2018-03-18 11:08:37 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-trim (buffer-string)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
2018-03-19 18:48:38 -04:00
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
|
|
|
|
;; Pathological case: Do not error when fixing a path in a headline.
|
|
|
|
|
(should
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "* [[file:foo.org]]" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
2023-08-18 04:11:17 -04:00
|
|
|
|
(org-mode)
|
2018-03-19 18:48:38 -04:00
|
|
|
|
(org-export-expand-include-keyword)
|
|
|
|
|
(org-trim (buffer-string)))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
2018-03-18 11:08:37 -04:00
|
|
|
|
|
2012-10-06 04:27:57 -04:00
|
|
|
|
(ert-deftest test-org-export/expand-macro ()
|
|
|
|
|
"Test macro expansion in an Org buffer."
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(require 'ox-org)
|
2012-10-06 04:27:57 -04:00
|
|
|
|
;; Standard macro expansion.
|
|
|
|
|
(should
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(equal "#+macro: macro1 value\nvalue\n"
|
2012-10-06 04:27:57 -04:00
|
|
|
|
(org-test-with-temp-text "#+MACRO: macro1 value\n{{{macro1}}}"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
2016-12-19 17:00:38 -05:00
|
|
|
|
;; Include global macros. However, local macros override them.
|
|
|
|
|
(should
|
|
|
|
|
(equal "global\n"
|
|
|
|
|
(org-test-with-temp-text "{{{M}}}"
|
|
|
|
|
(let ((org-export-global-macros '(("M" . "global"))))
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "global arg\n"
|
|
|
|
|
(org-test-with-temp-text "{{{M(arg)}}}"
|
|
|
|
|
(let ((org-export-global-macros '(("M" . "global $1"))))
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "2\n"
|
|
|
|
|
(org-test-with-temp-text "{{{M}}}"
|
|
|
|
|
(let ((org-export-global-macros '(("M" . "(eval (+ 1 1))"))))
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
(should
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(equal "#+macro: M local\nlocal\n"
|
2016-12-19 17:00:38 -05:00
|
|
|
|
(org-test-with-temp-text "#+macro: M local\n{{{M}}}"
|
|
|
|
|
(let ((org-export-global-macros '(("M" . "global"))))
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
2015-04-05 07:40:44 -04:00
|
|
|
|
;; Allow macro in parsed keywords and associated properties.
|
|
|
|
|
;; Standard macro expansion.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
2018-01-24 06:56:25 -05:00
|
|
|
|
"#\\+k: value"
|
2015-04-05 07:40:44 -04:00
|
|
|
|
(let ((backend (org-export-create-backend
|
|
|
|
|
:parent 'org
|
|
|
|
|
:options '((:k "K" nil nil parse)))))
|
|
|
|
|
(org-test-with-temp-text "#+MACRO: macro value\n#+K: {{{macro}}}"
|
|
|
|
|
(org-export-as backend)))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
":EXPORT_K: v"
|
|
|
|
|
(let ((backend (org-export-create-backend
|
|
|
|
|
:parent 'org
|
|
|
|
|
:options '((:k "K" nil nil parse)))))
|
|
|
|
|
(org-test-with-temp-text
|
2018-01-24 06:56:25 -05:00
|
|
|
|
"#+macro: m v\n* H\n:PROPERTIES:\n:EXPORT_K: {{{m}}}\n:END:"
|
2015-04-05 07:40:44 -04:00
|
|
|
|
(org-export-as backend nil nil nil '(:with-properties t))))))
|
2012-10-29 08:42:30 -04:00
|
|
|
|
;; Expand specific macros.
|
2012-10-06 04:27:57 -04:00
|
|
|
|
(should
|
2012-10-29 08:42:30 -04:00
|
|
|
|
(equal "me 2012-03-29 me@here Title\n"
|
2012-10-06 04:27:57 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"
|
|
|
|
|
#+TITLE: Title
|
|
|
|
|
#+DATE: 2012-03-29
|
|
|
|
|
#+AUTHOR: me
|
|
|
|
|
#+EMAIL: me@here
|
|
|
|
|
{{{author}}} {{{date}}} {{{email}}} {{{title}}}"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(let ((output (org-export-as (org-test-default-backend))))
|
2012-10-29 08:42:30 -04:00
|
|
|
|
(substring output (string-match ".*\n\\'" output))))))
|
|
|
|
|
;; Expand specific macros when property contained a regular macro
|
|
|
|
|
;; already.
|
|
|
|
|
(should
|
|
|
|
|
(equal "value\n"
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
#+MACRO: macro1 value
|
|
|
|
|
#+TITLE: {{{macro1}}}
|
|
|
|
|
{{{title}}}"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(let ((output (org-export-as (org-test-default-backend))))
|
2012-10-29 08:42:30 -04:00
|
|
|
|
(substring output (string-match ".*\n\\'" output))))))
|
2012-10-10 07:52:54 -04:00
|
|
|
|
;; Expand macros with templates in included files.
|
|
|
|
|
(should
|
2012-10-29 08:42:30 -04:00
|
|
|
|
(equal "success\n"
|
2012-10-10 07:52:54 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
(format "#+INCLUDE: \"%s/examples/macro-templates.org\"
|
|
|
|
|
{{{included-macro}}}" org-test-dir)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(let ((output (org-export-as (org-test-default-backend))))
|
2015-02-08 15:34:43 -05:00
|
|
|
|
(substring output (string-match ".*\n\\'" output))))))
|
|
|
|
|
;; Date macro takes a optional formatting argument
|
|
|
|
|
(should
|
|
|
|
|
(equal "09-02-15\n"
|
2015-03-23 19:32:15 -04:00
|
|
|
|
(org-test-with-temp-text "{{{date(%d-%m-%y)}}}\n* d :noexport:\n#+DATE: <2015-02-09>"
|
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
2015-02-08 15:34:43 -05:00
|
|
|
|
;; Only single timestamps are formatted
|
|
|
|
|
(should
|
|
|
|
|
(equal "<2015-02x-09>\n"
|
2015-03-23 19:32:15 -04:00
|
|
|
|
(org-test-with-temp-text "{{{date(%d-%m-%y)}}}\n* d :noexport:\n#+DATE: <2015-02x-09>"
|
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
|
|
|
|
;; Throw an error when a macro definition is missing.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-temp-text "{{{missing}}}"
|
2017-12-11 08:50:02 -05:00
|
|
|
|
(org-export-as (org-test-default-backend))))
|
|
|
|
|
;; Inline source blocks generate {{{results}}} macros. Evaluate
|
|
|
|
|
;; those.
|
|
|
|
|
(should
|
|
|
|
|
(equal "=2=\n"
|
|
|
|
|
(org-test-with-temp-text "src_emacs-lisp{(+ 1 1)}"
|
|
|
|
|
(let ((org-export-use-babel t)
|
|
|
|
|
(org-babel-inline-result-wrap "=%s="))
|
2018-07-07 06:45:40 -04:00
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
;; If inline source block is already associated to a "results"
|
|
|
|
|
;; macro, do not duplicate it.
|
|
|
|
|
(should
|
|
|
|
|
(equal "src_emacs-lisp{(+ 1 1)} {{{results(=2=)}}}"
|
|
|
|
|
(org-test-with-temp-text "src_emacs-lisp{(+ 1 1)} {{{results(=2=)}}}"
|
|
|
|
|
(let ((org-export-use-babel t)
|
|
|
|
|
(org-babel-inline-result-wrap "=%s="))
|
|
|
|
|
(org-export-as (org-test-default-backend)))
|
|
|
|
|
(buffer-string)))))
|
2012-10-06 04:27:57 -04:00
|
|
|
|
|
2012-11-02 09:06:50 -04:00
|
|
|
|
(ert-deftest test-org-export/before-processing-hook ()
|
|
|
|
|
"Test `org-export-before-processing-hook'."
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2018-01-24 06:56:25 -05:00
|
|
|
|
"#+macro: mac val\nTest\n"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "#+MACRO: mac val\n{{{mac}}} Test"
|
|
|
|
|
(let ((org-export-before-processing-hook
|
|
|
|
|
'((lambda (backend)
|
|
|
|
|
(while (re-search-forward "{{{" nil t)
|
|
|
|
|
(let ((object (org-element-context)))
|
2023-05-16 06:41:53 -04:00
|
|
|
|
(when (org-element-type-p object 'macro)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(delete-region
|
|
|
|
|
(org-element-property :begin object)
|
|
|
|
|
(org-element-property :end object)))))))))
|
|
|
|
|
(org-export-as (org-test-default-backend)))))))
|
2012-11-02 09:06:50 -04:00
|
|
|
|
|
2012-04-27 18:57:38 -04:00
|
|
|
|
(ert-deftest test-org-export/before-parsing-hook ()
|
|
|
|
|
"Test `org-export-before-parsing-hook'."
|
2012-11-02 09:06:50 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal "Body 1\nBody 2\n"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline 1\nBody 1\n* Headline 2\nBody 2"
|
|
|
|
|
(let ((org-export-before-parsing-hook
|
|
|
|
|
'((lambda (backend)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (re-search-forward org-outline-regexp-bol nil t)
|
|
|
|
|
(delete-region
|
|
|
|
|
(point-at-bol) (progn (forward-line) (point))))))))
|
|
|
|
|
(org-export-as (org-test-default-backend)))))))
|
2012-04-27 18:57:38 -04:00
|
|
|
|
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
2012-06-12 04:25:00 -04:00
|
|
|
|
|
|
|
|
|
;;; Affiliated Keywords
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/read-attribute ()
|
|
|
|
|
"Test `org-export-read-attribute' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(org-export-read-attribute
|
|
|
|
|
:attr_html
|
|
|
|
|
(org-test-with-temp-text "#+ATTR_HTML: :a 1 :b 2\nParagraph"
|
org-element: Rename a few internal functions
* contrib/lisp/org-element.el (org-element--parse-elements): Renamed
from `org-element-parse-elements'.
(org-element--parse-objects): Renamed from `org-element-parse-objects'.
(org-element--get-next-object-candidates): Renamed from
`org-element-get-next-object-candidates'.
(org-element--interpret-affiliated-keywords): Renamed from
`org-element-interpret--affiliated-keywords'.
(org-element--current-element): Renamed from
`org-element-current-element'.
(org-element--collect-affiliated-keywords): Renamed from
`org-element-collect-affiliated-keywords'.
(org-element-center-block-parser, org-element-drawer-parser,
org-element-dynamic-block-parser,
org-element-footnote-definition-parser, org-element-inlinetask-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-example-block-parser,
org-element-export-block-parser, org-element-fixed-width-parser,
org-element-horizontal-rule-parser,
org-element-latex-environment-parser, org-element-paragraph-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser, org-element-fill-paragraph,
org-element-context, org-element-at-point, org-element-interpret-data,
org-element-parse-secondary-string, org-element-parse-buffer): Apply
name change.
* contrib/lisp/org-export.el (org-export-get-buffer-attributes): Apply
name change.
* testing/lisp/test-org-element.el: Update tests accordingly.
* testing/lisp/test-org-export.el: Update tests accordingly.
2012-07-19 05:23:43 -04:00
|
|
|
|
(org-element-at-point)))
|
2013-03-08 18:58:31 -05:00
|
|
|
|
'(:a "1" :b "2")))
|
2012-06-12 04:25:00 -04:00
|
|
|
|
;; Return nil on empty attribute.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-read-attribute
|
|
|
|
|
:attr_html
|
2013-03-08 18:58:31 -05:00
|
|
|
|
(org-test-with-temp-text "Paragraph" (org-element-at-point))))
|
|
|
|
|
;; Return nil on "nil" string.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(:a nil :b nil)
|
|
|
|
|
(org-export-read-attribute
|
|
|
|
|
:attr_html
|
|
|
|
|
(org-test-with-temp-text "#+ATTR_HTML: :a nil :b nil\nParagraph"
|
|
|
|
|
(org-element-at-point)))))
|
|
|
|
|
;; Return nil on empty string.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(:a nil :b nil)
|
|
|
|
|
(org-export-read-attribute
|
|
|
|
|
:attr_html
|
|
|
|
|
(org-test-with-temp-text "#+ATTR_HTML: :a :b\nParagraph"
|
|
|
|
|
(org-element-at-point)))))
|
2013-04-10 12:33:12 -04:00
|
|
|
|
;; Return empty string when value is "".
|
|
|
|
|
(should
|
|
|
|
|
(equal '(:a "")
|
|
|
|
|
(org-export-read-attribute
|
|
|
|
|
:attr_html
|
|
|
|
|
(org-test-with-temp-text "#+ATTR_HTML: :a \"\"\nParagraph"
|
|
|
|
|
(org-element-at-point)))))
|
|
|
|
|
;; Return \"\" when value is """".
|
|
|
|
|
(should
|
|
|
|
|
(equal '(:a "\"\"")
|
|
|
|
|
(org-export-read-attribute
|
|
|
|
|
:attr_html
|
|
|
|
|
(org-test-with-temp-text "#+ATTR_HTML: :a \"\"\"\"\nParagraph"
|
|
|
|
|
(org-element-at-point)))))
|
2013-03-08 18:58:31 -05:00
|
|
|
|
;; Ignore text before first property.
|
|
|
|
|
(should-not
|
|
|
|
|
(member "ignore"
|
|
|
|
|
(org-export-read-attribute
|
|
|
|
|
:attr_html
|
|
|
|
|
(org-test-with-temp-text "#+ATTR_HTML: ignore :a 1\nParagraph"
|
|
|
|
|
(org-element-at-point))))))
|
2012-06-12 04:25:00 -04:00
|
|
|
|
|
2012-09-13 10:51:54 -04:00
|
|
|
|
(ert-deftest test-org-export/get-caption ()
|
|
|
|
|
"Test `org-export-get-caption' specifications."
|
|
|
|
|
;; Without optional argument, return long caption
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("l")
|
|
|
|
|
(org-test-with-temp-text "#+CAPTION[s]: l\nPara"
|
|
|
|
|
(org-export-get-caption (org-element-at-point)))))
|
|
|
|
|
;; With optional argument, return short caption.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("s")
|
|
|
|
|
(org-test-with-temp-text "#+CAPTION[s]: l\nPara"
|
|
|
|
|
(org-export-get-caption (org-element-at-point) t))))
|
|
|
|
|
;; Multiple lines are separated by white spaces.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'("a" " " "b")
|
|
|
|
|
(org-test-with-temp-text "#+CAPTION: a\n#+CAPTION: b\nPara"
|
|
|
|
|
(org-export-get-caption (org-element-at-point))))))
|
|
|
|
|
|
2012-07-04 17:30:23 -04:00
|
|
|
|
|
2012-11-17 07:33:38 -05:00
|
|
|
|
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;;; Backend Tools
|
2012-11-17 07:33:38 -05:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/define-backend ()
|
2023-04-20 08:11:19 -04:00
|
|
|
|
"Test backend definition and accessors."
|
2012-11-17 07:33:38 -05:00
|
|
|
|
;; Translate table.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((headline . my-headline-test))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test '((headline . my-headline-test)))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-get-all-transcoders 'test))))
|
2012-11-17 07:33:38 -05:00
|
|
|
|
;; Filters.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:filter-headline . my-filter))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . my-headline-test))
|
|
|
|
|
:filters-alist '((:filter-headline . my-filter)))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-backend-filters (org-export-get-backend 'test)))))
|
2012-11-17 07:33:38 -05:00
|
|
|
|
;; Options.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:prop value))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . my-headline-test))
|
|
|
|
|
:options-alist '((:prop value)))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-backend-options (org-export-get-backend 'test)))))
|
2012-11-17 07:33:38 -05:00
|
|
|
|
;; Menu.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(?k "Test Export" test)
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . my-headline-test))
|
|
|
|
|
:menu-entry '(?k "Test Export" test))
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(org-export-backend-menu (org-export-get-backend 'test))))))
|
2012-11-17 07:33:38 -05:00
|
|
|
|
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(ert-deftest test-org-export/define-derived-backend ()
|
|
|
|
|
"Test `org-export-define-derived-backend' specifications."
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Error when parent backend is not defined.
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(should-error
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-derived-backend 'test 'parent)))
|
|
|
|
|
;; Append translation table to parent's.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:headline . test) (:headline . parent))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'parent '((:headline . parent)))
|
|
|
|
|
(org-export-define-derived-backend 'test 'parent
|
|
|
|
|
:translate-alist '((:headline . test)))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-get-all-transcoders 'test))))
|
2013-03-19 11:27:15 -04:00
|
|
|
|
;; Options defined in the new back have priority over those defined
|
|
|
|
|
;; in parent.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'test
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'parent
|
|
|
|
|
'((:headline . parent))
|
|
|
|
|
:options-alist '((:a nil nil 'parent)))
|
|
|
|
|
(org-export-define-derived-backend 'test 'parent
|
|
|
|
|
:options-alist '((:a nil nil 'test)))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(plist-get (org-export--get-global-options
|
|
|
|
|
(org-export-get-backend 'test))
|
|
|
|
|
:a)))))
|
2013-03-19 11:27:15 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/derived-backend-p ()
|
|
|
|
|
"Test `org-export-derived-backend-p' specifications."
|
|
|
|
|
;; Non-nil with direct match.
|
|
|
|
|
(should
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test '((headline . test)))
|
|
|
|
|
(org-export-derived-backend-p 'test 'test)))
|
|
|
|
|
(should
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test '((headline . test)))
|
|
|
|
|
(org-export-define-derived-backend 'test2 'test)
|
|
|
|
|
(org-export-derived-backend-p 'test2 'test2)))
|
|
|
|
|
;; Non-nil with a direct parent.
|
|
|
|
|
(should
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test '((headline . test)))
|
|
|
|
|
(org-export-define-derived-backend 'test2 'test)
|
|
|
|
|
(org-export-derived-backend-p 'test2 'test)))
|
|
|
|
|
;; Non-nil with an indirect parent.
|
|
|
|
|
(should
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test '((headline . test)))
|
|
|
|
|
(org-export-define-derived-backend 'test2 'test)
|
|
|
|
|
(org-export-define-derived-backend 'test3 'test2)
|
|
|
|
|
(org-export-derived-backend-p 'test3 'test)))
|
|
|
|
|
;; Nil otherwise.
|
|
|
|
|
(should-not
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test '((headline . test)))
|
|
|
|
|
(org-export-define-backend 'test2 '((headline . test2)))
|
|
|
|
|
(org-export-derived-backend-p 'test2 'test)))
|
|
|
|
|
(should-not
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test '((headline . test)))
|
|
|
|
|
(org-export-define-backend 'test2 '((headline . test2)))
|
|
|
|
|
(org-export-define-derived-backend 'test3 'test2)
|
|
|
|
|
(org-export-derived-backend-p 'test3 'test))))
|
2012-11-17 07:33:38 -05:00
|
|
|
|
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(ert-deftest test-org-export/get-all-transcoders ()
|
|
|
|
|
"Test `org-export-get-all-transcoders' specifications."
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Return nil when backend cannot be found.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should-not (org-export-get-all-transcoders nil))
|
|
|
|
|
;; Same as `org-export-transcoders' if no parent.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((headline . ignore))
|
|
|
|
|
(org-export-get-all-transcoders
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((headline . ignore))))))
|
|
|
|
|
;; But inherit from all ancestors whenever possible.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((section . ignore) (headline . ignore))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1 '((headline . ignore)))
|
|
|
|
|
(org-export-get-all-transcoders
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b1 :transcoders '((section . ignore)))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '((paragraph . ignore) (section . ignore) (headline . ignore))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1 '((headline . ignore)))
|
|
|
|
|
(org-export-define-derived-backend 'b2 'b1
|
|
|
|
|
:translate-alist '((section . ignore)))
|
|
|
|
|
(org-export-get-all-transcoders
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b2 :transcoders '((paragraph . ignore)))))))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Backend transcoders overrule inherited ones.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(eq 'b
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1 '((headline . a)))
|
|
|
|
|
(cdr (assq 'headline
|
|
|
|
|
(org-export-get-all-transcoders
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b1 :transcoders '((headline . b))))))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-all-options ()
|
|
|
|
|
"Test `org-export-get-all-options' specifications."
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Return nil when backend cannot be found.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should-not (org-export-get-all-options nil))
|
|
|
|
|
;; Same as `org-export-options' if no parent.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((headline . ignore))
|
|
|
|
|
(org-export-get-all-options
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:options '((headline . ignore))))))
|
|
|
|
|
;; But inherit from all ancestors whenever possible.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:key2 value2) (:key1 value1))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1 nil :options-alist '((:key1 value1)))
|
|
|
|
|
(org-export-get-all-options
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b1 :options '((:key2 value2)))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:key3 value3) (:key2 value2) (:key1 value1))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1 nil :options-alist '((:key1 value1)))
|
|
|
|
|
(org-export-define-derived-backend 'b2 'b1
|
|
|
|
|
:options-alist '((:key2 value2)))
|
|
|
|
|
(org-export-get-all-options
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b2 :options '((:key3 value3)))))))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Backend options overrule inherited ones.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(eq 'b
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1 nil :options-alist '((:key1 . a)))
|
|
|
|
|
(cdr (assq :key1
|
|
|
|
|
(org-export-get-all-options
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b1 :options '((:key1 . b))))))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-all-filters ()
|
|
|
|
|
"Test `org-export-get-all-filters' specifications."
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Return nil when backend cannot be found.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should-not (org-export-get-all-filters nil))
|
|
|
|
|
;; Same as `org-export-filters' if no parent.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:filter-headline . ignore))
|
|
|
|
|
(org-export-get-all-filters
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:filters '((:filter-headline . ignore))))))
|
|
|
|
|
;; But inherit from all ancestors whenever possible.
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:filter-section . ignore) (:filter-headline . ignore))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1
|
|
|
|
|
nil :filters-alist '((:filter-headline . ignore)))
|
|
|
|
|
(org-export-get-all-filters
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b1 :filters '((:filter-section . ignore)))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '((:filter-paragraph . ignore)
|
|
|
|
|
(:filter-section . ignore)
|
|
|
|
|
(:filter-headline . ignore))
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1
|
|
|
|
|
nil :filters-alist '((:filter-headline . ignore)))
|
|
|
|
|
(org-export-define-derived-backend 'b2 'b1
|
|
|
|
|
:filters-alist '((:filter-section . ignore)))
|
|
|
|
|
(org-export-get-all-filters
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b2 :filters '((:filter-paragraph . ignore)))))))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Backend filters overrule inherited ones.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
|
|
|
|
(eq 'b
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-define-backend 'b1 '((:filter-headline . a)))
|
|
|
|
|
(cdr (assq :filter-headline
|
|
|
|
|
(org-export-get-all-filters
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:parent 'b1 :filters '((:filter-headline . b))))))))))
|
|
|
|
|
|
2012-11-23 12:41:58 -05:00
|
|
|
|
(ert-deftest test-org-export/with-backend ()
|
|
|
|
|
"Test `org-export-with-backend' definition."
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Error when calling an undefined backend
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should-error (org-export-with-backend nil "Test"))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Error when called backend doesn't have an appropriate
|
2012-11-23 12:41:58 -05:00
|
|
|
|
;; transcoder.
|
|
|
|
|
(should-error
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-with-backend
|
|
|
|
|
(org-export-create-backend :transcoders '((headline . ignore)))
|
|
|
|
|
"Test"))
|
2012-11-23 12:41:58 -05:00
|
|
|
|
;; Otherwise, export using correct transcoder
|
|
|
|
|
(should
|
|
|
|
|
(equal "Success"
|
2015-04-22 04:24:02 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test
|
2017-12-16 07:44:56 -05:00
|
|
|
|
'((verbatim . (lambda (text contents info) "Failure"))))
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-export-define-backend 'test2
|
2017-12-16 07:44:56 -05:00
|
|
|
|
'((verbatim . (lambda (text contents info) "Success"))))
|
|
|
|
|
(org-export-with-backend 'test2 '(verbatim (:value "=Test="))))))
|
|
|
|
|
;; Corner case: plain-text transcoders have a different arity.
|
|
|
|
|
(should
|
|
|
|
|
(equal "Success"
|
|
|
|
|
(org-export-with-backend
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((plain-text . (lambda (text info) "Success"))))
|
|
|
|
|
"Test")))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Provide correct backend if transcoder needs to use recursive
|
2017-12-16 07:44:56 -05:00
|
|
|
|
;; calls.
|
2013-10-07 10:47:51 -04:00
|
|
|
|
(should
|
2013-10-07 13:02:49 -04:00
|
|
|
|
(equal "Success\n"
|
2023-04-20 08:11:19 -04:00
|
|
|
|
(let ((test-backend
|
2013-10-07 13:02:49 -04:00
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
2015-08-14 17:50:51 -04:00
|
|
|
|
(list (cons 'headline
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(lambda (headline _contents info)
|
2015-08-14 17:50:51 -04:00
|
|
|
|
(org-export-data
|
|
|
|
|
(org-element-property :title headline)
|
|
|
|
|
info)))
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(cons 'plain-text (lambda (_text _info) "Success"))))))
|
2013-10-07 13:02:49 -04:00
|
|
|
|
(org-export-string-as
|
|
|
|
|
"* Test"
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
2015-08-14 17:50:51 -04:00
|
|
|
|
(list (cons 'headline
|
|
|
|
|
(lambda (headline contents info)
|
|
|
|
|
(org-export-with-backend
|
2023-04-20 08:11:19 -04:00
|
|
|
|
test-backend headline contents info))))))))))
|
2012-11-23 12:41:58 -05:00
|
|
|
|
|
2012-12-19 10:59:12 -05:00
|
|
|
|
(ert-deftest test-org-export/data-with-backend ()
|
|
|
|
|
"Test `org-export-data-with-backend' specifications."
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Error when calling an undefined backend.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should-error (org-export-data-with-backend nil "nil" nil))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Otherwise, export data recursively, using correct backend.
|
2012-12-19 10:59:12 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"Success!"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-data-with-backend
|
|
|
|
|
'(bold nil "Test")
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((plain-text . (lambda (text info) "Success"))
|
|
|
|
|
(bold . (lambda (bold contents info) (concat contents "!")))))
|
|
|
|
|
'(:with-emphasize t)))))
|
2012-12-19 10:59:12 -05:00
|
|
|
|
|
2012-11-17 07:33:38 -05:00
|
|
|
|
|
2015-11-12 05:28:13 -05:00
|
|
|
|
|
|
|
|
|
;;; Comments
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/comments ()
|
|
|
|
|
"Test comments handling during export.
|
|
|
|
|
In particular, structure of the document mustn't be altered after
|
|
|
|
|
comments removal."
|
|
|
|
|
(should
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(equal "Para1\n\nPara2\n"
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"Para1
|
2015-11-12 05:28:13 -05:00
|
|
|
|
# Comment
|
|
|
|
|
|
|
|
|
|
# Comment
|
|
|
|
|
Para2"
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
2015-11-12 05:28:13 -05:00
|
|
|
|
(should
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(equal "Para1\n\nPara2\n"
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"Para1
|
2015-11-12 05:28:13 -05:00
|
|
|
|
# Comment
|
|
|
|
|
Para2"
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
2015-11-12 05:28:13 -05:00
|
|
|
|
(should
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(equal "[fn:1] Para1\n\n\nPara2\n"
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"[fn:1] Para1
|
2015-11-12 05:28:13 -05:00
|
|
|
|
# Inside definition
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Outside definition
|
|
|
|
|
Para2"
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
2015-11-12 05:28:13 -05:00
|
|
|
|
(should
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(equal "[fn:1] Para1\n\nPara2\n"
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"[fn:1] Para1
|
2015-11-12 05:28:13 -05:00
|
|
|
|
|
|
|
|
|
# Inside definition
|
|
|
|
|
|
|
|
|
|
# Inside definition
|
|
|
|
|
|
|
|
|
|
Para2"
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
2015-11-12 05:28:13 -05:00
|
|
|
|
(should
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(equal "[fn:1] Para1\n\nPara2\n"
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"[fn:1] Para1
|
2015-11-12 05:28:13 -05:00
|
|
|
|
# Inside definition
|
|
|
|
|
|
|
|
|
|
Para2"
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
2015-11-12 05:28:13 -05:00
|
|
|
|
(should
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(equal "[fn:1] Para1\n\nPara2\n"
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"[fn:1] Para1
|
2015-11-12 05:28:13 -05:00
|
|
|
|
|
|
|
|
|
# Inside definition
|
|
|
|
|
Para2"
|
2017-01-10 18:00:29 -05:00
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "- item 1\n\n- item 2\n"
|
2019-05-25 21:34:34 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"- item 1
|
2017-01-10 18:00:29 -05:00
|
|
|
|
|
|
|
|
|
# Comment
|
|
|
|
|
|
|
|
|
|
- item 2"
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
2015-11-12 05:28:13 -05:00
|
|
|
|
|
|
|
|
|
|
2016-01-02 05:53:24 -05:00
|
|
|
|
|
|
|
|
|
;;; Export blocks
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/export-block ()
|
|
|
|
|
"Test export blocks transcoding."
|
|
|
|
|
(should
|
|
|
|
|
(equal "Success!\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_EXPORT backend\nSuccess!\n#+END_EXPORT"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((export-block . (lambda (b _c _i)
|
|
|
|
|
(org-element-property :value b)))
|
|
|
|
|
(section . (lambda (_s c _i) c))))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "Success!\n"
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_EXPORT backend\nSuccess!\n#+END_EXPORT"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
(list
|
|
|
|
|
(cons 'export-block
|
|
|
|
|
(lambda (b _c _i)
|
|
|
|
|
(and (equal (org-element-property :type b) "BACKEND")
|
|
|
|
|
(org-element-property :value b))))
|
|
|
|
|
(cons 'section (lambda (_s c _i) c)))))))))
|
|
|
|
|
|
2012-07-04 17:30:23 -04:00
|
|
|
|
|
|
|
|
|
;;; Export Snippets
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/export-snippet ()
|
|
|
|
|
"Test export snippets transcoding."
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
;; Standard test.
|
2012-07-04 17:30:23 -04:00
|
|
|
|
(org-test-with-temp-text "@@test:A@@@@t:B@@"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(let ((backend (org-test-default-backend)))
|
|
|
|
|
(setf (org-export-backend-name backend) 'test)
|
|
|
|
|
(setf (org-export-backend-transcoders backend)
|
|
|
|
|
(cons (cons 'export-snippet
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(lambda (snippet _contents _info)
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(when (eq (org-export-snippet-backend snippet) 'test)
|
|
|
|
|
(org-element-property :value snippet))))
|
|
|
|
|
(org-export-backend-transcoders backend)))
|
org-export: Internal changes to back-end definition
* contrib/lisp/org-export.el (org-export-registered-backends): New
variable.
(org-export-define-backend, org-export-define-derived-backend): Use
new variable. Also redefine how sub-menus are defined.
(org-export-backend-filters, org-export-backend-menu,
org-export-backend-options, org-export-backend-translate-table): New
functions.
(org-export-get-environment, org-export--parse-option-keyword,
org-export--get-subtree-options, org-export--get-inbuffer-options,
org-export--get-global-options, org-export-install-filters,
org-export-with-backend): Access to data stored in new variable.
(org-export-dispatch-ui): Display sub-menus according to new
definition.
(org-export-dispatch-menu-entries): Removed variable.
* contrib/lisp/org-e-beamer.el: Use new sub-menu definition.
(org-e-beamer--format-section, org-e-beamer-item,
org-e-beamer-keyword): Use `org-export-with-backend' instead of
relying on removed variables.
* testing/lisp/test-org-export.el: Update tests.
This patch gets rid of "invisible" variables, that is variables
defvar'ed within a macro.
2012-11-12 17:21:05 -05:00
|
|
|
|
(let ((org-export-snippet-translation-alist nil))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should (equal (org-export-as backend) "A\n")))
|
org-export: Internal changes to back-end definition
* contrib/lisp/org-export.el (org-export-registered-backends): New
variable.
(org-export-define-backend, org-export-define-derived-backend): Use
new variable. Also redefine how sub-menus are defined.
(org-export-backend-filters, org-export-backend-menu,
org-export-backend-options, org-export-backend-translate-table): New
functions.
(org-export-get-environment, org-export--parse-option-keyword,
org-export--get-subtree-options, org-export--get-inbuffer-options,
org-export--get-global-options, org-export-install-filters,
org-export-with-backend): Access to data stored in new variable.
(org-export-dispatch-ui): Display sub-menus according to new
definition.
(org-export-dispatch-menu-entries): Removed variable.
* contrib/lisp/org-e-beamer.el: Use new sub-menu definition.
(org-e-beamer--format-section, org-e-beamer-item,
org-e-beamer-keyword): Use `org-export-with-backend' instead of
relying on removed variables.
* testing/lisp/test-org-export.el: Update tests.
This patch gets rid of "invisible" variables, that is variables
defvar'ed within a macro.
2012-11-12 17:21:05 -05:00
|
|
|
|
(let ((org-export-snippet-translation-alist '(("t" . "test"))))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should (equal (org-export-as backend) "AB\n")))))
|
2013-03-21 15:08:24 -04:00
|
|
|
|
;; Ignored export snippets do not remove any blank.
|
|
|
|
|
(should
|
|
|
|
|
(equal "begin end\n"
|
|
|
|
|
(org-test-with-parsed-data "begin @@test:A@@ end"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-data-with-backend
|
2013-03-21 15:08:24 -04:00
|
|
|
|
tree
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((paragraph . (lambda (paragraph contents info) contents))
|
|
|
|
|
(section . (lambda (section contents info) contents))))
|
2013-03-21 15:08:24 -04:00
|
|
|
|
info)))))
|
2012-07-04 17:30:23 -04:00
|
|
|
|
|
2016-11-19 17:06:17 -05:00
|
|
|
|
|
|
|
|
|
;;; Filters
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/filter-apply-functions ()
|
|
|
|
|
"Test `org-export-filter-apply-functions' specifications."
|
|
|
|
|
;; Functions are applied in order and return values are reduced.
|
|
|
|
|
(should
|
|
|
|
|
(equal "210"
|
|
|
|
|
(org-export-filter-apply-functions
|
|
|
|
|
(list (lambda (value &rest _) (concat "1" value))
|
|
|
|
|
(lambda (value &rest _) (concat "2" value)))
|
|
|
|
|
"0" nil)))
|
|
|
|
|
;; Functions returning nil are skipped.
|
|
|
|
|
(should
|
|
|
|
|
(equal "20"
|
|
|
|
|
(org-export-filter-apply-functions
|
|
|
|
|
(list #'ignore (lambda (value &rest _) (concat "2" value)))
|
|
|
|
|
"0" nil)))
|
|
|
|
|
;; If all functions are skipped, return the initial value.
|
|
|
|
|
(should
|
|
|
|
|
(equal "0"
|
|
|
|
|
(org-export-filter-apply-functions (list #'ignore) "0" nil)))
|
|
|
|
|
;; If any function returns the empty string, final value is the
|
|
|
|
|
;; empty string.
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
|
|
|
|
(org-export-filter-apply-functions
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(list (lambda (_value &rest _) "")
|
2016-11-19 17:06:17 -05:00
|
|
|
|
(lambda (value &rest _) (concat "2" value)))
|
|
|
|
|
"0" nil)))
|
|
|
|
|
;; Any function returning the empty string short-circuits the
|
|
|
|
|
;; process.
|
|
|
|
|
(should
|
|
|
|
|
(org-export-filter-apply-functions
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(list (lambda (_value &rest _) "")
|
|
|
|
|
(lambda (_value &rest _) (error "This shouldn't happen")))
|
2016-11-19 17:06:17 -05:00
|
|
|
|
"0" nil)))
|
2012-07-04 17:30:23 -04:00
|
|
|
|
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
2012-04-27 18:57:38 -04:00
|
|
|
|
;;; Footnotes
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
2015-02-13 08:10:51 -05:00
|
|
|
|
(ert-deftest test-org-export/footnote-first-reference-p ()
|
|
|
|
|
"Test `org-export-footnote-first-reference-p' specifications."
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(t nil)
|
|
|
|
|
(org-test-with-temp-text "Text[fn:1][fn:1]\n\n[fn:1] Definition"
|
|
|
|
|
(let (result)
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
`(,(cons 'footnote-reference
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(lambda (f _c i)
|
2015-08-14 17:50:51 -04:00
|
|
|
|
(push (org-export-footnote-first-reference-p f i)
|
2015-02-13 08:10:51 -05:00
|
|
|
|
result)
|
|
|
|
|
""))
|
|
|
|
|
(section . (lambda (s c i) c))
|
|
|
|
|
(paragraph . (lambda (p c i) c))))
|
|
|
|
|
nil nil nil '(:with-footnotes t))
|
|
|
|
|
(nreverse result)))))
|
2015-02-21 03:34:15 -05:00
|
|
|
|
;; Limit check to DATA, when non-nil.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(nil t)
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1]\n* H\nText[fn:1]\n\n[fn:1] D1"
|
|
|
|
|
(let (result)
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref)
|
|
|
|
|
(push
|
|
|
|
|
(org-export-footnote-first-reference-p
|
|
|
|
|
ref info (org-element-map tree 'headline #'identity info t))
|
|
|
|
|
result))
|
|
|
|
|
info)
|
|
|
|
|
(nreverse result)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(t nil)
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1]\n* H\nText[fn:1]\n\n[fn:1] D1"
|
|
|
|
|
(let (result)
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref)
|
|
|
|
|
(push (org-export-footnote-first-reference-p ref info) result))
|
|
|
|
|
info)
|
|
|
|
|
(nreverse result)))))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
;; If optional argument BODY-FIRST is non-nil, first find footnote
|
|
|
|
|
;; in the main body of the document. Otherwise, enter footnote
|
|
|
|
|
;; definitions when they are encountered.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(t nil)
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
":BODY:\nText[fn:1][fn:2]\n:END:\n\n[fn:1] Definition[fn:2]\n\n[fn:2] Inner"
|
|
|
|
|
(let (result)
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
`(,(cons 'footnote-reference
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(lambda (f _c i)
|
2023-05-18 07:35:35 -04:00
|
|
|
|
(when (org-element-lineage f 'drawer)
|
2015-08-14 17:50:51 -04:00
|
|
|
|
(push (org-export-footnote-first-reference-p f i nil)
|
2015-02-13 08:10:51 -05:00
|
|
|
|
result))
|
|
|
|
|
""))
|
|
|
|
|
(drawer . (lambda (d c i) c))
|
|
|
|
|
(footnote-definition . (lambda (d c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))
|
|
|
|
|
(paragraph . (lambda (p c i) c))))
|
|
|
|
|
nil nil nil '(:with-footnotes t))
|
|
|
|
|
(nreverse result)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(t t)
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
":BODY:\nText[fn:1][fn:2]\n:END:\n\n[fn:1] Definition[fn:2]\n\n[fn:2] Inner"
|
|
|
|
|
(let (result)
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
`(,(cons 'footnote-reference
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(lambda (f _c i)
|
2023-05-18 07:35:35 -04:00
|
|
|
|
(when (org-element-lineage f 'drawer)
|
2015-08-14 17:50:51 -04:00
|
|
|
|
(push (org-export-footnote-first-reference-p f i nil t)
|
2015-02-13 08:10:51 -05:00
|
|
|
|
result))
|
|
|
|
|
""))
|
|
|
|
|
(drawer . (lambda (d c i) c))
|
|
|
|
|
(footnote-definition . (lambda (d c i) c))
|
|
|
|
|
(section . (lambda (s c i) c))
|
|
|
|
|
(paragraph . (lambda (p c i) c))))
|
|
|
|
|
nil nil nil '(:with-footnotes t))
|
|
|
|
|
(nreverse result))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-footnote-number ()
|
|
|
|
|
"Test `org-export-get-footnote-number' specifications."
|
|
|
|
|
(should
|
|
|
|
|
(equal '(1 2 1)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1][fn:2][fn:1]\n\n[fn:1] Def\n[fn:2] Def"
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref) (org-export-get-footnote-number ref info))
|
|
|
|
|
info))))
|
|
|
|
|
;; Anonymous footnotes all get a new number.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(1 2)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn::anon1][fn::anon2]"
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref) (org-export-get-footnote-number ref info))
|
|
|
|
|
info))))
|
|
|
|
|
;; Test nested footnotes order.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-12-16 12:22:27 -05:00
|
|
|
|
'((1 . "1") (2 . "2") (3 . "3") (3 . "3") (4))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1:A[fn:2]] [fn:3].\n\n[fn:2] B [fn:3] [fn::D].\n\n[fn:3] C."
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref)
|
|
|
|
|
(cons (org-export-get-footnote-number ref info)
|
|
|
|
|
(org-element-property :label ref)))
|
|
|
|
|
info))))
|
2015-02-21 03:34:15 -05:00
|
|
|
|
;; Limit number to provided DATA, when non-nil.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(1)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1]\n* H\nText[fn:2]\n\n[fn:1] D1\n[fn:2] D2"
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref)
|
|
|
|
|
(org-export-get-footnote-number
|
|
|
|
|
ref info (org-element-map tree 'headline #'identity info t)))
|
|
|
|
|
info))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(1 2)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1]\n* H\nText[fn:2]\n\n[fn:1] D1\n[fn:2]"
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref) (org-export-get-footnote-number ref info))
|
|
|
|
|
info))))
|
|
|
|
|
;; With a non-nil BODY-FIRST optional argument, first check body,
|
|
|
|
|
;; then footnote definitions.
|
2015-02-13 08:10:51 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-12-16 12:22:27 -05:00
|
|
|
|
'(("1" . 1) ("2" . 2) ("3" . 3) ("3" . 3))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1][fn:2][fn:3]\n\n[fn:1] Def[fn:3]\n[fn:2] Def\n[fn:3] Def"
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref)
|
|
|
|
|
(cons (org-element-property :label ref)
|
2015-02-21 03:34:15 -05:00
|
|
|
|
(org-export-get-footnote-number ref info nil t)))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
info))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-12-16 12:22:27 -05:00
|
|
|
|
'(("1" . 1) ("2" . 3) ("3" . 2) ("3" . 2))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1][fn:2][fn:3]\n\n[fn:1] Def[fn:3]\n[fn:2] Def\n[fn:3] Def"
|
|
|
|
|
(org-element-map tree 'footnote-reference
|
|
|
|
|
(lambda (ref)
|
|
|
|
|
(cons (org-element-property :label ref)
|
|
|
|
|
(org-export-get-footnote-number ref info nil)))
|
|
|
|
|
info)))))
|
|
|
|
|
|
2016-06-22 16:34:53 -04:00
|
|
|
|
(ert-deftest test-org-export/get-footnote-definition ()
|
|
|
|
|
"Test `org-export-get-footnote-definition' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal "A\n"
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1]\n\n[fn:1] A"
|
|
|
|
|
(org-export-get-footnote-definition
|
|
|
|
|
(org-element-map tree 'footnote-reference #'identity nil t)
|
|
|
|
|
info)))))
|
|
|
|
|
;; Raise an error if no definition is found.
|
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1]"
|
|
|
|
|
(org-export-get-footnote-definition
|
|
|
|
|
(org-element-map tree 'footnote-reference #'identity nil t)
|
|
|
|
|
info)))
|
|
|
|
|
;; Find inline definitions.
|
|
|
|
|
(should
|
|
|
|
|
(equal "A"
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1:A]"
|
|
|
|
|
(org-export-get-footnote-definition
|
|
|
|
|
(org-element-map tree 'footnote-reference #'identity nil t)
|
|
|
|
|
info)))))
|
|
|
|
|
;; Find anonymous definitions.
|
|
|
|
|
(should
|
|
|
|
|
(equal "A"
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(org-test-with-parsed-data "Text[fn::A]"
|
|
|
|
|
(org-export-get-footnote-definition
|
|
|
|
|
(org-element-map tree 'footnote-reference #'identity nil t)
|
|
|
|
|
info)))))
|
|
|
|
|
;; Find empty definitions.
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1]\n\n[fn:1]"
|
|
|
|
|
(org-export-get-footnote-definition
|
|
|
|
|
(org-element-map tree 'footnote-reference #'identity nil t)
|
|
|
|
|
info)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1:]"
|
|
|
|
|
(org-export-get-footnote-definition
|
|
|
|
|
(org-element-map tree 'footnote-reference #'identity nil t)
|
|
|
|
|
info)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
|
|
|
|
(org-element-interpret-data
|
|
|
|
|
(org-test-with-parsed-data "Text[fn::]"
|
|
|
|
|
(org-export-get-footnote-definition
|
|
|
|
|
(org-element-map tree 'footnote-reference #'identity nil t)
|
|
|
|
|
info))))))
|
|
|
|
|
|
2015-02-20 12:06:23 -05:00
|
|
|
|
(ert-deftest test-org-export/collect-footnote-definitions ()
|
|
|
|
|
"Test `org-export-collect-footnote-definitions' specifications."
|
|
|
|
|
(should
|
|
|
|
|
(= 4
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
|
|
|
|
|
|
|
|
|
|
\[fn:2] B [fn:3] [fn::D].
|
|
|
|
|
|
|
|
|
|
\[fn:3] C."
|
|
|
|
|
(length (org-export-collect-footnote-definitions info)))))
|
2015-02-21 03:34:15 -05:00
|
|
|
|
;; Limit number to provided DATA, when non-nil.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-12-16 12:22:27 -05:00
|
|
|
|
'((1 "2"))
|
2015-02-21 03:34:15 -05:00
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1]\n* H\nText[fn:2]\n\n[fn:1] D1\n[fn:2] D2"
|
|
|
|
|
(mapcar #'butlast
|
|
|
|
|
(org-export-collect-footnote-definitions
|
|
|
|
|
info (org-element-map tree 'headline #'identity info t))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-12-16 12:22:27 -05:00
|
|
|
|
'((1 "1") (2 "2"))
|
2015-02-21 03:34:15 -05:00
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Text[fn:1]\n* H\nText[fn:2]\n\n[fn:1] D1\n[fn:2] D2"
|
|
|
|
|
(mapcar #'butlast (org-export-collect-footnote-definitions info)))))
|
|
|
|
|
;; With optional argument BODY-FIRST, first check body, then
|
|
|
|
|
;; footnote definitions.
|
2015-02-20 12:06:23 -05:00
|
|
|
|
(should
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(equal '("1" "3" "2" nil)
|
2015-02-20 12:06:23 -05:00
|
|
|
|
(org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
|
|
|
|
|
|
|
|
|
|
\[fn:2] B [fn:3] [fn::D].
|
|
|
|
|
|
|
|
|
|
\[fn:3] C."
|
|
|
|
|
(mapcar (lambda (e) (nth 1 e))
|
2015-02-21 03:34:15 -05:00
|
|
|
|
(org-export-collect-footnote-definitions info nil t)))))
|
2015-02-20 12:06:23 -05:00
|
|
|
|
(should-not
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(equal '("1" "3" "2" nil)
|
2015-02-20 12:06:23 -05:00
|
|
|
|
(org-test-with-parsed-data "Text[fn:1:A[fn:2]] [fn:3].
|
|
|
|
|
|
|
|
|
|
\[fn:2] B [fn:3] [fn::D].
|
|
|
|
|
|
|
|
|
|
\[fn:3] C."
|
|
|
|
|
(mapcar (lambda (e) (nth 1 e))
|
|
|
|
|
(org-export-collect-footnote-definitions info))))))
|
|
|
|
|
|
2012-02-25 08:51:15 -05:00
|
|
|
|
(ert-deftest test-org-export/footnotes ()
|
2015-02-13 08:10:51 -05:00
|
|
|
|
"Miscellaneous tests on footnotes."
|
2012-06-06 17:39:04 -04:00
|
|
|
|
(let ((org-footnote-section nil)
|
|
|
|
|
(org-export-with-footnotes t))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
;; Read every type of footnote.
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-12-16 12:22:27 -05:00
|
|
|
|
'((1 . "A\n") (2 . "C") (3 . "D"))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(org-test-with-parsed-data
|
2015-12-16 12:22:27 -05:00
|
|
|
|
"Text[fn:1] [fn:label:C] [fn::D]\n\n[fn:1] A\n"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'footnote-reference
|
2013-02-13 09:51:08 -05:00
|
|
|
|
(lambda (ref)
|
|
|
|
|
(let ((def (org-export-get-footnote-definition ref info)))
|
|
|
|
|
(cons (org-export-get-footnote-number ref info)
|
|
|
|
|
(if (eq (org-element-property :type ref) 'inline) (car def)
|
|
|
|
|
(car (org-element-contents
|
|
|
|
|
(car (org-element-contents def))))))))
|
|
|
|
|
info))))
|
2016-06-27 17:50:58 -04:00
|
|
|
|
;; Export nested footnote in invisible definitions.
|
2015-06-23 09:28:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 2
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(org-test-with-temp-text "Text[fn:1]\n\n[fn:1] B [fn:2]\n\n[fn:2] C."
|
2015-06-23 09:28:01 -04:00
|
|
|
|
(narrow-to-region (point) (line-end-position))
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((section
|
|
|
|
|
.
|
|
|
|
|
(lambda (s c i)
|
|
|
|
|
(throw 'exit (length
|
|
|
|
|
(org-export-collect-footnote-definitions
|
|
|
|
|
i))))))))))))
|
2016-06-27 17:50:58 -04:00
|
|
|
|
;; Export footnotes defined outside parsing scope.
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(should
|
2016-06-27 17:50:58 -04:00
|
|
|
|
(string-match
|
|
|
|
|
"Out of scope"
|
|
|
|
|
(org-test-with-temp-text "[fn:1] Out of scope
|
|
|
|
|
* Title
|
|
|
|
|
<point>Paragraph[fn:1]"
|
|
|
|
|
(org-export-as (org-test-default-backend) 'subtree))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"Out of scope"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "[fn:1] Out of scope
|
2012-04-13 09:30:02 -04:00
|
|
|
|
* Title
|
2015-06-23 09:28:01 -04:00
|
|
|
|
<point>Paragraph[fn:1]"
|
2016-06-27 17:50:58 -04:00
|
|
|
|
(narrow-to-region (point) (point-max))
|
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
|
|
|
|
;; Export nested footnotes defined outside parsing scope.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"Very out of scope"
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
\[fn:1] Out of scope[fn:2]
|
|
|
|
|
|
|
|
|
|
\[fn:2] Very out of scope
|
|
|
|
|
* Title
|
|
|
|
|
<point>Paragraph[fn:1]"
|
|
|
|
|
(org-export-as (org-test-default-backend) 'subtree))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"Very out of scope"
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
\[fn:1] Out of scope[fn:2]
|
|
|
|
|
|
|
|
|
|
\[fn:2] Very out of scope
|
|
|
|
|
* Title
|
2016-06-27 18:28:47 -04:00
|
|
|
|
<point>Paragraph[fn:1]"
|
|
|
|
|
(narrow-to-region (point) (point-max))
|
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"D2"
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
\[fn:1] Out of scope[fn:2:D2]
|
|
|
|
|
* Title
|
2016-06-27 17:50:58 -04:00
|
|
|
|
<point>Paragraph[fn:1]"
|
|
|
|
|
(narrow-to-region (point) (point-max))
|
|
|
|
|
(org-export-as (org-test-default-backend)))))
|
|
|
|
|
;; Export footnotes in pruned parts of tree.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"Definition"
|
|
|
|
|
(let ((org-export-exclude-tags '("noexport")))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\nText[fn:1]\n* H2 :noexport:\n[fn:1] Definition"
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"Definition"
|
|
|
|
|
(let ((org-export-select-tags '("export")))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H :export:\nText[fn:1]\n* H2\n[fn:1] Definition"
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
;; Export nested footnotes in pruned parts of tree.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"D2"
|
|
|
|
|
(let ((org-export-exclude-tags '("noexport")))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\nText[fn:1]\n* H2 :noexport:\n[fn:1] D1[fn:2]\n\n[fn:2] D2"
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"D2"
|
|
|
|
|
(let ((org-export-select-tags '("export")))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H :export:\nText[fn:1]\n* H2\n[fn:1] D1[fn:2]\n\n[fn:2] D2"
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
|
|
|
|
;; Handle uninterpreted data in pruned footnote definitions.
|
|
|
|
|
(should-not
|
|
|
|
|
(string-match
|
|
|
|
|
"|"
|
|
|
|
|
(let ((org-export-with-tables nil))
|
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"* H\nText[fn:1]\n* H2 :noexport:\n[fn:1]\n| a |"
|
|
|
|
|
(org-export-as (org-test-default-backend))))))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
;; Footnotes without a definition should throw an error.
|
2014-10-12 17:18:40 -04:00
|
|
|
|
(should-error
|
|
|
|
|
(org-test-with-parsed-data "Text[fn:1]"
|
2013-01-30 08:17:30 -05:00
|
|
|
|
(org-export-get-footnote-definition
|
2015-06-23 09:28:01 -04:00
|
|
|
|
(org-element-map tree 'footnote-reference #'identity info t) info)))
|
2015-02-13 08:10:51 -05:00
|
|
|
|
;; Footnote section should be ignored in TOC and in headlines
|
|
|
|
|
;; numbering.
|
2013-02-13 09:51:08 -05:00
|
|
|
|
(should
|
|
|
|
|
(= 1 (let ((org-footnote-section "Footnotes"))
|
|
|
|
|
(length (org-test-with-parsed-data "* H1\n* Footnotes\n"
|
|
|
|
|
(org-export-collect-headlines info))))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '(2)
|
|
|
|
|
(let ((org-footnote-section "Footnotes"))
|
|
|
|
|
(org-test-with-parsed-data "* H1\n* Footnotes\n* H2"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (hl)
|
|
|
|
|
(when (equal (org-element-property :raw-value hl) "H2")
|
|
|
|
|
(org-export-get-headline-number hl info)))
|
|
|
|
|
info t)))))))
|
2012-02-20 16:24:38 -05:00
|
|
|
|
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
2012-05-26 07:44:13 -04:00
|
|
|
|
|
|
|
|
|
;;; Headlines and Inlinetasks
|
|
|
|
|
|
2012-07-04 11:37:55 -04:00
|
|
|
|
(ert-deftest test-org-export/get-relative-level ()
|
|
|
|
|
"Test `org-export-get-relative-level' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(1 2)
|
|
|
|
|
(let ((org-odd-levels-only nil))
|
|
|
|
|
(org-test-with-parsed-data "* Headline 1\n** Headline 2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-get-relative-level h info))
|
|
|
|
|
info)))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
;; Missing levels
|
|
|
|
|
(should
|
|
|
|
|
(equal '(1 3)
|
|
|
|
|
(let ((org-odd-levels-only nil))
|
|
|
|
|
(org-test-with-parsed-data "** Headline 1\n**** Headline 2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-get-relative-level h info))
|
|
|
|
|
info))))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/low-level-p ()
|
|
|
|
|
"Test `org-export-low-level-p' specifications."
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(no yes)
|
|
|
|
|
(let ((org-odd-levels-only nil))
|
|
|
|
|
(org-test-with-parsed-data "* Headline 1\n** Headline 2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-low-level-p h info) 'yes 'no))
|
|
|
|
|
(plist-put info :headline-levels 1)))))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-headline-number ()
|
|
|
|
|
"Test `org-export-get-headline-number' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'((1) (1 1))
|
|
|
|
|
(let ((org-odd-levels-only nil))
|
|
|
|
|
(org-test-with-parsed-data "* Headline 1\n** Headline 2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-get-headline-number h info))
|
|
|
|
|
info)))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
;; Missing levels are replaced with 0.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'((1) (1 0 1))
|
|
|
|
|
(let ((org-odd-levels-only nil))
|
|
|
|
|
(org-test-with-parsed-data "* Headline 1\n*** Headline 2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-get-headline-number h info))
|
|
|
|
|
info))))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/numbered-headline-p ()
|
|
|
|
|
"Test `org-export-numbered-headline-p' specifications."
|
|
|
|
|
;; If `:section-numbers' is nil, never number headlines.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-numbered-headline-p h info))
|
|
|
|
|
(plist-put info :section-numbers nil))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
;; If `:section-numbers' is a number, only number headlines with
|
|
|
|
|
;; a level greater that it.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no)
|
|
|
|
|
(org-test-with-parsed-data "* Headline 1\n** Headline 2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-numbered-headline-p h info) 'yes 'no))
|
|
|
|
|
(plist-put info :section-numbers 1)))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
;; Otherwise, headlines are always numbered.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-numbered-headline-p h info))
|
2015-04-12 18:49:17 -04:00
|
|
|
|
(plist-put info :section-numbers t))))
|
|
|
|
|
;; With #+OPTIONS: num:nil all headlines are unnumbered.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "* H\n#+OPTIONS: num:nil"
|
|
|
|
|
(org-export-numbered-headline-p
|
|
|
|
|
(org-element-map tree 'headline 'identity info t)
|
|
|
|
|
info)))
|
|
|
|
|
;; Headlines with a non-nil UNNUMBERED property are not numbered.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "* H\n:PROPERTIES:\n:UNNUMBERED: t\n:END:"
|
|
|
|
|
(org-export-numbered-headline-p
|
|
|
|
|
(org-element-map tree 'headline #'identity info t)
|
|
|
|
|
info)))
|
2017-11-19 17:59:56 -05:00
|
|
|
|
;; UNNUMBERED is inherited.
|
2014-09-21 10:17:55 -04:00
|
|
|
|
(should
|
2017-11-19 17:59:56 -05:00
|
|
|
|
(equal '(unnumbered numbered unnumbered)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* H
|
2014-09-21 10:17:55 -04:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:UNNUMBERED: t
|
|
|
|
|
:END:
|
|
|
|
|
** H2
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:UNNUMBERED: nil
|
|
|
|
|
:END:
|
2017-11-19 17:59:56 -05:00
|
|
|
|
** H3"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h)
|
|
|
|
|
(if (org-export-numbered-headline-p h info) 'numbered
|
|
|
|
|
'unnumbered))
|
|
|
|
|
info)))))
|
2014-09-21 10:17:55 -04:00
|
|
|
|
|
2012-07-04 11:37:55 -04:00
|
|
|
|
(ert-deftest test-org-export/number-to-roman ()
|
|
|
|
|
"Test `org-export-number-to-roman' specifications."
|
|
|
|
|
;; If number is negative, return it as a string.
|
|
|
|
|
(should (equal (org-export-number-to-roman -1) "-1"))
|
|
|
|
|
;; Otherwise, return it as a roman number.
|
|
|
|
|
(should (equal (org-export-number-to-roman 1449) "MCDXLIX")))
|
|
|
|
|
|
2013-02-24 03:15:26 -05:00
|
|
|
|
(ert-deftest test-org-export/get-optional-title ()
|
2013-02-26 18:00:33 -05:00
|
|
|
|
"Test `org-export-get-alt-title' specifications."
|
|
|
|
|
;; If ALT_TITLE property is defined, use it.
|
2013-02-24 03:15:26 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal '("opt")
|
|
|
|
|
(org-test-with-parsed-data
|
2013-02-26 18:00:33 -05:00
|
|
|
|
"* Headline\n:PROPERTIES:\n:ALT_TITLE: opt\n:END:"
|
|
|
|
|
(org-export-get-alt-title
|
2013-02-24 03:15:26 -05:00
|
|
|
|
(org-element-map tree 'headline 'identity info t)
|
|
|
|
|
info))))
|
|
|
|
|
;; Otherwise, fall-back to regular title.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("Headline")
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
2013-02-26 18:00:33 -05:00
|
|
|
|
(org-export-get-alt-title
|
2013-02-24 03:15:26 -05:00
|
|
|
|
(org-element-map tree 'headline 'identity info t)
|
|
|
|
|
info)))))
|
|
|
|
|
|
2012-05-26 07:44:13 -04:00
|
|
|
|
(ert-deftest test-org-export/get-tags ()
|
|
|
|
|
"Test `org-export-get-tags' specifications."
|
2015-11-10 17:38:04 -05:00
|
|
|
|
;; Standard test: tags which are not a select tag, an exclude tag,
|
|
|
|
|
;; or specified as optional argument shouldn't be ignored.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Headline :tag:"
|
|
|
|
|
(org-export-get-tags (org-element-map tree 'headline 'identity info t)
|
|
|
|
|
info)))
|
|
|
|
|
;; Tags provided in the optional argument are ignored.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "* Headline :ignore:"
|
|
|
|
|
(org-export-get-tags (org-element-map tree 'headline 'identity info t)
|
|
|
|
|
info '("ignore"))))
|
|
|
|
|
;; Allow tag inheritance.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(("tag") ("tag"))
|
|
|
|
|
(org-test-with-parsed-data "* Headline :tag:\n** Sub-heading"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (hl) (org-export-get-tags hl info nil t)) info))))
|
|
|
|
|
;; Tag inheritance checks FILETAGS keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(("a" "b" "tag"))
|
|
|
|
|
(org-test-with-parsed-data "#+FILETAGS: :a:b:\n* Headline :tag:"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (hl) (org-export-get-tags hl info nil t)) info)))))
|
2012-05-26 07:44:13 -04:00
|
|
|
|
|
2012-09-23 13:37:21 -04:00
|
|
|
|
(ert-deftest test-org-export/get-node-property ()
|
|
|
|
|
"Test`org-export-get-node-property' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal "value"
|
|
|
|
|
(org-test-with-parsed-data "* Headline
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:prop: value
|
|
|
|
|
:END:"
|
|
|
|
|
(org-export-get-node-property
|
export-back-ends: Apply changes from b692064e621acbc93876670585f8a4b0fd6a7ffa
* lisp/ox-beamer.el (org-beamer--get-label, org-beamer--frame-level,
org-beamer--format-section, org-beamer--format-frame,
org-beamer--format-block, org-beamer-headline): Apply changes to
properties.
* lisp/ox-html.el (org-html-headline, org-html-link,
org-html-section): Apply changes to properties.
* lisp/ox-icalendar.el (org-icalendar-create-uid,
org-icalendar-blocked-headline-p, org-icalendar-entry,
org-icalendar--valarm): Apply changes to properties.
* lisp/ox-odt.el (org-odt-headline): Apply changes
* lisp/ox-publish.el (org-publish-collect-index): Apply changes to
properties.
* lisp/ox-texinfo.el (org-texinfo--generate-menu-list,
org-texinfo--generate-menu-items, org-texinfo-template,
org-texinfo-headline, org-texinfo-link): Apply changes to
properties.
* lisp/ox.el (org-export-resolve-id-link, org-export-get-category):
Apply changes to properties.
(org-export-get-node-property): Update docstring.
* testing/lisp/test-ox.el: Update tests.
2013-02-17 18:01:21 -05:00
|
|
|
|
:PROP (org-element-map tree 'headline 'identity nil t)))))
|
2012-09-23 13:37:21 -04:00
|
|
|
|
;; Test inheritance.
|
|
|
|
|
(should
|
|
|
|
|
(equal "value"
|
|
|
|
|
(org-test-with-parsed-data "* Parent
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:prop: value
|
|
|
|
|
:END:
|
|
|
|
|
** Headline
|
|
|
|
|
Paragraph"
|
|
|
|
|
(org-export-get-node-property
|
export-back-ends: Apply changes from b692064e621acbc93876670585f8a4b0fd6a7ffa
* lisp/ox-beamer.el (org-beamer--get-label, org-beamer--frame-level,
org-beamer--format-section, org-beamer--format-frame,
org-beamer--format-block, org-beamer-headline): Apply changes to
properties.
* lisp/ox-html.el (org-html-headline, org-html-link,
org-html-section): Apply changes to properties.
* lisp/ox-icalendar.el (org-icalendar-create-uid,
org-icalendar-blocked-headline-p, org-icalendar-entry,
org-icalendar--valarm): Apply changes to properties.
* lisp/ox-odt.el (org-odt-headline): Apply changes
* lisp/ox-publish.el (org-publish-collect-index): Apply changes to
properties.
* lisp/ox-texinfo.el (org-texinfo--generate-menu-list,
org-texinfo--generate-menu-items, org-texinfo-template,
org-texinfo-headline, org-texinfo-link): Apply changes to
properties.
* lisp/ox.el (org-export-resolve-id-link, org-export-get-category):
Apply changes to properties.
(org-export-get-node-property): Update docstring.
* testing/lisp/test-ox.el: Update tests.
2013-02-17 18:01:21 -05:00
|
|
|
|
:PROP (org-element-map tree 'paragraph 'identity nil t) t))))
|
2012-09-23 13:37:21 -04:00
|
|
|
|
;; Cannot return a value before the first headline.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "Paragraph
|
|
|
|
|
* Headline
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:prop: value
|
|
|
|
|
:END:"
|
|
|
|
|
(org-export-get-node-property
|
export-back-ends: Apply changes from b692064e621acbc93876670585f8a4b0fd6a7ffa
* lisp/ox-beamer.el (org-beamer--get-label, org-beamer--frame-level,
org-beamer--format-section, org-beamer--format-frame,
org-beamer--format-block, org-beamer-headline): Apply changes to
properties.
* lisp/ox-html.el (org-html-headline, org-html-link,
org-html-section): Apply changes to properties.
* lisp/ox-icalendar.el (org-icalendar-create-uid,
org-icalendar-blocked-headline-p, org-icalendar-entry,
org-icalendar--valarm): Apply changes to properties.
* lisp/ox-odt.el (org-odt-headline): Apply changes
* lisp/ox-publish.el (org-publish-collect-index): Apply changes to
properties.
* lisp/ox-texinfo.el (org-texinfo--generate-menu-list,
org-texinfo--generate-menu-items, org-texinfo-template,
org-texinfo-headline, org-texinfo-link): Apply changes to
properties.
* lisp/ox.el (org-export-resolve-id-link, org-export-get-category):
Apply changes to properties.
(org-export-get-node-property): Update docstring.
* testing/lisp/test-ox.el: Update tests.
2013-02-17 18:01:21 -05:00
|
|
|
|
:PROP (org-element-map tree 'paragraph 'identity nil t)))))
|
2012-09-23 13:37:21 -04:00
|
|
|
|
|
2012-11-02 08:44:46 -04:00
|
|
|
|
(ert-deftest test-org-export/get-category ()
|
|
|
|
|
"Test `org-export-get-category' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal "value"
|
|
|
|
|
(org-test-with-parsed-data "* Headline
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:CATEGORY: value
|
|
|
|
|
:END:"
|
|
|
|
|
(org-export-get-category
|
|
|
|
|
(org-element-map tree 'headline 'identity nil t) info))))
|
|
|
|
|
;; Test inheritance from a parent headline.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("value" "value")
|
|
|
|
|
(org-test-with-parsed-data "* Headline1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:CATEGORY: value
|
|
|
|
|
:END:
|
|
|
|
|
** Headline2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (hl) (org-export-get-category hl info)) info))))
|
2012-11-02 08:44:46 -04:00
|
|
|
|
;; Test inheritance from #+CATEGORY keyword
|
|
|
|
|
(should
|
|
|
|
|
(equal "value"
|
|
|
|
|
(org-test-with-parsed-data "#+CATEGORY: value
|
|
|
|
|
* Headline"
|
|
|
|
|
(org-export-get-category
|
|
|
|
|
(org-element-map tree 'headline 'identity nil t) info))))
|
|
|
|
|
;; Test inheritance from file name.
|
|
|
|
|
(should
|
|
|
|
|
(equal "test"
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
|
|
|
|
(let ((info (plist-put info :input-file "~/test.org")))
|
|
|
|
|
(org-export-get-category
|
|
|
|
|
(org-element-map tree 'headline 'identity nil t) info)))))
|
|
|
|
|
;; Fall-back value.
|
|
|
|
|
(should
|
|
|
|
|
(equal "???"
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
|
|
|
|
(org-export-get-category
|
|
|
|
|
(org-element-map tree 'headline 'identity nil t) info)))))
|
|
|
|
|
|
2012-07-04 11:37:55 -04:00
|
|
|
|
(ert-deftest test-org-export/first-sibling-p ()
|
|
|
|
|
"Test `org-export-first-sibling-p' specifications."
|
2012-07-27 10:13:57 -04:00
|
|
|
|
;; Standard test.
|
2012-07-04 11:37:55 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes yes no)
|
2014-08-26 08:41:36 -04:00
|
|
|
|
(org-test-with-parsed-data "* H\n** H 2\n** H 3"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-first-sibling-p h info) 'yes 'no))
|
|
|
|
|
info))))
|
2014-08-26 08:41:36 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(yes no)
|
|
|
|
|
(org-test-with-parsed-data "- item\n\n para"
|
|
|
|
|
(org-element-map tree 'paragraph
|
|
|
|
|
(lambda (h) (if (org-export-first-sibling-p h info) 'yes 'no))
|
|
|
|
|
info))))
|
|
|
|
|
;; Ignore sections for headlines.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(yes yes)
|
|
|
|
|
(org-test-with-parsed-data "* H\nSection\n** H 2"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-first-sibling-p h info) 'yes 'no))
|
|
|
|
|
info))))
|
2012-07-27 10:13:57 -04:00
|
|
|
|
;; Ignore headlines not exported.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes)
|
|
|
|
|
(let ((org-export-exclude-tags '("ignore")))
|
|
|
|
|
(org-test-with-parsed-data "* Headline :ignore:\n* Headline 2"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-first-sibling-p h info) 'yes 'no))
|
|
|
|
|
info))))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/last-sibling-p ()
|
|
|
|
|
"Test `org-export-last-sibling-p' specifications."
|
2012-07-27 10:13:57 -04:00
|
|
|
|
;; Standard test.
|
2012-07-04 11:37:55 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no yes)
|
2012-07-27 10:13:57 -04:00
|
|
|
|
(org-test-with-parsed-data "* Headline\n** Headline 2\n** Headline 3"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-last-sibling-p h info) 'yes 'no))
|
|
|
|
|
info))))
|
2014-08-26 08:41:36 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(no yes)
|
|
|
|
|
(org-test-with-parsed-data "- item\n\n para"
|
|
|
|
|
(org-element-map tree 'paragraph
|
|
|
|
|
(lambda (h) (if (org-export-last-sibling-p h info) 'yes 'no))
|
|
|
|
|
info))))
|
2012-07-27 10:13:57 -04:00
|
|
|
|
;; Ignore headlines not exported.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes)
|
|
|
|
|
(let ((org-export-exclude-tags '("ignore")))
|
|
|
|
|
(org-test-with-parsed-data "* Headline\n* Headline 2 :ignore:"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-last-sibling-p h info) 'yes 'no))
|
2017-12-02 06:21:03 -05:00
|
|
|
|
info)))))
|
|
|
|
|
;; Handle gracefully discontinuous headings.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(yes yes)
|
|
|
|
|
(org-test-with-parsed-data "** S\n* H"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-last-sibling-p h info) 'yes 'no)))))))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
|
2013-03-02 08:34:45 -05:00
|
|
|
|
(ert-deftest test-org-export/handle-inlinetasks ()
|
|
|
|
|
"Test inlinetask export."
|
|
|
|
|
;; Inlinetask with an exclude tag.
|
|
|
|
|
(when (featurep 'org-inlinetask)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
""
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(let ((org-inlinetask-min-level 3)
|
|
|
|
|
org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
2013-03-02 08:34:45 -05:00
|
|
|
|
(org-test-with-temp-text "*** Inlinetask :noexp:\nContents\n*** end"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:exclude-tags ("noexp")))))))
|
2013-03-02 08:34:45 -05:00
|
|
|
|
;; Inlinetask with an include tag.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"* H2\n*** Inline :exp:\n"
|
|
|
|
|
(let ((org-inlinetask-min-level 3)
|
|
|
|
|
(org-tags-column 0))
|
|
|
|
|
(org-test-with-temp-text "* H1\n* H2\n*** Inline :exp:"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:select-tags ("exp")))))))
|
2013-03-02 08:34:45 -05:00
|
|
|
|
;; Ignore inlinetask with a TODO keyword and tasks excluded.
|
|
|
|
|
(should
|
|
|
|
|
(equal ""
|
|
|
|
|
(let ((org-todo-keywords '((sequence "TODO" "DONE")))
|
2015-01-22 00:59:04 -05:00
|
|
|
|
(org-inlinetask-min-level 3)
|
|
|
|
|
org-export-filter-body-functions
|
|
|
|
|
org-export-filter-final-output-functions)
|
2013-03-02 08:34:45 -05:00
|
|
|
|
(org-test-with-temp-text "*** TODO Inline"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-export-as (org-test-default-backend)
|
|
|
|
|
nil nil nil '(:with-tasks nil))))))))
|
2013-03-02 08:34:45 -05:00
|
|
|
|
|
2012-05-26 07:44:13 -04:00
|
|
|
|
|
2013-04-02 17:55:28 -04:00
|
|
|
|
|
|
|
|
|
;;; Keywords
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-date ()
|
|
|
|
|
"Test `org-export-get-date' specifications."
|
|
|
|
|
;; Return a properly formatted string when
|
|
|
|
|
;; `org-export-date-timestamp-format' is non-nil and DATE keyword
|
|
|
|
|
;; consists in a single timestamp.
|
|
|
|
|
(should
|
|
|
|
|
(equal "29 03 2012"
|
|
|
|
|
(let ((org-export-date-timestamp-format "%d %m %Y"))
|
|
|
|
|
(org-test-with-parsed-data "#+DATE: <2012-03-29 Thu>"
|
|
|
|
|
(org-export-get-date info)))))
|
|
|
|
|
;; Return a secondary string otherwise.
|
|
|
|
|
(should-not
|
|
|
|
|
(stringp
|
|
|
|
|
(let ((org-export-date-timestamp-format nil))
|
|
|
|
|
(org-test-with-parsed-data "#+DATE: <2012-03-29 Thu>"
|
|
|
|
|
(org-export-get-date info)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '("Date")
|
|
|
|
|
(org-test-with-parsed-data "#+DATE: Date"
|
|
|
|
|
(org-export-get-date info))))
|
|
|
|
|
;; Optional argument has precedence over
|
|
|
|
|
;; `org-export-date-timestamp-format'.
|
|
|
|
|
(should
|
|
|
|
|
(equal "29 03"
|
|
|
|
|
(let ((org-export-date-timestamp-format "%d %m %Y"))
|
|
|
|
|
(org-test-with-parsed-data "#+DATE: <2012-03-29 Thu>"
|
|
|
|
|
(org-export-get-date info "%d %m"))))))
|
|
|
|
|
|
|
|
|
|
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
|
|
|
|
;;; Links
|
|
|
|
|
|
2015-01-04 15:54:41 -05:00
|
|
|
|
(ert-deftest test-org-export/custom-protocol-maybe ()
|
|
|
|
|
"Test `org-export-custom-protocol-maybe' specifications."
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"success"
|
2016-07-07 09:58:29 -04:00
|
|
|
|
(progn
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(org-link-set-parameters "foo" :export (lambda (_p _d _f _i) "success"))
|
2015-01-04 15:54:41 -05:00
|
|
|
|
(org-export-string-as
|
|
|
|
|
"[[foo:path]]"
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:name 'test
|
2015-02-24 09:54:01 -05:00
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (s c i) c))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(link . (lambda (l c i)
|
2020-02-14 04:00:15 -05:00
|
|
|
|
(or (org-export-custom-protocol-maybe l c 'test i)
|
2015-02-24 09:54:01 -05:00
|
|
|
|
"failure")))))))))
|
2015-01-04 15:54:41 -05:00
|
|
|
|
(should-not
|
|
|
|
|
(string-match
|
|
|
|
|
"success"
|
2016-07-07 09:58:29 -04:00
|
|
|
|
(progn
|
|
|
|
|
(org-link-set-parameters
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
"foo" :export (lambda (_p _d f _i) (and (eq f 'test) "success")))
|
2015-01-04 15:54:41 -05:00
|
|
|
|
(org-export-string-as
|
|
|
|
|
"[[foo:path]]"
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:name 'no-test
|
2015-02-24 09:54:01 -05:00
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (s c i) c))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(link . (lambda (l c i)
|
2020-02-14 04:00:15 -05:00
|
|
|
|
(or (org-export-custom-protocol-maybe l c 'no-test i)
|
2015-02-24 09:54:01 -05:00
|
|
|
|
"failure")))))))))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; Ignore anonymous backends.
|
2015-01-04 15:54:41 -05:00
|
|
|
|
(should-not
|
|
|
|
|
(string-match
|
|
|
|
|
"success"
|
2016-07-07 09:58:29 -04:00
|
|
|
|
(progn
|
|
|
|
|
(org-link-set-parameters
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
"foo" :export (lambda (_p _d f _i) (and (eq f 'test) "success")))
|
2015-01-04 15:54:41 -05:00
|
|
|
|
(org-export-string-as
|
|
|
|
|
"[[foo:path]]"
|
|
|
|
|
(org-export-create-backend
|
2015-02-24 09:54:01 -05:00
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (s c i) c))
|
|
|
|
|
(paragraph . (lambda (p c i) c))
|
|
|
|
|
(link . (lambda (l c i)
|
2020-02-14 04:00:15 -05:00
|
|
|
|
(or (org-export-custom-protocol-maybe l c nil i)
|
2015-02-24 09:54:01 -05:00
|
|
|
|
"failure"))))))))))
|
2015-01-04 15:54:41 -05:00
|
|
|
|
|
2012-07-04 11:37:55 -04:00
|
|
|
|
(ert-deftest test-org-export/get-coderef-format ()
|
|
|
|
|
"Test `org-export-get-coderef-format' specifications."
|
|
|
|
|
;; A link without description returns "%s"
|
|
|
|
|
(should (equal (org-export-get-coderef-format "(ref:line)" nil)
|
|
|
|
|
"%s"))
|
|
|
|
|
;; Return "%s" when path is matched within description.
|
|
|
|
|
(should (equal (org-export-get-coderef-format "path" "desc (path)")
|
|
|
|
|
"desc %s"))
|
|
|
|
|
;; Otherwise return description.
|
|
|
|
|
(should (equal (org-export-get-coderef-format "path" "desc")
|
|
|
|
|
"desc")))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/inline-image-p ()
|
|
|
|
|
"Test `org-export-inline-image-p' specifications."
|
|
|
|
|
(should
|
|
|
|
|
(org-export-inline-image-p
|
|
|
|
|
(org-test-with-temp-text "[[#id]]"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map (org-element-parse-buffer) 'link 'identity nil t))
|
2012-07-04 11:37:55 -04:00
|
|
|
|
'(("custom-id" . "id")))))
|
|
|
|
|
|
2016-12-19 12:02:38 -05:00
|
|
|
|
(ert-deftest test-org-export/insert-image-links ()
|
|
|
|
|
"Test `org-export-insert-image-links' specifications."
|
|
|
|
|
(should-not
|
|
|
|
|
(member "file"
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(org-test-with-parsed-data "[[https://orgmode.org][file:image.png]]"
|
2016-12-19 12:02:38 -05:00
|
|
|
|
(org-element-map tree 'link
|
|
|
|
|
(lambda (l) (org-element-property :type l))))))
|
|
|
|
|
(should
|
|
|
|
|
(member "file"
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(org-test-with-parsed-data "[[https://orgmode.org][file:image.png]]"
|
2016-12-19 12:02:38 -05:00
|
|
|
|
(org-element-map (org-export-insert-image-links tree info) 'link
|
|
|
|
|
(lambda (l) (org-element-property :type l))))))
|
2017-01-07 09:48:49 -05:00
|
|
|
|
;; Properly set `:parent' property when replace contents with image
|
|
|
|
|
;; link.
|
|
|
|
|
(should
|
|
|
|
|
(memq 'link
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(org-test-with-parsed-data "[[https://orgmode.org][file:image.png]]"
|
2017-01-07 09:48:49 -05:00
|
|
|
|
(org-element-map (org-export-insert-image-links tree info) 'link
|
|
|
|
|
(lambda (l)
|
|
|
|
|
(org-element-type (org-element-property :parent l)))))))
|
2016-12-19 12:02:38 -05:00
|
|
|
|
;; With optional argument RULES, recognize different links as
|
|
|
|
|
;; images.
|
|
|
|
|
(should-not
|
|
|
|
|
(member "file"
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(org-test-with-parsed-data "[[https://orgmode.org][file:image.xxx]]"
|
2016-12-19 12:02:38 -05:00
|
|
|
|
(org-element-map (org-export-insert-image-links tree info) 'link
|
|
|
|
|
(lambda (l) (org-element-property :type l))))))
|
|
|
|
|
(should
|
|
|
|
|
(member "file"
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(org-test-with-parsed-data "[[https://orgmode.org][file:image.xxx]]"
|
2016-12-19 12:02:38 -05:00
|
|
|
|
(org-element-map
|
|
|
|
|
(org-export-insert-image-links tree info '(("file" . "xxx")))
|
|
|
|
|
'link
|
2019-02-11 19:15:55 -05:00
|
|
|
|
(lambda (l) (org-element-property :type l))))))
|
|
|
|
|
;; If an image link was included from another file, make sure to
|
|
|
|
|
;; shift any relative path accordingly.
|
|
|
|
|
(should
|
|
|
|
|
(string-prefix-p
|
|
|
|
|
"file:org-includee-"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "file:foo.png" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (_s c _i) c))
|
|
|
|
|
(paragraph . (lambda (_p c _i) c))
|
|
|
|
|
(link . (lambda (l c _i) (org-element-link-interpreter l c))))
|
|
|
|
|
:filters
|
|
|
|
|
'((:filter-parse-tree
|
|
|
|
|
(lambda (d _b i) (org-export-insert-image-links d i)))))))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
|
|
|
|
"file:org-includee-.+?foo\\.png"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "[[https://orgmode.org][file:foo.png]]" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (_s c _i) c))
|
|
|
|
|
(paragraph . (lambda (_p c _i) c))
|
|
|
|
|
(link . (lambda (l c _i) (org-element-link-interpreter l c))))
|
|
|
|
|
:filters
|
|
|
|
|
'((:filter-parse-tree
|
|
|
|
|
(lambda (d _b i) (org-export-insert-image-links d i)))))))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer)))))))
|
|
|
|
|
(should
|
|
|
|
|
(string-match-p
|
|
|
|
|
"file:org-includee.+?file:org-includee"
|
|
|
|
|
(let* ((subdir (make-temp-file "org-includee-" t))
|
|
|
|
|
(includee (expand-file-name "includee.org" subdir))
|
|
|
|
|
(includer (make-temp-file "org-includer-")))
|
|
|
|
|
(write-region "[[file:bar.png][file:foo.png]]" nil includee)
|
|
|
|
|
(write-region (format "#+INCLUDE: %S"
|
|
|
|
|
(file-relative-name includee
|
|
|
|
|
temporary-file-directory))
|
|
|
|
|
nil includer)
|
|
|
|
|
(let ((buffer (find-file-noselect includer t)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((section . (lambda (_s c _i) c))
|
|
|
|
|
(paragraph . (lambda (_p c _i) c))
|
|
|
|
|
(link . (lambda (l c _i) (org-element-link-interpreter l c))))
|
|
|
|
|
:filters
|
|
|
|
|
'((:filter-parse-tree
|
|
|
|
|
(lambda (d _b i) (org-export-insert-image-links d i)))))))
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer (set-buffer-modified-p nil))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
(when (file-exists-p subdir) (delete-directory subdir t))
|
|
|
|
|
(when (file-exists-p includer) (delete-file includer))))))))
|
2016-12-19 12:02:38 -05:00
|
|
|
|
|
2012-06-06 18:06:19 -04:00
|
|
|
|
(ert-deftest test-org-export/fuzzy-link ()
|
|
|
|
|
"Test fuzzy links specifications."
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Link to an headline should return headline's number.
|
2016-03-06 16:42:26 -05:00
|
|
|
|
(should
|
|
|
|
|
;; Note: Headline's number is in fact a list of numbers.
|
|
|
|
|
(equal '(2)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"Paragraph.\n* Head1\n* Head2\n* Head3\n[[Head2]]"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'link
|
2013-02-15 12:08:03 -05:00
|
|
|
|
(lambda (link)
|
|
|
|
|
(org-export-get-ordinal
|
|
|
|
|
(org-export-resolve-fuzzy-link link info) info)) info t))))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Link to a target in an item should return item's number.
|
2016-03-06 16:42:26 -05:00
|
|
|
|
(should
|
|
|
|
|
;; Note: Item's number is in fact a list of numbers.
|
|
|
|
|
(equal '(1 2)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"- Item1\n - Item11\n - <<test>>Item12\n- Item2\n\n\n[[test]]"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'link
|
2013-02-15 12:08:03 -05:00
|
|
|
|
(lambda (link)
|
|
|
|
|
(org-export-get-ordinal
|
|
|
|
|
(org-export-resolve-fuzzy-link link info) info)) info t))))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Link to a target in a footnote should return footnote's number.
|
2016-03-06 16:42:26 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal '(2 3)
|
|
|
|
|
(org-test-with-parsed-data "
|
2015-12-16 12:22:27 -05:00
|
|
|
|
Paragraph[fn:1][fn:2][fn:lbl3:C<<target>>][[test]][[target]]
|
|
|
|
|
\[fn:1] A
|
|
|
|
|
|
|
|
|
|
\[fn:2] <<test>>B"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'link
|
2013-02-15 12:08:03 -05:00
|
|
|
|
(lambda (link)
|
|
|
|
|
(org-export-get-ordinal
|
|
|
|
|
(org-export-resolve-fuzzy-link link info) info)) info))))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Link to a named element should return sequence number of that
|
|
|
|
|
;; element.
|
2016-03-06 16:42:26 -05:00
|
|
|
|
(should
|
|
|
|
|
(= 2
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+NAME: tbl1\n|1|2|\n#+NAME: tbl2\n|3|4|\n#+NAME: tbl3\n|5|6|\n[[tbl2]]"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'link
|
2013-02-15 12:08:03 -05:00
|
|
|
|
(lambda (link)
|
|
|
|
|
(org-export-get-ordinal
|
|
|
|
|
(org-export-resolve-fuzzy-link link info) info)) info t))))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Link to a target not within an item, a table, a footnote
|
|
|
|
|
;; reference or definition should return section number.
|
2016-03-06 16:42:26 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal '(2)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* Head1\n* Head2\nParagraph<<target>>\n* Head3\n[[target]]"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'link
|
2013-02-15 12:08:03 -05:00
|
|
|
|
(lambda (link)
|
|
|
|
|
(org-export-get-ordinal
|
|
|
|
|
(org-export-resolve-fuzzy-link link info) info)) info t))))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Space are not significant when matching a fuzzy link.
|
2013-02-15 12:08:03 -05:00
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Head 1\n[[Head\n 1]]"
|
2013-02-16 09:05:45 -05:00
|
|
|
|
(org-element-map tree 'link
|
|
|
|
|
(lambda (link) (org-export-resolve-fuzzy-link link info))
|
|
|
|
|
info t)))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Statistics cookies are ignored for headline match.
|
2013-02-16 09:05:45 -05:00
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Head [0/0]\n[[Head]]"
|
|
|
|
|
(org-element-map tree 'link
|
|
|
|
|
(lambda (link) (org-export-resolve-fuzzy-link link info))
|
|
|
|
|
info t)))
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Head [100%]\n[[Head]]"
|
2023-10-14 04:45:57 -04:00
|
|
|
|
(org-element-map tree 'link
|
|
|
|
|
(lambda (link) (org-export-resolve-fuzzy-link link info))
|
|
|
|
|
info t)))
|
|
|
|
|
;; Case is not significant when matching headings and radio targets.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Head line\n[[head line]]"
|
2013-02-15 12:08:03 -05:00
|
|
|
|
(org-element-map tree 'link
|
|
|
|
|
(lambda (link) (org-export-resolve-fuzzy-link link info))
|
2015-06-16 17:05:29 -04:00
|
|
|
|
info t))))
|
2012-06-06 18:06:19 -04:00
|
|
|
|
|
2019-05-15 14:22:05 -04:00
|
|
|
|
(ert-deftest test-org-export/resolve-link ()
|
|
|
|
|
"Test `org-export-resolve-link' specifications."
|
|
|
|
|
(should
|
|
|
|
|
;; Match ID links
|
|
|
|
|
(equal
|
|
|
|
|
"Headline1"
|
|
|
|
|
(org-test-with-parsed-data "* Headline1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:ID: aaaa
|
|
|
|
|
:END:
|
|
|
|
|
* Headline2"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:raw-value (org-export-resolve-link "#aaaa" info)))))
|
|
|
|
|
;; Match Custom ID links
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"Headline1"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* Headline1
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:CUSTOM_ID: test
|
|
|
|
|
:END:
|
|
|
|
|
* Headline2"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:raw-value (org-export-resolve-link "#test" info)))))
|
|
|
|
|
;; Match fuzzy links
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"B"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* A\n* B\n* C"
|
|
|
|
|
(org-element-property
|
|
|
|
|
:raw-value (org-export-resolve-link "B" info))))))
|
|
|
|
|
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(defun test-org-gen-loc-list(text type)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(org-test-with-parsed-data text
|
|
|
|
|
(org-element-map tree type
|
|
|
|
|
(lambda (el) (or (org-export-get-loc el info) 'no-loc)))))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-loc ()
|
|
|
|
|
"Test `org-export-get-loc' specifications."
|
|
|
|
|
(should
|
|
|
|
|
;; "-n" resets line number.
|
|
|
|
|
(equal '(0)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list "#+BEGIN_EXAMPLE -n\n Text\n#+END_EXAMPLE"
|
|
|
|
|
'example-block)))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
;; The first "+n" has 0 lines before it
|
|
|
|
|
(should
|
|
|
|
|
(equal '(0)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list "#+BEGIN_EXAMPLE +n\n Text\n#+END_EXAMPLE"
|
|
|
|
|
'example-block)))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
;; "-n 10" resets line number but has "9 lines" before it.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(9)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list "#+BEGIN_EXAMPLE -n 10\n Text\n#+END_EXAMPLE"
|
|
|
|
|
'example-block)))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
;; -n10 with two lines then +n 15
|
|
|
|
|
(should
|
|
|
|
|
(equal '(9 25)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list "
|
|
|
|
|
#+BEGIN_EXAMPLE -n 10
|
|
|
|
|
Text_10
|
|
|
|
|
Second line(11)
|
|
|
|
|
#+END_EXAMPLE
|
|
|
|
|
#+BEGIN_EXAMPLE +n 15
|
|
|
|
|
Text line (11 + 15)
|
|
|
|
|
#+END_EXAMPLE"
|
|
|
|
|
'example-block)))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(9 19 0)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list "
|
|
|
|
|
#+BEGIN_EXAMPLE -n 10
|
|
|
|
|
Text
|
|
|
|
|
#+END_EXAMPLE
|
|
|
|
|
#+BEGIN_EXAMPLE +n 10
|
|
|
|
|
Text
|
|
|
|
|
#+END_EXAMPLE
|
|
|
|
|
|
|
|
|
|
#+BEGIN_EXAMPLE -n
|
|
|
|
|
Text
|
|
|
|
|
#+END_EXAMPLE"
|
|
|
|
|
'example-block)))
|
|
|
|
|
;; an Example Block without -n does not add to the line count.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(9 no-loc 19)
|
|
|
|
|
(test-org-gen-loc-list "
|
|
|
|
|
#+BEGIN_EXAMPLE -n 10
|
|
|
|
|
Text
|
|
|
|
|
#+END_EXAMPLE
|
|
|
|
|
#+BEGIN_EXAMPLE
|
|
|
|
|
Text
|
|
|
|
|
#+END_EXAMPLE
|
|
|
|
|
#+BEGIN_EXAMPLE +n 10
|
|
|
|
|
Text
|
|
|
|
|
#+END_EXAMPLE"
|
|
|
|
|
'example-block)))
|
|
|
|
|
;; "-n" resets line number.
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(equal
|
|
|
|
|
'(0)
|
|
|
|
|
(test-org-gen-loc-list "#+BEGIN_SRC emacs-lisp -n \n (- 1 1) \n#+END_SRC"
|
|
|
|
|
'src-block)))
|
|
|
|
|
;; The first "+n" has 0 lines before it.
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(0)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp +n \n (+ 0 (- 1 1))\n#+END_SRC"
|
|
|
|
|
'src-block)))
|
|
|
|
|
;; "-n 10" resets line number but has "9 lines" before it.
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(9)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n 10\n (- 10 1)\n#+END_SRC"
|
|
|
|
|
'src-block)))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(9 25)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list "
|
|
|
|
|
#+BEGIN_SRC emacs-lisp -n 10
|
|
|
|
|
(- 10 1)
|
|
|
|
|
(+ (- 10 1) 1)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
#+BEGIN_SRC emacs-lisp +n 15
|
|
|
|
|
(+ (- 10 1) 2 (- 15 1))
|
|
|
|
|
#+END_SRC"
|
|
|
|
|
'src-block)))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(9 19 0)
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(test-org-gen-loc-list "
|
|
|
|
|
#+BEGIN_SRC emacs-lisp -n 10
|
|
|
|
|
(- 10 1)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
#+BEGIN_SRC emacs-lisp +n 10
|
|
|
|
|
(+ (- 10 1) 1 (- 10 1))
|
|
|
|
|
#+END_SRC
|
|
|
|
|
#+BEGIN_SRC emacs-lisp -n
|
|
|
|
|
(- 1 1)
|
|
|
|
|
#+END_SRC"
|
|
|
|
|
'src-block)))
|
|
|
|
|
;; A SRC Block without -n does not add to the line count.
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
2016-05-24 15:40:43 -04:00
|
|
|
|
(equal '(9 no-loc 19)
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(test-org-gen-loc-list
|
2016-05-24 15:40:43 -04:00
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n 10
|
|
|
|
|
(+ (-10 1) 1)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
(+ 2 2)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
#+BEGIN_SRC emacs-lisp +n 10
|
|
|
|
|
(+ (- 10 1) 1 (- 10 1))
|
|
|
|
|
#+END_SRC"
|
|
|
|
|
'src-block))))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
|
2012-06-06 17:39:04 -04:00
|
|
|
|
(ert-deftest test-org-export/resolve-coderef ()
|
|
|
|
|
"Test `org-export-resolve-coderef' specifications."
|
|
|
|
|
(let ((org-coderef-label-format "(ref:%s)"))
|
2015-03-17 17:28:39 -04:00
|
|
|
|
;; A link to a "-n -k -r" block returns line number.
|
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -n -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 10
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -n 10 -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
(should
|
|
|
|
|
(= 135
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -n 10 -k -r\nText \n#+END_EXAMPLE\n
|
|
|
|
|
#+BEGIN_EXAMPLE +n 125 -k -r\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2015-03-17 17:28:39 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 10
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n 10 -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
(should
|
|
|
|
|
(= 135
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n 10 -k -r\n(+ 1 1) \n#+END_SRC\n
|
|
|
|
|
#+BEGIN_SRC emacs-lisp +n 125 -k -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2015-03-17 17:28:39 -04:00
|
|
|
|
;; A link to a "-n -r" block returns line number.
|
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -n -r\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 10
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -n 10 -r\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
(should
|
|
|
|
|
(= 135
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE +n 10 -r\nText \n#+END_EXAMPLE
|
|
|
|
|
#+BEGIN_EXAMPLE +n 125 -r\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
|
2015-03-17 17:28:39 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(should
|
|
|
|
|
(= 10
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n10 -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
(should
|
|
|
|
|
(= 135
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n10 -r\n(+ 1 1) \n#+END_SRC
|
|
|
|
|
#+BEGIN_SRC emacs-lisp +n125 -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2015-03-17 17:28:39 -04:00
|
|
|
|
;; A link to a "-n" block returns coderef.
|
|
|
|
|
(should
|
|
|
|
|
(equal "coderef"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -n\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "coderef"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -n\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
;; A link to a "-r" block returns line number.
|
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp -r\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
(should
|
|
|
|
|
(= 1
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -r\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
|
|
|
|
;; A link to a block without a switch returns coderef.
|
|
|
|
|
(should
|
|
|
|
|
(equal "coderef"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp\n(+ 1 1) (ref:coderef)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "coderef" info))))
|
2012-06-06 17:39:04 -04:00
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE\nText (ref:coderef)\n#+END_EXAMPLE"
|
|
|
|
|
(should (equal (org-export-resolve-coderef "coderef" info) "coderef")))
|
2015-03-17 17:28:39 -04:00
|
|
|
|
;; Correctly handle continued line numbers. A "+n" switch should
|
|
|
|
|
;; resume numbering from previous block with numbered lines,
|
|
|
|
|
;; ignoring blocks not numbering lines in the process. A "-n"
|
|
|
|
|
;; switch resets count.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(2 1)
|
|
|
|
|
(org-test-with-parsed-data "
|
2012-06-06 17:39:04 -04:00
|
|
|
|
#+BEGIN_EXAMPLE -n
|
|
|
|
|
Text.
|
|
|
|
|
#+END_EXAMPLE
|
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
\(- 1 1)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp +n -r
|
|
|
|
|
\(+ 1 1) (ref:addition)
|
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
|
|
#+BEGIN_EXAMPLE -n -r
|
|
|
|
|
Another text. (ref:text)
|
|
|
|
|
#+END_EXAMPLE"
|
2015-03-17 17:28:39 -04:00
|
|
|
|
(list (org-export-resolve-coderef "addition" info)
|
|
|
|
|
(org-export-resolve-coderef "text" info)))))
|
|
|
|
|
;; Recognize coderef with user-specified syntax.
|
|
|
|
|
(should
|
2015-10-10 10:03:05 -04:00
|
|
|
|
(equal
|
|
|
|
|
"text"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText. [ref:text]\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-resolve-coderef "text" info))))
|
|
|
|
|
;; Unresolved coderefs raise a `org-link-broken' signal.
|
|
|
|
|
(should
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(org-test-with-parsed-data "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
|
|
|
|
|
(org-export-resolve-coderef "unknown" info))
|
|
|
|
|
(org-link-broken t)))))
|
2012-06-06 17:39:04 -04:00
|
|
|
|
|
2012-07-04 11:37:55 -04:00
|
|
|
|
(ert-deftest test-org-export/resolve-fuzzy-link ()
|
2012-06-06 17:39:04 -04:00
|
|
|
|
"Test `org-export-resolve-fuzzy-link' specifications."
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Match target objects.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "<<target>> [[target]]"
|
2012-06-06 18:06:19 -04:00
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Match named elements.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "#+NAME: target\nParagraph\n\n[[target]]"
|
2012-06-06 18:06:19 -04:00
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Match exact headline's name.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* My headline\n[[My headline]]"
|
2012-06-06 18:06:19 -04:00
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))
|
2016-03-06 16:42:26 -05:00
|
|
|
|
;; Targets objects have priority over headline titles.
|
2013-04-04 13:23:07 -04:00
|
|
|
|
(should
|
|
|
|
|
(eq 'target
|
2016-03-06 16:42:26 -05:00
|
|
|
|
(org-test-with-parsed-data "* target\n<<target>>[[target]]"
|
2012-06-06 18:06:19 -04:00
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; Named elements have priority over headline titles.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'paragraph
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* target\n#+NAME: target\nParagraph\n\n[[target]]"
|
2012-06-06 18:06:19 -04:00
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))))
|
2013-04-04 13:23:07 -04:00
|
|
|
|
;; If link's path starts with a "*", only match headline titles,
|
|
|
|
|
;; though.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'headline
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* target\n#+NAME: target\n<<target>>\n\n[[*target]]"
|
2012-06-06 18:06:19 -04:00
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))))
|
2015-10-10 10:03:05 -04:00
|
|
|
|
;; Raise a `org-link-broken' signal if no match.
|
|
|
|
|
(should
|
2013-04-04 13:23:07 -04:00
|
|
|
|
(org-test-with-parsed-data "[[target]]"
|
2015-10-10 10:03:05 -04:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link #'identity info t) info)
|
|
|
|
|
(org-link-broken t))))
|
2013-06-18 16:27:39 -04:00
|
|
|
|
;; Match fuzzy link even when before first headline.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'headline
|
|
|
|
|
(org-test-with-parsed-data "[[hl]]\n* hl"
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-resolve-fuzzy-link
|
2015-06-16 16:11:16 -04:00
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))))
|
2019-03-09 04:58:41 -05:00
|
|
|
|
;; Handle escaped fuzzy links.
|
2015-06-16 16:11:16 -04:00
|
|
|
|
(should
|
2019-12-22 08:52:53 -05:00
|
|
|
|
(org-test-with-parsed-data "* [foo]\n[[\\[foo\\]]]"
|
2015-06-16 16:11:16 -04:00
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(org-element-map tree 'link #'identity info t) info))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
|
2012-06-06 17:39:04 -04:00
|
|
|
|
(ert-deftest test-org-export/resolve-id-link ()
|
|
|
|
|
"Test `org-export-resolve-id-link' specifications."
|
2015-03-17 18:24:03 -04:00
|
|
|
|
;; Regular test for custom-id link.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("Headline1")
|
|
|
|
|
(org-test-with-parsed-data "* Headline1
|
2012-06-06 17:39:04 -04:00
|
|
|
|
:PROPERTIES:
|
export-back-ends: Apply changes from b692064e621acbc93876670585f8a4b0fd6a7ffa
* lisp/ox-beamer.el (org-beamer--get-label, org-beamer--frame-level,
org-beamer--format-section, org-beamer--format-frame,
org-beamer--format-block, org-beamer-headline): Apply changes to
properties.
* lisp/ox-html.el (org-html-headline, org-html-link,
org-html-section): Apply changes to properties.
* lisp/ox-icalendar.el (org-icalendar-create-uid,
org-icalendar-blocked-headline-p, org-icalendar-entry,
org-icalendar--valarm): Apply changes to properties.
* lisp/ox-odt.el (org-odt-headline): Apply changes
* lisp/ox-publish.el (org-publish-collect-index): Apply changes to
properties.
* lisp/ox-texinfo.el (org-texinfo--generate-menu-list,
org-texinfo--generate-menu-items, org-texinfo-template,
org-texinfo-headline, org-texinfo-link): Apply changes to
properties.
* lisp/ox.el (org-export-resolve-id-link, org-export-get-category):
Apply changes to properties.
(org-export-get-node-property): Update docstring.
* testing/lisp/test-ox.el: Update tests.
2013-02-17 18:01:21 -05:00
|
|
|
|
:CUSTOM_ID: test
|
2012-06-06 17:39:04 -04:00
|
|
|
|
:END:
|
|
|
|
|
* Headline 2
|
|
|
|
|
\[[#test]]"
|
2015-03-17 18:24:03 -04:00
|
|
|
|
(org-element-property
|
|
|
|
|
:title
|
|
|
|
|
(org-export-resolve-id-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))))
|
2015-10-10 10:03:05 -04:00
|
|
|
|
;; Raise a `org-link-broken' signal on failing searches.
|
|
|
|
|
(should
|
2015-03-17 18:24:03 -04:00
|
|
|
|
(org-test-with-parsed-data "* Headline1
|
2012-06-06 17:39:04 -04:00
|
|
|
|
:PROPERTIES:
|
export-back-ends: Apply changes from b692064e621acbc93876670585f8a4b0fd6a7ffa
* lisp/ox-beamer.el (org-beamer--get-label, org-beamer--frame-level,
org-beamer--format-section, org-beamer--format-frame,
org-beamer--format-block, org-beamer-headline): Apply changes to
properties.
* lisp/ox-html.el (org-html-headline, org-html-link,
org-html-section): Apply changes to properties.
* lisp/ox-icalendar.el (org-icalendar-create-uid,
org-icalendar-blocked-headline-p, org-icalendar-entry,
org-icalendar--valarm): Apply changes to properties.
* lisp/ox-odt.el (org-odt-headline): Apply changes
* lisp/ox-publish.el (org-publish-collect-index): Apply changes to
properties.
* lisp/ox-texinfo.el (org-texinfo--generate-menu-list,
org-texinfo--generate-menu-items, org-texinfo-template,
org-texinfo-headline, org-texinfo-link): Apply changes to
properties.
* lisp/ox.el (org-export-resolve-id-link, org-export-get-category):
Apply changes to properties.
(org-export-get-node-property): Update docstring.
* testing/lisp/test-ox.el: Update tests.
2013-02-17 18:01:21 -05:00
|
|
|
|
:CUSTOM_ID: test
|
2012-06-06 17:39:04 -04:00
|
|
|
|
:END:
|
|
|
|
|
* Headline 2
|
|
|
|
|
\[[#no-match]]"
|
2015-10-10 10:03:05 -04:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(org-export-resolve-id-link
|
|
|
|
|
(org-element-map tree 'link #'identity info t) info)
|
|
|
|
|
(org-link-broken t))))
|
2015-03-17 18:24:03 -04:00
|
|
|
|
;; Test for internal id target.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("Headline1")
|
|
|
|
|
(org-test-with-parsed-data "* Headline1
|
2012-06-06 17:39:04 -04:00
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:ID: aaaa
|
|
|
|
|
:END:
|
|
|
|
|
* Headline 2
|
|
|
|
|
\[[id:aaaa]]"
|
2015-03-17 18:24:03 -04:00
|
|
|
|
(org-element-property
|
|
|
|
|
:title
|
|
|
|
|
(org-export-resolve-id-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t) info)))))
|
|
|
|
|
;; Test for external id target.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
"external-file"
|
|
|
|
|
(org-test-with-parsed-data "[[id:aaaa]]"
|
|
|
|
|
(org-export-resolve-id-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t)
|
|
|
|
|
(org-combine-plists info '(:id-alist (("aaaa" . "external-file")))))))))
|
2012-03-10 05:37:13 -05:00
|
|
|
|
|
2012-05-18 05:20:00 -04:00
|
|
|
|
(ert-deftest test-org-export/resolve-radio-link ()
|
|
|
|
|
"Test `org-export-resolve-radio-link' specifications."
|
|
|
|
|
;; Standard test.
|
2013-02-15 16:38:29 -05:00
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "<<<radio>>> radio"
|
|
|
|
|
(org-update-radio-target-regexp)
|
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
|
|
|
|
(info `(:parse-tree ,tree)))
|
|
|
|
|
(org-export-resolve-radio-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t)
|
|
|
|
|
info))))
|
|
|
|
|
;; Radio targets are case-insensitive.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "<<<RADIO>>> radio"
|
|
|
|
|
(org-update-radio-target-regexp)
|
2012-05-18 05:20:00 -04:00
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
|
|
|
|
(info `(:parse-tree ,tree)))
|
|
|
|
|
(org-export-resolve-radio-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t)
|
|
|
|
|
info))))
|
|
|
|
|
;; Radio target with objects.
|
2013-02-15 16:38:29 -05:00
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "<<<radio \\alpha>>> radio \\alpha"
|
|
|
|
|
(org-update-radio-target-regexp)
|
2012-05-18 05:20:00 -04:00
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
|
|
|
|
(info `(:parse-tree ,tree)))
|
|
|
|
|
(org-export-resolve-radio-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t)
|
2013-05-12 11:49:51 -04:00
|
|
|
|
info))))
|
2014-03-23 06:28:26 -04:00
|
|
|
|
;; Radio target with objects at its beginning.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "<<<\\alpha radio>>> \\alpha radio"
|
|
|
|
|
(org-update-radio-target-regexp)
|
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
|
|
|
|
(info `(:parse-tree ,tree)))
|
|
|
|
|
(org-export-resolve-radio-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t)
|
|
|
|
|
info))))
|
2014-03-25 05:15:25 -04:00
|
|
|
|
;; Radio link next to an apostrophe.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "<<<radio>>> radio's"
|
|
|
|
|
(org-update-radio-target-regexp)
|
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
|
|
|
|
(info `(:parse-tree ,tree)))
|
|
|
|
|
(org-export-resolve-radio-link
|
|
|
|
|
(org-element-map tree 'link 'identity info t)
|
|
|
|
|
info))))
|
2013-05-12 11:49:51 -04:00
|
|
|
|
;; Multiple radio targets.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("radio1" "radio2")
|
|
|
|
|
(org-test-with-temp-text "<<<radio1>>> <<<radio2>>> radio1 radio2"
|
|
|
|
|
(org-update-radio-target-regexp)
|
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
|
|
|
|
(info `(:parse-tree ,tree)))
|
|
|
|
|
(org-element-map tree 'link
|
|
|
|
|
(lambda (link)
|
|
|
|
|
(org-element-property
|
|
|
|
|
:value (org-export-resolve-radio-link link info)))
|
2013-05-12 14:42:30 -04:00
|
|
|
|
info)))))
|
|
|
|
|
;; Radio target is whitespace insensitive.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-temp-text "<<<a radio>>> a\n radio"
|
|
|
|
|
(org-update-radio-target-regexp)
|
|
|
|
|
(let* ((tree (org-element-parse-buffer))
|
|
|
|
|
(info `(:parse-tree ,tree)))
|
|
|
|
|
(org-element-map tree 'link
|
|
|
|
|
(lambda (link) (org-export-resolve-radio-link link info)) info t)))))
|
2012-05-18 05:20:00 -04:00
|
|
|
|
|
2015-04-20 06:36:47 -04:00
|
|
|
|
(ert-deftest test-org-export/file-uri ()
|
|
|
|
|
"Test `org-export-file-uri' specifications."
|
|
|
|
|
;; Preserve relative filenames.
|
|
|
|
|
(should (equal "relative.org" (org-export-file-uri "relative.org")))
|
2017-02-13 11:14:38 -05:00
|
|
|
|
;; Local files start with "file://"
|
2017-02-16 16:42:59 -05:00
|
|
|
|
(should (equal (concat (if (memq system-type '(windows-nt cygwin)) "file:///" "file://") (expand-file-name "/local.org"))
|
2017-02-13 11:14:38 -05:00
|
|
|
|
(org-export-file-uri "/local.org")))
|
2015-04-20 06:36:47 -04:00
|
|
|
|
;; Remote files start with "file://"
|
2017-06-09 15:28:49 -04:00
|
|
|
|
(should (equal "file://ssh:myself@some.where:papers/last.pdf"
|
|
|
|
|
(org-export-file-uri "/ssh:myself@some.where:papers/last.pdf")))
|
2015-09-25 18:04:05 -04:00
|
|
|
|
(should (equal "file://localhost/etc/fstab"
|
|
|
|
|
(org-export-file-uri "//localhost/etc/fstab")))
|
2015-04-20 06:36:47 -04:00
|
|
|
|
;; Expand filename starting with "~".
|
|
|
|
|
(should (equal (org-export-file-uri "~/file.org")
|
2017-02-16 16:42:59 -05:00
|
|
|
|
(concat (if (memq system-type '(windows-nt cygwin)) "file:///" "file://") (expand-file-name "~/file.org")))))
|
2015-04-20 06:36:47 -04:00
|
|
|
|
|
2016-03-07 17:43:23 -05:00
|
|
|
|
(ert-deftest test-org-export/get-reference ()
|
|
|
|
|
"Test `org-export-get-reference' specifications."
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
|
|
|
|
(org-export-get-reference (org-element-map tree 'headline #'identity nil t)
|
|
|
|
|
info)))
|
|
|
|
|
;; For a given element always return the same reference.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
|
|
|
|
(let ((headline (org-element-map tree 'headline #'identity nil t)))
|
|
|
|
|
(equal (org-export-get-reference headline info)
|
|
|
|
|
(org-export-get-reference headline info)))))
|
2023-04-20 08:11:19 -04:00
|
|
|
|
;; References get through local export backends.
|
2016-12-13 16:11:41 -05:00
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
|
|
|
|
(let ((headline (org-element-map tree 'headline #'identity nil t))
|
|
|
|
|
(backend
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-get-reference h i)))))))
|
|
|
|
|
(equal (org-trim (org-export-data-with-backend headline backend info))
|
|
|
|
|
(org-export-get-reference headline info)))))
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
|
|
|
|
(let ((headline (org-element-map tree 'headline #'identity nil t))
|
|
|
|
|
(backend
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-get-reference h i)))))))
|
|
|
|
|
(equal (org-export-with-backend backend headline nil info)
|
|
|
|
|
(org-export-get-reference headline info)))))
|
2016-11-11 11:47:09 -05:00
|
|
|
|
;; Use search cells defined in `:crossrefs'. However, handle
|
|
|
|
|
;; duplicate search cells.
|
2016-03-07 17:43:23 -05:00
|
|
|
|
(should
|
2016-04-28 10:55:24 -04:00
|
|
|
|
(equal "org0000001"
|
2016-03-07 17:43:23 -05:00
|
|
|
|
(org-test-with-parsed-data "* Headline"
|
|
|
|
|
(let* ((headline (org-element-map tree 'headline #'identity nil t))
|
|
|
|
|
(search-cell (car (org-export-search-cells headline))))
|
|
|
|
|
(setq info
|
|
|
|
|
(plist-put info :crossrefs (list (cons search-cell 1))))
|
2016-11-11 11:47:09 -05:00
|
|
|
|
(org-export-get-reference headline info)))))
|
|
|
|
|
(should-not
|
|
|
|
|
(equal '("org0000001" "org0000001")
|
|
|
|
|
(org-test-with-parsed-data "* H\n** H"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h)
|
|
|
|
|
(let* ((search-cell (car (org-export-search-cells h)))
|
|
|
|
|
(info (plist-put info :crossrefs
|
|
|
|
|
(list (cons search-cell 1)))))
|
|
|
|
|
(org-export-get-reference h info))))))))
|
2016-03-07 17:43:23 -05:00
|
|
|
|
|
2016-10-24 17:32:15 -04:00
|
|
|
|
|
|
|
|
|
;;; Pseudo objects and pseudo elements
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/pseudo-elements ()
|
|
|
|
|
"Test exporting pseudo-elements."
|
|
|
|
|
;; Handle blank lines after pseudo-elements. In particular, do not
|
|
|
|
|
;; replace them with white spaces.
|
|
|
|
|
(should
|
|
|
|
|
(equal "contents\n\nparagraph\n"
|
|
|
|
|
(let ((backend (org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((pseudo-element . (lambda (_p c _i) c))
|
|
|
|
|
(paragraph . (lambda (_p c _i) c))
|
|
|
|
|
(plain-text . (lambda (c _i) c)))))
|
|
|
|
|
(element '(pseudo-element (:post-blank 1) "contents"))
|
|
|
|
|
(paragraph '(paragraph nil "paragraph"))
|
|
|
|
|
(data '(org-data nil)))
|
2023-05-16 06:41:53 -04:00
|
|
|
|
(org-element-adopt data element paragraph)
|
2016-10-24 17:32:15 -04:00
|
|
|
|
(org-export-data-with-backend data backend nil)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/pseudo-objects ()
|
|
|
|
|
"Test exporting pseudo-objects."
|
|
|
|
|
;; Handle blank spaces after pseudo-objects. In particular, do not
|
|
|
|
|
;; replace them with newlines.
|
|
|
|
|
(should
|
|
|
|
|
(equal "begin x end\n"
|
|
|
|
|
(let ((backend (org-export-create-backend
|
|
|
|
|
:transcoders
|
|
|
|
|
'((pseudo-object . (lambda (_p c _i) c))
|
|
|
|
|
(paragraph . (lambda (_p c _i) c))
|
|
|
|
|
(plain-text . (lambda (c _i) c)))))
|
|
|
|
|
(object '(pseudo-object (:post-blank 1) "x"))
|
|
|
|
|
(paragraph '(paragraph nil)))
|
2023-05-16 06:41:53 -04:00
|
|
|
|
(org-element-adopt paragraph "begin " object "end")
|
2016-10-24 17:32:15 -04:00
|
|
|
|
(org-export-data-with-backend paragraph backend nil)))))
|
2014-07-26 11:18:10 -04:00
|
|
|
|
|
2021-04-18 13:32:27 -04:00
|
|
|
|
|
|
|
|
|
;;; Raw objects
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/raw-strings ()
|
|
|
|
|
"Test exporting raw objects."
|
|
|
|
|
(should
|
|
|
|
|
(equal "foo"
|
|
|
|
|
(let ((backend (org-export-create-backend))
|
|
|
|
|
(object (org-export-raw-string "foo")))
|
|
|
|
|
(org-export-data-with-backend object backend nil)))))
|
|
|
|
|
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
|
|
|
|
;;; Src-block and example-block
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/unravel-code ()
|
|
|
|
|
"Test `org-export-unravel-code' function."
|
2013-05-25 08:18:48 -04:00
|
|
|
|
;; Code without reference.
|
|
|
|
|
(should
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(equal '("(+ 1 1)")
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
|
|
|
|
|
(org-export-unravel-code (org-element-at-point)))))
|
|
|
|
|
;; Code with reference.
|
|
|
|
|
(should
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(equal '("(+ 1 1)" (1 . "test"))
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
|
|
|
|
|
(let ((org-coderef-label-format "(ref:%s)"))
|
|
|
|
|
(org-export-unravel-code (org-element-at-point))))))
|
|
|
|
|
;; Code with user-defined reference.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2017-04-29 08:32:29 -04:00
|
|
|
|
'("(+ 1 1)" (1 . "test"))
|
2012-03-10 14:25:32 -05:00
|
|
|
|
(org-test-with-temp-text
|
|
|
|
|
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(let ((org-coderef-label-format "(ref:%s)"))
|
|
|
|
|
(org-export-unravel-code (org-element-at-point))))))
|
|
|
|
|
;; Code references keys are relative to the current block.
|
|
|
|
|
(should
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(equal '("(+ 2 2)\n(+ 3 3)" (2 . "one"))
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(org-test-with-temp-text "
|
2012-03-10 14:25:32 -05:00
|
|
|
|
#+BEGIN_EXAMPLE -n
|
|
|
|
|
\(+ 1 1)
|
|
|
|
|
#+END_EXAMPLE
|
|
|
|
|
#+BEGIN_EXAMPLE +n
|
|
|
|
|
\(+ 2 2)
|
|
|
|
|
\(+ 3 3) (ref:one)
|
|
|
|
|
#+END_EXAMPLE"
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(goto-line 5)
|
|
|
|
|
(let ((org-coderef-label-format "(ref:%s)"))
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(org-export-unravel-code (org-element-at-point)))))))
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
2013-03-03 13:10:42 -05:00
|
|
|
|
(ert-deftest test-org-export/format-code-default ()
|
|
|
|
|
"Test `org-export-format-code-default' specifications."
|
2017-04-29 08:32:29 -04:00
|
|
|
|
;; Preserve blank lines, even when code is empty.
|
2013-03-03 13:10:42 -05:00
|
|
|
|
(should
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(equal "\n\n"
|
2013-03-03 13:10:42 -05:00
|
|
|
|
(org-test-with-parsed-data "#+BEGIN_SRC emacs-lisp\n\n\n#+END_SRC"
|
|
|
|
|
(org-export-format-code-default
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(org-element-map tree 'src-block #'identity info t) info))))
|
|
|
|
|
;; Likewise, preserve leading and trailing blank lines in the code.
|
|
|
|
|
(should
|
|
|
|
|
(equal "\n(+ 1 1)\n"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp\n\n(+ 1 1)\n#+END_SRC"
|
|
|
|
|
(org-export-format-code-default
|
|
|
|
|
(org-element-map tree 'src-block #'identity info t) info))))
|
|
|
|
|
(should
|
|
|
|
|
(equal "(+ 1 1)\n\n"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n\n#+END_SRC"
|
|
|
|
|
(org-export-format-code-default
|
|
|
|
|
(org-element-map tree 'src-block #'identity info t) info))))
|
2013-03-03 13:10:42 -05:00
|
|
|
|
;; Number lines, two whitespace characters before the actual loc.
|
|
|
|
|
(should
|
|
|
|
|
(equal "1 a\n2 b\n"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp +n\na\nb\n#+END_SRC"
|
|
|
|
|
(org-export-format-code-default
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(org-element-map tree 'src-block #'identity info t) info))))
|
|
|
|
|
;; Numbering includes blank lines.
|
|
|
|
|
(should
|
|
|
|
|
(equal "1 \n2 a\n3 \n4 b\n5 \n"
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp +n\n\na\n\nb\n\n#+END_SRC"
|
|
|
|
|
(org-export-format-code-default
|
|
|
|
|
(org-element-map tree 'src-block #'identity info t) info))))
|
2013-03-03 13:10:42 -05:00
|
|
|
|
;; Put references 6 whitespace characters after the widest line,
|
|
|
|
|
;; wrapped within parenthesis.
|
|
|
|
|
(should
|
|
|
|
|
(equal "123 (a)\n1 (b)\n"
|
|
|
|
|
(let ((org-coderef-label-format "(ref:%s)"))
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"#+BEGIN_SRC emacs-lisp\n123 (ref:a)\n1 (ref:b)\n#+END_SRC"
|
|
|
|
|
(org-export-format-code-default
|
2017-04-29 08:32:29 -04:00
|
|
|
|
(org-element-map tree 'src-block #'identity info t) info))))))
|
2013-03-03 13:10:42 -05:00
|
|
|
|
|
2021-09-07 08:01:11 -04:00
|
|
|
|
(ert-deftest test-org-export/latex-src-block-verbatim-caption ()
|
|
|
|
|
"Test `org-latex-src-block' caption for verbatim environment.
|
|
|
|
|
Check that percent sign does not become a part of format.
|
|
|
|
|
This test does not cover listings and custom environments."
|
|
|
|
|
(let ((export
|
|
|
|
|
(lambda (buffer-text)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
buffer-text
|
|
|
|
|
(let* ((backend (org-export-get-backend 'latex))
|
|
|
|
|
(info (org-combine-plists
|
|
|
|
|
(org-export--get-export-attributes backend)
|
|
|
|
|
(org-export-get-environment backend)))
|
|
|
|
|
(result (org-latex-src-block
|
|
|
|
|
(org-element-map tree 'src-block #'identity info t)
|
|
|
|
|
t info)))
|
|
|
|
|
;; Remove properties to make failure reports more clear.
|
|
|
|
|
(set-text-properties 0 (length result) nil result)
|
|
|
|
|
result)))))
|
|
|
|
|
|
|
|
|
|
(should (equal
|
|
|
|
|
"\
|
|
|
|
|
\\begin{verbatim}
|
|
|
|
|
\"No float, no listings, 20%S\"
|
|
|
|
|
\\end{verbatim}
|
|
|
|
|
\\captionof{figure}{Caption of verbatim is below, 20\\%s}
|
|
|
|
|
"
|
|
|
|
|
(funcall export
|
|
|
|
|
"\
|
|
|
|
|
#+CAPTION: Caption of verbatim is below, 20%s
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
\"No float, no listings, 20%S\"
|
|
|
|
|
#+END_SRC")))
|
|
|
|
|
|
|
|
|
|
;; `org-latex-caption-above' has no associated property or keyword.
|
|
|
|
|
(should (equal
|
|
|
|
|
"\
|
|
|
|
|
\\captionof{figure}{Caption of verbatim is above, 40\\%s}
|
|
|
|
|
\\begin{verbatim}
|
|
|
|
|
\"No float, no listings, 40%S\"
|
|
|
|
|
\\end{verbatim}"
|
|
|
|
|
(let ((org-latex-caption-above t))
|
|
|
|
|
(funcall export
|
|
|
|
|
"\
|
|
|
|
|
#+CAPTION: Caption of verbatim is above, 40%s
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
\"No float, no listings, 40%S\"
|
|
|
|
|
#+END_SRC"))))
|
|
|
|
|
|
|
|
|
|
(should (equal
|
|
|
|
|
"\
|
|
|
|
|
\\begin{figure*}[tp]
|
|
|
|
|
\\caption{Caption is above, 60\\%s}
|
|
|
|
|
\\begin{verbatim}
|
|
|
|
|
\"Float, no listings, 60%S\"
|
|
|
|
|
\\end{verbatim}
|
|
|
|
|
\\end{figure*}"
|
|
|
|
|
(let ((org-latex-caption-above t)
|
|
|
|
|
(org-latex-default-figure-position "tp"))
|
|
|
|
|
(funcall export
|
|
|
|
|
"\
|
|
|
|
|
#+CAPTION: Caption is above, 60%s
|
|
|
|
|
#+ATTR_LATEX: :float multicolumn
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
\"Float, no listings, 60%S\"
|
|
|
|
|
#+END_SRC"))))
|
|
|
|
|
|
|
|
|
|
(should (equal
|
|
|
|
|
"\
|
|
|
|
|
\\begin{figure*}[tp]
|
|
|
|
|
\\begin{verbatim}
|
|
|
|
|
\"Float, no lang, listings, 80%S\"
|
|
|
|
|
\\end{verbatim}
|
|
|
|
|
\\caption{Caption is below, 60\\%s}
|
|
|
|
|
\\end{figure*}"
|
ox-latex: Replace `org-latex-listings'
* lisp/ox-latex.el (org-latex-src-block, org-latex-keyword,
org-latex-inline-src-block, org-latex-template,
org-latex--caption/label-string, org-latex-engraved-preamble,
org-latex-listings): Replace `org-latex-listings' with
`org-latex-src-block-backend', which now can be set to listings/verbatim
and no longer advertises t/nil as valid values.
* lisp/ox-beamer.el (org-beamer-template): Update in the same manner as
`org-latex-template'.
* lisp/org-compat.el: Make `org-latex-listings' an obsolete alias for
`org-latex-src-block-backend'.
* testing/lisp/test-ox.el: Replace `org-latex-listings' reference with
`org-latex-src-block-backend'.
* doc/org-manual.org (Footnotes, LaTeX specific properties, Literal
Examples): Replace references to `org-latex-listings' with
`org-latex-src-block-backend'.
* etc/ORG-NEWS: Add a news entry noting this change.
The variable `org-latex-listings' originally indicated whether source
blocks should use the listings LaTeX package, or not. This usage has
evolved over the years, and now it sets one of four different
fontification backends. This renaming should make the variable name a
bit less misleading.
2022-05-07 02:46:28 -04:00
|
|
|
|
(let ((org-latex-src-block-backend 'minted) ; inactive due to missing lang
|
2021-09-07 08:01:11 -04:00
|
|
|
|
(org-latex-default-figure-position "tp"))
|
|
|
|
|
;; Namely "multicolumn" value to get just figure environment
|
|
|
|
|
;; looks like a bug.
|
|
|
|
|
(funcall export
|
|
|
|
|
"\
|
|
|
|
|
#+CAPTION: Caption is below, 60%s
|
|
|
|
|
#+ATTR_LATEX: :float multicolumn
|
|
|
|
|
#+BEGIN_SRC
|
|
|
|
|
\"Float, no lang, listings, 80%S\"
|
|
|
|
|
#+END_SRC"))))
|
|
|
|
|
|
|
|
|
|
(should (equal
|
|
|
|
|
"\
|
|
|
|
|
\\begin{verbatim}
|
|
|
|
|
\"No caption, no float, no listings, 100%S\"
|
|
|
|
|
\\end{verbatim}"
|
|
|
|
|
(funcall export
|
|
|
|
|
"\
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
|
\"No caption, no float, no listings, 100%S\"
|
|
|
|
|
#+END_SRC")))))
|
|
|
|
|
|
2012-03-10 14:25:32 -05:00
|
|
|
|
|
2012-10-25 17:54:53 -04:00
|
|
|
|
|
|
|
|
|
;;; Smart Quotes
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/activate-smart-quotes ()
|
|
|
|
|
"Test `org-export-activate-smart-quotes' specifications."
|
2015-03-28 10:08:44 -04:00
|
|
|
|
;; Double quotes: standard test.
|
2012-10-25 17:54:53 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-03-28 10:08:44 -04:00
|
|
|
|
'("some “quoted” text")
|
2012-10-25 17:54:53 -04:00
|
|
|
|
(let ((org-export-default-language "en"))
|
2015-03-28 10:08:44 -04:00
|
|
|
|
(org-test-with-parsed-data "some \"quoted\" text"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2012-10-25 17:54:53 -04:00
|
|
|
|
;; Opening quotes: at the beginning of a paragraph.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2024-03-23 07:34:06 -04:00
|
|
|
|
'("“begin”")
|
2012-10-25 17:54:53 -04:00
|
|
|
|
(let ((org-export-default-language "en"))
|
2024-03-23 07:34:06 -04:00
|
|
|
|
(org-test-with-parsed-data "\"begin\""
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2012-10-25 17:54:53 -04:00
|
|
|
|
;; Opening quotes: after an object.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-03-28 10:08:44 -04:00
|
|
|
|
'("“quoted” text")
|
2012-10-25 17:54:53 -04:00
|
|
|
|
(let ((org-export-default-language "en"))
|
2015-03-28 10:08:44 -04:00
|
|
|
|
(org-test-with-parsed-data "=verb= \"quoted\" text"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2012-10-25 17:54:53 -04:00
|
|
|
|
;; Closing quotes: at the end of a paragraph.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-03-28 10:08:44 -04:00
|
|
|
|
'("Quoted “text”")
|
2012-10-25 17:54:53 -04:00
|
|
|
|
(let ((org-export-default-language "en"))
|
2015-03-28 10:08:44 -04:00
|
|
|
|
(org-test-with-parsed-data "Quoted \"text\""
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2015-03-28 10:08:44 -04:00
|
|
|
|
;; Inner quotes: standard test.
|
|
|
|
|
(should
|
2023-08-05 09:16:31 -04:00
|
|
|
|
(equal '("« outer “inner” outer »")
|
2015-03-28 10:08:44 -04:00
|
|
|
|
(let ((org-export-default-language "fr"))
|
|
|
|
|
(org-test-with-parsed-data "\"outer 'inner' outer\""
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :utf-8 info))
|
2015-09-02 15:02:41 -04:00
|
|
|
|
info)))))
|
|
|
|
|
;; Inner quotes: close to special symbols.
|
|
|
|
|
(should
|
2023-08-05 09:16:31 -04:00
|
|
|
|
(equal '("« outer (“inner”) outer »")
|
2015-09-02 15:02:41 -04:00
|
|
|
|
(let ((org-export-default-language "fr"))
|
|
|
|
|
(org-test-with-parsed-data "\"outer ('inner') outer\""
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :utf-8 info))
|
|
|
|
|
info)))))
|
|
|
|
|
(should
|
2023-08-05 09:16:31 -04:00
|
|
|
|
(equal '("« “inner” »")
|
2015-09-02 15:02:41 -04:00
|
|
|
|
(let ((org-export-default-language "fr"))
|
|
|
|
|
(org-test-with-parsed-data "\"'inner'\""
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :utf-8 info))
|
2015-03-28 10:08:44 -04:00
|
|
|
|
info)))))
|
2012-10-25 17:54:53 -04:00
|
|
|
|
;; Apostrophe: standard test.
|
|
|
|
|
(should
|
2015-03-28 10:08:44 -04:00
|
|
|
|
(equal '("It « shouldn’t » fail")
|
|
|
|
|
(let ((org-export-default-language "fr"))
|
|
|
|
|
(org-test-with-parsed-data "It \"shouldn't\" fail"
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :utf-8 info))
|
|
|
|
|
info)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '("It shouldn’t fail")
|
|
|
|
|
(let ((org-export-default-language "fr"))
|
|
|
|
|
(org-test-with-parsed-data "It shouldn't fail"
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :utf-8 info))
|
|
|
|
|
info)))))
|
2012-10-25 17:54:53 -04:00
|
|
|
|
;; Apostrophe: before an object.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2015-03-28 10:08:44 -04:00
|
|
|
|
'("« a’" " »")
|
|
|
|
|
(let ((org-export-default-language "fr"))
|
|
|
|
|
(org-test-with-parsed-data "\"a'=b=\""
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
2015-03-28 10:08:44 -04:00
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :utf-8 info))
|
2013-03-19 11:27:15 -04:00
|
|
|
|
info)))))
|
2012-10-25 17:54:53 -04:00
|
|
|
|
;; Apostrophe: after an object.
|
|
|
|
|
(should
|
2015-03-28 10:08:44 -04:00
|
|
|
|
(equal '("« " "’s »")
|
|
|
|
|
(let ((org-export-default-language "fr"))
|
|
|
|
|
(org-test-with-parsed-data "\"=code='s\""
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :utf-8 info))
|
|
|
|
|
info)))))
|
2012-10-29 15:36:03 -04:00
|
|
|
|
;; Special case: isolated quotes.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("“" "”")
|
|
|
|
|
(let ((org-export-default-language "en"))
|
|
|
|
|
(org-test-with-parsed-data "\"$x$\""
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2012-10-31 07:28:21 -04:00
|
|
|
|
;; Smart quotes in secondary strings.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("“" "”")
|
|
|
|
|
(let ((org-export-default-language "en"))
|
|
|
|
|
(org-test-with-parsed-data "* \"$x$\""
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2024-01-21 07:44:50 -05:00
|
|
|
|
;; Smart quotes when object has multiple secondary strings.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(" “prefix” " " “suffix”")
|
|
|
|
|
(let ((org-export-default-language "en"))
|
|
|
|
|
(org-test-with-parsed-data "[cite:; \"prefix\" @key \"suffix\";]"
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2012-10-31 07:28:21 -04:00
|
|
|
|
;; Smart quotes in document keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("“" "”")
|
|
|
|
|
(let ((org-export-default-language "en"))
|
|
|
|
|
(org-test-with-parsed-data "#+TITLE: \"$x$\""
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map (plist-get info :title) 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info)))))
|
2012-10-31 07:28:21 -04:00
|
|
|
|
;; Smart quotes in parsed affiliated keywords.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("“" "”" "Paragraph")
|
|
|
|
|
(let ((org-export-default-language "en"))
|
|
|
|
|
(org-test-with-parsed-data "#+CAPTION: \"$x$\"\nParagraph"
|
2016-03-10 04:10:29 -05:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
|
|
|
|
info nil nil t)))))
|
|
|
|
|
;; Smart quotes within objects.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("“foo”")
|
|
|
|
|
(let ((org-export-default-language "en"))
|
|
|
|
|
(org-test-with-parsed-data "| \"foo\" |"
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
2016-03-17 12:15:17 -04:00
|
|
|
|
info nil nil t)))))
|
2022-11-22 22:32:04 -05:00
|
|
|
|
(should
|
|
|
|
|
(equal '("“foo”")
|
|
|
|
|
(let ((org-export-default-language "en"))
|
|
|
|
|
(org-test-with-parsed-data "*\"foo\"*"
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :html info))
|
2024-03-23 07:34:06 -04:00
|
|
|
|
info nil nil t)))))
|
|
|
|
|
;; Unmatched quotes.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("\\guillemotleft{}my friends' party and the students' papers\\guillemotright{} \\guillemotleft{}``mothers''\\guillemotright{}")
|
|
|
|
|
(let ((org-export-default-language "es"))
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"\"my friends' party and the students' papers\" \"'mothers'\""
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :latex info))
|
|
|
|
|
info nil nil t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '("\"'mothers'")
|
|
|
|
|
(let ((org-export-default-language "es"))
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"\"'mothers'"
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :latex info))
|
|
|
|
|
info nil nil t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '("\"'mothers " "end'")
|
|
|
|
|
(let ((org-export-default-language "es"))
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"\"'mothers =verbatim= end'"
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :latex info))
|
|
|
|
|
info nil nil t)))))
|
|
|
|
|
(should
|
|
|
|
|
(equal '("\\guillemotleft{}να 'ρθώ το βράδυ\\guillemotright{}")
|
|
|
|
|
(let ((org-export-default-language "el"))
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"\"να 'ρθώ το βράδυ\""
|
|
|
|
|
(org-element-map tree 'plain-text
|
|
|
|
|
(lambda (s) (org-export-activate-smart-quotes s :latex info))
|
2022-11-22 22:32:04 -05:00
|
|
|
|
info nil nil t))))))
|
2012-10-25 17:54:53 -04:00
|
|
|
|
|
|
|
|
|
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
|
|
|
|
;;; Tables
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/special-column ()
|
|
|
|
|
"Test if the table's special column is properly recognized."
|
|
|
|
|
;; 1. First column is special if it contains only a special marking
|
|
|
|
|
;; characters or empty cells.
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
| ! | 1 |
|
|
|
|
|
| | 2 |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-has-special-column-p
|
|
|
|
|
(org-element-map
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-parse-buffer) 'table 'identity nil 'first-match))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 2. If the column contains anything else, it isn't special.
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
| ! | 1 |
|
|
|
|
|
| b | 2 |"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-table-has-special-column-p
|
|
|
|
|
(org-element-map
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-parse-buffer) 'table 'identity nil 'first-match))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 3. Special marking characters are "#", "^", "*", "_", "/", "$"
|
|
|
|
|
;; and "!".
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
| # | 1 |
|
|
|
|
|
| ^ | 2 |
|
|
|
|
|
| * | 3 |
|
|
|
|
|
| _ | 4 |
|
|
|
|
|
| / | 5 |
|
|
|
|
|
| $ | 6 |
|
|
|
|
|
| ! | 7 |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-has-special-column-p
|
|
|
|
|
(org-element-map
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-parse-buffer) 'table 'identity nil 'first-match))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 4. A first column with only empty cells isn't considered as
|
|
|
|
|
;; special.
|
|
|
|
|
(org-test-with-temp-text "
|
|
|
|
|
| | 1 |
|
|
|
|
|
| | 2 |"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-table-has-special-column-p
|
|
|
|
|
(org-element-map
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-parse-buffer) 'table 'identity nil 'first-match)))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
2012-05-03 08:29:30 -04:00
|
|
|
|
(ert-deftest test-org-export/table-row-is-special-p ()
|
|
|
|
|
"Test `org-export-table-row-is-special-p' specifications."
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 1. A row is special if it has a special marking character in the
|
|
|
|
|
;; special column.
|
|
|
|
|
(org-test-with-parsed-data "| ! | 1 |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-row-is-special-p
|
|
|
|
|
(org-element-map tree 'table-row 'identity nil 'first-match) info)))
|
|
|
|
|
;; 2. A row is special when its first field is "/"
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | 1 |
|
|
|
|
|
| a | b |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-row-is-special-p
|
|
|
|
|
(org-element-map tree 'table-row 'identity nil 'first-match) info)))
|
|
|
|
|
;; 3. A row only containing alignment cookies is also considered as
|
|
|
|
|
;; special.
|
|
|
|
|
(org-test-with-parsed-data "| <5> | | <l> | <l22> |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-row-is-special-p
|
|
|
|
|
(org-element-map tree 'table-row 'identity nil 'first-match) info)))
|
|
|
|
|
;; 4. Everything else isn't considered as special.
|
2012-05-03 08:29:30 -04:00
|
|
|
|
(org-test-with-parsed-data "| \alpha | | c |"
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
(should-not
|
|
|
|
|
(org-export-table-row-is-special-p
|
|
|
|
|
(org-element-map tree 'table-row 'identity nil 'first-match) info)))
|
|
|
|
|
;; 5. Table's rules are never considered as special rows.
|
|
|
|
|
(org-test-with-parsed-data "|---+---|"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-table-row-is-special-p
|
|
|
|
|
(org-element-map tree 'table-row 'identity nil 'first-match) info))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/has-header-p ()
|
|
|
|
|
"Test `org-export-table-has-header-p' specifications."
|
2017-01-01 17:58:29 -05:00
|
|
|
|
;; With an header.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| a | b |
|
|
|
|
|
|---+---|
|
|
|
|
|
| c | d |"
|
|
|
|
|
(org-export-table-has-header-p
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match)
|
|
|
|
|
info)))
|
2020-06-12 12:42:34 -04:00
|
|
|
|
;; With a multi-line header.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a | b |
|
|
|
|
|
| 0 | 1 |
|
|
|
|
|
|---+---|
|
|
|
|
|
| a | w |"
|
|
|
|
|
(org-export-table-has-header-p
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match)
|
|
|
|
|
info)))
|
2017-01-01 17:58:29 -05:00
|
|
|
|
;; Without an header.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| a | b |
|
|
|
|
|
| c | d |"
|
|
|
|
|
(org-export-table-has-header-p
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match)
|
|
|
|
|
info)))
|
2017-01-01 17:58:29 -05:00
|
|
|
|
;; Don't get fooled with starting and ending rules.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|---+---|
|
|
|
|
|
| a | b |
|
|
|
|
|
| c | d |
|
|
|
|
|
|---+---|"
|
|
|
|
|
(org-export-table-has-header-p
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match)
|
|
|
|
|
info))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-row-group ()
|
|
|
|
|
"Test `org-export-table-row-group' specifications."
|
2017-01-01 17:58:29 -05:00
|
|
|
|
;; A rule creates a new group.
|
2013-05-18 12:20:46 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(1 rule 2)
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| a | b |
|
|
|
|
|
|---+---|
|
|
|
|
|
| 1 | 2 |"
|
2013-05-18 12:20:46 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (eq (org-element-property :type row) 'rule) 'rule
|
|
|
|
|
(org-export-table-row-group row info)))))))
|
2017-01-01 17:58:29 -05:00
|
|
|
|
;; Special rows are ignored in count.
|
2013-05-18 12:20:46 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(rule 1)
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| / | < | > |
|
|
|
|
|
|---|---+---|
|
|
|
|
|
| | 1 | 2 |"
|
2013-05-18 12:20:46 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (eq (org-element-property :type row) 'rule) 'rule
|
|
|
|
|
(org-export-table-row-group row info)))
|
|
|
|
|
info))))
|
2017-01-01 17:58:29 -05:00
|
|
|
|
;; Double rules also are ignored in count.
|
2013-05-18 12:20:46 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '(1 rule rule 2)
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| a | b |
|
|
|
|
|
|---+---|
|
|
|
|
|
|---+---|
|
|
|
|
|
| 1 | 2 |"
|
2013-05-18 12:20:46 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (eq (org-element-property :type row) 'rule) 'rule
|
|
|
|
|
(org-export-table-row-group row info))))))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
2013-04-09 10:52:01 -04:00
|
|
|
|
(ert-deftest test-org-export/table-row-number ()
|
|
|
|
|
"Test `org-export-table-row-number' specifications."
|
|
|
|
|
;; Standard test. Number is 0-indexed.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(0 1)
|
|
|
|
|
(org-test-with-parsed-data "| a | b | c |\n| d | e | f |"
|
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row) (org-export-table-row-number row info)) info))))
|
|
|
|
|
;; Number ignores separators.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(0 1)
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a | b | c |
|
|
|
|
|
|---+---+---|
|
|
|
|
|
| d | e | f |"
|
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row) (org-export-table-row-number row info)) info))))
|
|
|
|
|
;; Number ignores special rows.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(0 1)
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | < | > |
|
|
|
|
|
| | b | c |
|
|
|
|
|
|---+-----+-----|
|
|
|
|
|
| | <c> | <c> |
|
|
|
|
|
| | e | f |"
|
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row) (org-export-table-row-number row info)) info)))))
|
|
|
|
|
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
(ert-deftest test-org-export/table-cell-width ()
|
|
|
|
|
"Test `org-export-table-cell-width' specifications."
|
2019-05-30 08:59:10 -04:00
|
|
|
|
;; Width is primarily determined by width cookies. If no cookie is
|
|
|
|
|
;; found, cell's width is nil.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(nil 6 7)
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| / | <l> | <6> | <l7> |
|
|
|
|
|
| | a | b | c |"
|
2019-05-30 08:59:10 -04:00
|
|
|
|
(mapcar (lambda (cell) (org-export-table-cell-width cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity info)))))
|
|
|
|
|
;; Valid width cookies must have a specific row.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(nil nil)
|
|
|
|
|
(org-test-with-parsed-data "| <6> | cell |"
|
|
|
|
|
(mapcar (lambda (cell) (org-export-table-cell-width cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity)))))
|
|
|
|
|
;; Do not error on malformed tables.
|
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
| b | c |"
|
|
|
|
|
(mapcar (lambda (cell) (org-export-table-cell-width cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity info)))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-cell-alignment ()
|
|
|
|
|
"Test `org-export-table-cell-alignment' specifications."
|
2013-08-12 04:42:05 -04:00
|
|
|
|
;; 1. Alignment is primarily determined by alignment cookies.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(left center right)
|
|
|
|
|
(let ((org-table-number-fraction 0.5)
|
|
|
|
|
(org-table-number-regexp "^[0-9]+$"))
|
|
|
|
|
(org-test-with-parsed-data "| <l> | <c> | <r> |"
|
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-alignment cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity))))))
|
|
|
|
|
;; 2. The last alignment cookie has precedence.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(right right right)
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| <l8> |
|
|
|
|
|
| cell |
|
|
|
|
|
| <r9> |"
|
2013-08-12 04:42:05 -04:00
|
|
|
|
(mapcar (lambda (cell) (org-export-table-cell-alignment cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity)))))
|
|
|
|
|
;; 3. If there's no cookie, cell's contents determine alignment.
|
|
|
|
|
;; A column mostly made of cells containing numbers will align
|
|
|
|
|
;; its cells to the right.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(right right right)
|
|
|
|
|
(let ((org-table-number-fraction 0.5)
|
|
|
|
|
(org-table-number-regexp "^[0-9]+$"))
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| 123 |
|
|
|
|
|
| some text |
|
|
|
|
|
| 12345 |"
|
2013-08-12 04:42:05 -04:00
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-alignment cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity))))))
|
|
|
|
|
;; 4. Otherwise, they will be aligned to the left.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(left left left)
|
|
|
|
|
(org-test-with-parsed-data "
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
| text |
|
|
|
|
|
| some text |
|
2012-05-03 08:29:30 -04:00
|
|
|
|
| \alpha |"
|
2013-08-12 04:42:05 -04:00
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-alignment cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity info))))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-cell-borders ()
|
|
|
|
|
"Test `org-export-table-cell-borders' specifications."
|
|
|
|
|
;; 1. Recognize various column groups indicators.
|
|
|
|
|
(org-test-with-parsed-data "| / | < | > | <> |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'((right bottom top) (left bottom top) (right bottom top)
|
|
|
|
|
(right left bottom top))
|
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-borders cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity)))))
|
|
|
|
|
;; 2. Accept shortcuts to define column groups.
|
|
|
|
|
(org-test-with-parsed-data "| / | < | < |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'((right bottom top) (right left bottom top) (left bottom top))
|
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-borders cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity)))))
|
|
|
|
|
;; 3. A valid column groups row must start with a "/".
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| | < |
|
|
|
|
|
| a | b |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '((top) (top) (bottom) (bottom))
|
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-borders cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity)))))
|
|
|
|
|
;; 4. Take table rules into consideration.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| 1 |
|
|
|
|
|
|---|
|
|
|
|
|
| 2 |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '((below top) (bottom above))
|
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-borders cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity)))))
|
|
|
|
|
;; 5. Top and (resp. bottom) rules induce both `top' and `above'
|
|
|
|
|
;; (resp. `bottom' and `below') borders. Any special row is
|
|
|
|
|
;; ignored.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
|---+----|
|
|
|
|
|
| / | |
|
|
|
|
|
| | 1 |
|
|
|
|
|
|---+----|"
|
|
|
|
|
(should
|
|
|
|
|
(equal '((bottom below top above))
|
|
|
|
|
(last
|
|
|
|
|
(mapcar (lambda (cell)
|
|
|
|
|
(org-export-table-cell-borders cell info))
|
|
|
|
|
(org-element-map tree 'table-cell 'identity)))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-dimensions ()
|
|
|
|
|
"Test `org-export-table-dimensions' specifications."
|
|
|
|
|
;; 1. Standard test.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| 1 | 2 | 3 |
|
|
|
|
|
| 4 | 5 | 6 |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '(2 . 3)
|
|
|
|
|
(org-export-table-dimensions
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match) info))))
|
|
|
|
|
;; 2. Ignore horizontal rules and special columns.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | < | > |
|
|
|
|
|
| 1 | 2 | 3 |
|
|
|
|
|
|---+---+---|
|
|
|
|
|
| 4 | 5 | 6 |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '(2 . 3)
|
|
|
|
|
(org-export-table-dimensions
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match) info)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-cell-address ()
|
|
|
|
|
"Test `org-export-table-cell-address' specifications."
|
|
|
|
|
;; 1. Standard test: index is 0-based.
|
|
|
|
|
(org-test-with-parsed-data "| a | b |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '((0 . 0) (0 . 1))
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-cell
|
|
|
|
|
(lambda (cell) (org-export-table-cell-address cell info))
|
|
|
|
|
info))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 2. Special column isn't counted, nor are special rows.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | <> |
|
|
|
|
|
| | c |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '(0 . 0)
|
|
|
|
|
(org-export-table-cell-address
|
|
|
|
|
(car (last (org-element-map tree 'table-cell 'identity info)))
|
|
|
|
|
info))))
|
|
|
|
|
;; 3. Tables rules do not count either.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
|---|
|
|
|
|
|
| b |
|
|
|
|
|
|---|
|
|
|
|
|
| c |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '(2 . 0)
|
|
|
|
|
(org-export-table-cell-address
|
|
|
|
|
(car (last (org-element-map tree 'table-cell 'identity info)))
|
|
|
|
|
info))))
|
|
|
|
|
;; 4. Return nil for special cells.
|
|
|
|
|
(org-test-with-parsed-data "| / | a |"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-table-cell-address
|
|
|
|
|
(org-element-map tree 'table-cell 'identity nil 'first-match)
|
|
|
|
|
info))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-table-cell-at ()
|
|
|
|
|
"Test `org-export-get-table-cell-at' specifications."
|
|
|
|
|
;; 1. Address ignores special columns, special rows and rules.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | <> |
|
|
|
|
|
| | a |
|
|
|
|
|
|---+----|
|
|
|
|
|
| | b |"
|
|
|
|
|
(should
|
|
|
|
|
(equal '("b")
|
|
|
|
|
(org-element-contents
|
|
|
|
|
(org-export-get-table-cell-at
|
|
|
|
|
'(1 . 0)
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match)
|
|
|
|
|
info)))))
|
|
|
|
|
;; 2. Return value for a non-existent address is nil.
|
|
|
|
|
(org-test-with-parsed-data "| a |"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-get-table-cell-at
|
|
|
|
|
'(2 . 2)
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match)
|
|
|
|
|
info)))
|
|
|
|
|
(org-test-with-parsed-data "| / |"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-get-table-cell-at
|
|
|
|
|
'(0 . 0)
|
|
|
|
|
(org-element-map tree 'table 'identity info 'first-match)
|
|
|
|
|
info))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-cell-starts-colgroup-p ()
|
|
|
|
|
"Test `org-export-table-cell-starts-colgroup-p' specifications."
|
|
|
|
|
;; 1. A cell at a beginning of a row always starts a column group.
|
|
|
|
|
(org-test-with-parsed-data "| a |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-cell-starts-colgroup-p
|
|
|
|
|
(org-element-map tree 'table-cell 'identity info 'first-match)
|
|
|
|
|
info)))
|
|
|
|
|
;; 2. Special column should be ignored when determining the
|
|
|
|
|
;; beginning of the row.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | |
|
|
|
|
|
| | a |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-cell-starts-colgroup-p
|
|
|
|
|
(org-element-map tree 'table-cell 'identity info 'first-match)
|
|
|
|
|
info)))
|
|
|
|
|
;; 2. Explicit column groups.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | | < |
|
|
|
|
|
| a | b | c |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no yes)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-cell
|
|
|
|
|
(lambda (cell)
|
|
|
|
|
(if (org-export-table-cell-starts-colgroup-p cell info) 'yes 'no))
|
|
|
|
|
info)))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-cell-ends-colgroup-p ()
|
|
|
|
|
"Test `org-export-table-cell-ends-colgroup-p' specifications."
|
|
|
|
|
;; 1. A cell at the end of a row always ends a column group.
|
|
|
|
|
(org-test-with-parsed-data "| a |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-cell-ends-colgroup-p
|
|
|
|
|
(org-element-map tree 'table-cell 'identity info 'first-match)
|
|
|
|
|
info)))
|
|
|
|
|
;; 2. Special column should be ignored when determining the
|
|
|
|
|
;; beginning of the row.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | |
|
|
|
|
|
| | a |"
|
|
|
|
|
(should
|
|
|
|
|
(org-export-table-cell-ends-colgroup-p
|
|
|
|
|
(org-element-map tree 'table-cell 'identity info 'first-match)
|
|
|
|
|
info)))
|
|
|
|
|
;; 3. Explicit column groups.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | < | |
|
|
|
|
|
| a | b | c |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no yes)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-cell
|
|
|
|
|
(lambda (cell)
|
|
|
|
|
(if (org-export-table-cell-ends-colgroup-p cell info) 'yes 'no))
|
|
|
|
|
info)))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-row-starts-rowgroup-p ()
|
|
|
|
|
"Test `org-export-table-row-starts-rowgroup-p' specifications."
|
|
|
|
|
;; 1. A row at the beginning of a table always starts a row group.
|
|
|
|
|
;; So does a row following a table rule.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
|---|
|
|
|
|
|
| b |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no yes)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-starts-rowgroup-p row info) 'yes 'no))
|
|
|
|
|
info))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 2. Special rows should be ignored when determining the beginning
|
|
|
|
|
;; of the row.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| / | < |
|
|
|
|
|
| | a |
|
|
|
|
|
|---+---|
|
|
|
|
|
| / | < |
|
|
|
|
|
| | b |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no yes)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-starts-rowgroup-p row info) 'yes 'no))
|
|
|
|
|
info)))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-row-ends-rowgroup-p ()
|
|
|
|
|
"Test `org-export-table-row-ends-rowgroup-p' specifications."
|
|
|
|
|
;; 1. A row at the end of a table always ends a row group. So does
|
|
|
|
|
;; a row preceding a table rule.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
|---|
|
|
|
|
|
| b |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no yes)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-ends-rowgroup-p row info) 'yes 'no))
|
|
|
|
|
info))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 2. Special rows should be ignored when determining the beginning
|
|
|
|
|
;; of the row.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| | a |
|
|
|
|
|
| / | < |
|
|
|
|
|
|---+---|
|
|
|
|
|
| | b |
|
|
|
|
|
| / | < |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no yes)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-ends-rowgroup-p row info) 'yes 'no))
|
|
|
|
|
info)))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
|
2014-08-26 09:05:52 -04:00
|
|
|
|
(ert-deftest test-org-export/table-row-in-header-p ()
|
|
|
|
|
"Test `org-export-table-row-in-header-p' specifications."
|
|
|
|
|
;; Standard test. Separators are always nil.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no no)
|
|
|
|
|
(org-test-with-parsed-data "| a |\n|---|\n| b |"
|
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-in-header-p row info) 'yes 'no)) info))))
|
|
|
|
|
;; Nil when there is no header.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(no no)
|
|
|
|
|
(org-test-with-parsed-data "| a |\n| b |"
|
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-in-header-p row info) 'yes 'no)) info)))))
|
|
|
|
|
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
(ert-deftest test-org-export/table-row-starts-header-p ()
|
|
|
|
|
"Test `org-export-table-row-starts-header-p' specifications."
|
|
|
|
|
;; 1. Only the row starting the first row group starts the table
|
|
|
|
|
;; header.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
| b |
|
|
|
|
|
|---|
|
|
|
|
|
| c |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(yes no no no)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-starts-header-p row info) 'yes 'no))
|
|
|
|
|
info))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 2. A row cannot start an header if there's no header in the
|
|
|
|
|
;; table.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
|---|"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-table-row-starts-header-p
|
|
|
|
|
(org-element-map tree 'table-row 'identity info 'first-match)
|
|
|
|
|
info))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/table-row-ends-header-p ()
|
|
|
|
|
"Test `org-export-table-row-ends-header-p' specifications."
|
|
|
|
|
;; 1. Only the row starting the first row group starts the table
|
|
|
|
|
;; header.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
| b |
|
|
|
|
|
|---|
|
|
|
|
|
| c |"
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(no yes no no)
|
2013-03-19 11:27:15 -04:00
|
|
|
|
(org-element-map tree 'table-row
|
|
|
|
|
(lambda (row)
|
|
|
|
|
(if (org-export-table-row-ends-header-p row info) 'yes 'no))
|
|
|
|
|
info))))
|
org-export: Define tools for tables, table rows and table cells
* contrib/lisp/org-export.el (org-export-table-cell-width,
org-export-table-cell-alignment, org-export-table-cell-borders,
org-export-table-row-group, org-export-table-has-special-column-p,
org-export-table-row-is-special-p, org-export-get-parent-table,
org-export-table-dimensions, org-export-table-cell-address,
org-export-get-table-cell-at, org-export-table-has-header-p,
org-export-table-cell-starts-colgroup-p,
org-export-table-cell-ends-colgroup-p,
org-export-table-row-starts-rowgroup-p,
org-export-table-row-ends-rowgroup-p,
org-export-table-row-starts-header-p,
org-export-table-row-ends-header-p): New functions.
(org-export-table-format-info, org-export-clean-table): Removed
functions.
(org-export-filter-table-cell-functions,
org-export-filter-table-row-functions): New variables.
(org-export-filters-alist): Install new filters.
(org-export-collect-tree-properties, org-export--skip-p): Mark special
rows and cells as ignored.
* testing/lisp/test-org-export.el: Add tests.
2012-04-11 02:54:24 -04:00
|
|
|
|
;; 2. A row cannot start an header if there's no header in the
|
|
|
|
|
;; table.
|
|
|
|
|
(org-test-with-parsed-data "
|
|
|
|
|
| a |
|
|
|
|
|
|---|"
|
|
|
|
|
(should-not
|
|
|
|
|
(org-export-table-row-ends-header-p
|
|
|
|
|
(org-element-map tree 'table-row 'identity info 'first-match)
|
|
|
|
|
info))))
|
|
|
|
|
|
2012-03-10 05:37:13 -05:00
|
|
|
|
|
2013-08-31 08:30:25 -04:00
|
|
|
|
|
|
|
|
|
;;; Tables of Contents
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/collect-headlines ()
|
|
|
|
|
"Test `org-export-collect-headlines' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
2017-09-10 09:53:20 -04:00
|
|
|
|
(equal '("H1" "H2")
|
|
|
|
|
(org-test-with-parsed-data "* H1\n** H2"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info)))))
|
2013-08-31 08:30:25 -04:00
|
|
|
|
;; Do not collect headlines below optional argument.
|
|
|
|
|
(should
|
2017-09-10 09:53:20 -04:00
|
|
|
|
(equal '("H1")
|
|
|
|
|
(org-test-with-parsed-data "* H1\n** H2"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info 1)))))
|
2013-08-31 08:30:25 -04:00
|
|
|
|
;; Never collect headlines below maximum headline level.
|
|
|
|
|
(should
|
2017-09-10 09:53:20 -04:00
|
|
|
|
(equal '("H1")
|
|
|
|
|
(org-test-with-parsed-data "#+OPTIONS: H:1\n* H1\n** H2"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info)))))
|
2013-08-31 08:30:25 -04:00
|
|
|
|
(should
|
2017-09-10 09:53:20 -04:00
|
|
|
|
(equal '("H1")
|
|
|
|
|
(org-test-with-parsed-data "#+OPTIONS: H:1\n* H1\n** H2"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info 2)))))
|
|
|
|
|
;; Do not collect footnote section.
|
|
|
|
|
(should
|
|
|
|
|
(equal '("H1")
|
|
|
|
|
(let ((org-footnote-section "Footnotes"))
|
|
|
|
|
(org-test-with-parsed-data "* H1\n** Footnotes"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info))))))
|
2017-10-07 10:03:17 -04:00
|
|
|
|
;; Do not collect headlines with UNNUMBERED property set to "notoc".
|
|
|
|
|
;; Headlines with another value for the property are still
|
2017-11-20 08:07:03 -05:00
|
|
|
|
;; collected. UNNUMBERED property is inherited.
|
2017-10-07 10:03:17 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '("H1")
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* H1\n* H2\n:PROPERTIES:\n:UNNUMBERED: notoc\n:END:"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info)))))
|
2017-11-20 08:07:03 -05:00
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* H1\n:PROPERTIES:\n:UNNUMBERED: notoc\n:END:\n** H2"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info))))
|
2017-10-07 10:03:17 -04:00
|
|
|
|
(should
|
|
|
|
|
(equal '("H1" "H2")
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* H1\n* H2\n:PROPERTIES:\n:UNNUMBERED: t\n:END:"
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info)))))
|
2014-10-25 11:14:34 -04:00
|
|
|
|
;; Collect headlines locally.
|
|
|
|
|
(should
|
2017-09-10 09:53:20 -04:00
|
|
|
|
(equal '("H2" "H3")
|
|
|
|
|
(org-test-with-parsed-data "* H1\n** H2\n** H3"
|
|
|
|
|
(let ((scope (org-element-map tree 'headline #'identity info t)))
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info nil scope))))))
|
2019-05-15 14:22:05 -04:00
|
|
|
|
;; Collect headlines from a scope specified by a fuzzy match
|
|
|
|
|
(should
|
|
|
|
|
(equal '("H3" "H4")
|
|
|
|
|
(org-test-with-parsed-data "* HA
|
|
|
|
|
** H1
|
|
|
|
|
** H2
|
|
|
|
|
* Target
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:CUSTOM_ID: TargetSection
|
|
|
|
|
:END:
|
|
|
|
|
** H3
|
|
|
|
|
** H4
|
|
|
|
|
* HB
|
|
|
|
|
** H5
|
|
|
|
|
"
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines
|
|
|
|
|
info
|
|
|
|
|
nil
|
|
|
|
|
(org-export-resolve-fuzzy-link
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(save-excursion (insert "[[Target]]"))
|
|
|
|
|
(org-element-link-parser))
|
|
|
|
|
info))))))
|
|
|
|
|
;; Collect headlines from a scope specified by CUSTOM_ID
|
|
|
|
|
(should
|
|
|
|
|
(equal '("H3" "H4")
|
|
|
|
|
(org-test-with-parsed-data "* Not this section
|
|
|
|
|
** H1
|
|
|
|
|
** H2
|
|
|
|
|
* Target
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:CUSTOM_ID: TargetSection
|
|
|
|
|
:END:
|
|
|
|
|
** H3
|
|
|
|
|
** H4
|
|
|
|
|
* Another
|
|
|
|
|
** H5
|
|
|
|
|
"
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines
|
|
|
|
|
info
|
|
|
|
|
nil
|
|
|
|
|
(org-export-resolve-id-link
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(save-excursion (insert "[[#TargetSection]]"))
|
|
|
|
|
(org-element-link-parser))
|
|
|
|
|
info))))))
|
2014-10-25 11:14:34 -04:00
|
|
|
|
;; When collecting locally, optional level is relative.
|
|
|
|
|
(should
|
2017-09-10 09:53:20 -04:00
|
|
|
|
(equal '("H2")
|
|
|
|
|
(org-test-with-parsed-data "* H1\n** H2\n*** H3"
|
|
|
|
|
(let ((scope (org-element-map tree 'headline #'identity info t)))
|
|
|
|
|
(mapcar (lambda (h) (org-element-property :raw-value h))
|
|
|
|
|
(org-export-collect-headlines info 1 scope)))))))
|
2013-08-31 08:30:25 -04:00
|
|
|
|
|
2017-10-15 06:15:06 -04:00
|
|
|
|
(ert-deftest test-org-export/excluded-from-toc-p ()
|
|
|
|
|
"Test `org-export-excluded-from-toc-p' specifications."
|
2017-11-20 08:07:03 -05:00
|
|
|
|
;; By default, headlines are not excluded.
|
2017-10-15 06:15:06 -04:00
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "* H1"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-excluded-from-toc-p h info)) info t)))
|
2017-11-20 08:07:03 -05:00
|
|
|
|
;; Exclude according to a maximum level.
|
|
|
|
|
(should
|
|
|
|
|
(equal '(in out)
|
|
|
|
|
(org-test-with-parsed-data "#+OPTIONS: H:1\n* H1\n** H2"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-excluded-from-toc-p h info) 'out 'in))
|
|
|
|
|
info))))
|
|
|
|
|
;; Exclude according to UNNUMBERED property.
|
2017-10-15 06:15:06 -04:00
|
|
|
|
(should
|
|
|
|
|
(org-test-with-parsed-data "* H1\n:PROPERTIES:\n:UNNUMBERED: notoc\n:END:"
|
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (org-export-excluded-from-toc-p h info)) info t)))
|
2017-11-20 08:07:03 -05:00
|
|
|
|
;; UNNUMBERED property is inherited, so is "notoc" value.
|
2017-10-15 06:15:06 -04:00
|
|
|
|
(should
|
2017-11-20 08:07:03 -05:00
|
|
|
|
(equal '(out out)
|
|
|
|
|
(org-test-with-parsed-data
|
|
|
|
|
"* H1\n:PROPERTIES:\n:UNNUMBERED: notoc\n:END:\n** H2"
|
2017-10-15 06:15:06 -04:00
|
|
|
|
(org-element-map tree 'headline
|
|
|
|
|
(lambda (h) (if (org-export-excluded-from-toc-p h info) 'out 'in))
|
|
|
|
|
info)))))
|
|
|
|
|
|
2017-10-14 06:29:52 -04:00
|
|
|
|
(ert-deftest test-org-export/toc-entry-backend ()
|
|
|
|
|
"Test `org-export-toc-entry-backend' specifications."
|
|
|
|
|
;; Ignore targets.
|
|
|
|
|
(should
|
|
|
|
|
(equal "H \n"
|
|
|
|
|
(org-test-with-temp-text "* H <<target>>"
|
|
|
|
|
(let (org-export-registered-backends)
|
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-data-with-backend
|
|
|
|
|
(org-element-property :title h)
|
|
|
|
|
(org-export-toc-entry-backend 'test)
|
|
|
|
|
i)))))
|
|
|
|
|
(org-export-as 'test)))))
|
|
|
|
|
;; Ignore footnote references.
|
|
|
|
|
(should
|
|
|
|
|
(equal "H \n"
|
|
|
|
|
(org-test-with-temp-text "[fn:1] Definition\n* H [fn:1]"
|
|
|
|
|
(let (org-export-registered-backends)
|
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-data-with-backend
|
|
|
|
|
(org-element-property :title h)
|
|
|
|
|
(org-export-toc-entry-backend 'test)
|
|
|
|
|
i)))))
|
|
|
|
|
(org-export-as 'test)))))
|
|
|
|
|
;; Replace plain links with contents, or with path.
|
|
|
|
|
(should
|
|
|
|
|
(equal "H Org mode\n"
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(org-test-with-temp-text "* H [[https://orgmode.org][Org mode]]"
|
2017-10-14 06:29:52 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-data-with-backend
|
|
|
|
|
(org-element-property :title h)
|
|
|
|
|
(org-export-toc-entry-backend 'test)
|
|
|
|
|
i)))))
|
|
|
|
|
(org-export-as 'test)))))
|
|
|
|
|
(should
|
2018-01-16 13:42:57 -05:00
|
|
|
|
(equal "H https://orgmode.org\n"
|
|
|
|
|
(org-test-with-temp-text "* H [[https://orgmode.org]]"
|
2017-10-14 06:29:52 -04:00
|
|
|
|
(let (org-export-registered-backends)
|
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-data-with-backend
|
|
|
|
|
(org-element-property :title h)
|
|
|
|
|
(org-export-toc-entry-backend 'test)
|
|
|
|
|
i)))))
|
|
|
|
|
(org-export-as 'test)))))
|
|
|
|
|
;; Replace radio targets with contents.
|
|
|
|
|
(should
|
|
|
|
|
(equal "H radio\n"
|
|
|
|
|
(org-test-with-temp-text "* H <<<radio>>>"
|
|
|
|
|
(let (org-export-registered-backends)
|
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-data-with-backend
|
|
|
|
|
(org-element-property :title h)
|
|
|
|
|
(org-export-toc-entry-backend 'test)
|
|
|
|
|
i)))))
|
|
|
|
|
(org-export-as 'test)))))
|
|
|
|
|
;; With optional argument TRANSCODERS, specify other
|
|
|
|
|
;; transformations.
|
|
|
|
|
(should
|
|
|
|
|
(equal "H bold\n"
|
|
|
|
|
(org-test-with-temp-text "* H *bold*"
|
|
|
|
|
(let (org-export-registered-backends)
|
|
|
|
|
(org-export-define-backend 'test
|
|
|
|
|
'((headline . (lambda (h _c i) (org-export-data-with-backend
|
2017-11-20 08:07:03 -05:00
|
|
|
|
(org-element-property :title h)
|
|
|
|
|
(org-export-toc-entry-backend 'test
|
|
|
|
|
'(bold . (lambda (_b c _i) c)))
|
|
|
|
|
i)))))
|
2017-10-14 06:29:52 -04:00
|
|
|
|
(org-export-as 'test))))))
|
|
|
|
|
|
2013-08-31 08:30:25 -04:00
|
|
|
|
|
2013-02-11 16:19:23 -05:00
|
|
|
|
|
|
|
|
|
;;; Templates
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/inner-template ()
|
|
|
|
|
"Test `inner-template' translator specifications."
|
|
|
|
|
(should
|
|
|
|
|
(equal "Success!"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders
|
2013-03-19 11:27:15 -04:00
|
|
|
|
'((inner-template . (lambda (contents info) "Success!"))
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(headline . (lambda (h c i) "Headline"))))))))
|
2013-02-11 16:19:23 -05:00
|
|
|
|
;; Inner template is applied even in a "body-only" export.
|
|
|
|
|
(should
|
|
|
|
|
(equal "Success!"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((inner-template . (lambda (c i) "Success!"))
|
|
|
|
|
(headline . (lambda (h c i) "Headline"))))
|
|
|
|
|
nil nil 'body-only)))))
|
2013-02-11 16:19:23 -05:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/template ()
|
|
|
|
|
"Test `template' translator specifications."
|
|
|
|
|
(should
|
|
|
|
|
(equal "Success!"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((template . (lambda (contents info) "Success!"))
|
|
|
|
|
(headline . (lambda (h c i) "Headline"))))))))
|
2013-02-11 16:19:23 -05:00
|
|
|
|
;; Template is not applied in a "body-only" export.
|
|
|
|
|
(should-not
|
|
|
|
|
(equal "Success!"
|
ox: Change back-ends internal representation to structures
* lisp/ox.el (org-export--registered-backends): Renamed from
`org-export-registered-backends'.
(org-export-invisible-backends): Removed variable.
(org-export-get-backend, org-export-get-all-transcoders
org-export-get-all-options, org-export-get-all-filters): New
functions. It replaces `org-export-backend-translate-table'.
(org-export-barf-if-invalid-backend, org-export-derived-backend-p,
org-export-define-backend, org-export-define-derived-backend):
Rewrite functions using new representation.
(org-export-backend-translate-table): Remove function.
(org-export-get-environment): Use new function.
(org-export--get-subtree-options, org-export--parse-option-keyword,
org-export--get-inbuffer-options, org-export--get-global-options,
org-export-to-buffer org-export-to-file, org-export-string-as
org-export-replace-region-by): Update docstring.
(org-export-data-with-translations): Remove function. Use
`org-export-data-with-backend' with a temporary back-end instead.
(org-export-data-with-backend, org-export-as): Reflect new definition
for back-ends.
(org-export--dispatch-action, org-export--dispatch-ui): Reflect new
definition for back-ends and variable removal. Refactoring.
(org-export-filter-apply-functions): Call functions with
current back-end's name, not full back-end.
* lisp/org.el (org-export-backends, org-create-formula--latex-header):
Use new structure and variables.
* testing/lisp/test-ox.el: Update tests.
This patch separates back-end definition from its registration. Thus,
it allows to use anonymous or unregistered back-ends.
2013-06-24 14:52:10 -04:00
|
|
|
|
(org-test-with-temp-text "* Headline"
|
|
|
|
|
(org-export-as
|
|
|
|
|
(org-export-create-backend
|
|
|
|
|
:transcoders '((template . (lambda (contents info) "Success!"))
|
|
|
|
|
(headline . (lambda (h c i) "Headline"))))
|
|
|
|
|
nil nil 'body-only)))))
|
2013-02-11 16:19:23 -05:00
|
|
|
|
|
|
|
|
|
|
2012-07-10 13:22:04 -04:00
|
|
|
|
|
|
|
|
|
;;; Topology
|
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-next-element ()
|
|
|
|
|
"Test `org-export-get-next-element' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal "b"
|
|
|
|
|
(org-test-with-parsed-data "* Headline\n*a* b"
|
|
|
|
|
(org-export-get-next-element
|
2012-07-27 10:13:57 -04:00
|
|
|
|
(org-element-map tree 'bold 'identity info t) info))))
|
2012-07-10 13:22:04 -04:00
|
|
|
|
;; Return nil when no previous element.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "* Headline\na *b*"
|
|
|
|
|
(org-export-get-next-element
|
2012-07-27 10:13:57 -04:00
|
|
|
|
(org-element-map tree 'bold 'identity info t) info)))
|
|
|
|
|
;; Non-exportable elements are ignored.
|
|
|
|
|
(should-not
|
|
|
|
|
(let ((org-export-with-timestamps nil))
|
|
|
|
|
(org-test-with-parsed-data "\alpha <2012-03-29 Thu>"
|
|
|
|
|
(org-export-get-next-element
|
2012-10-31 07:28:21 -04:00
|
|
|
|
(org-element-map tree 'entity 'identity info t) info))))
|
|
|
|
|
;; Find next element in secondary strings.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "* a =verb="
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-next-element
|
|
|
|
|
(org-element-map tree 'plain-text 'identity info t) info)))))
|
2013-11-10 19:54:01 -05:00
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "* /italic/ =verb="
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-next-element
|
|
|
|
|
(org-element-map tree 'italic 'identity info t) info)))))
|
2012-10-31 07:28:21 -04:00
|
|
|
|
;; Find next element in document keywords.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "#+TITLE: a =verb="
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-next-element
|
|
|
|
|
(org-element-map
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(plist-get info :title) 'plain-text 'identity info t)
|
|
|
|
|
info)))))
|
2012-10-31 07:28:21 -04:00
|
|
|
|
;; Find next element in parsed affiliated keywords.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "#+CAPTION: a =verb=\nParagraph"
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-next-element
|
2012-12-08 12:57:10 -05:00
|
|
|
|
(org-element-map tree 'plain-text 'identity info t nil t) info)))))
|
2012-12-10 02:53:00 -05:00
|
|
|
|
;; With optional argument N, return a list containing all the
|
|
|
|
|
;; following elements.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(bold code underline)
|
|
|
|
|
(org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(mapcar #'car
|
2012-12-10 02:53:00 -05:00
|
|
|
|
(org-export-get-next-element
|
|
|
|
|
(org-element-map tree 'italic 'identity info t) info t)))))
|
|
|
|
|
;; When N is a positive integer, return a list containing up to
|
2012-12-08 12:57:10 -05:00
|
|
|
|
;; N following elements.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
'(bold code)
|
2012-12-10 02:53:00 -05:00
|
|
|
|
(org-test-with-parsed-data "_a_ /b/ *c* ~d~ _e_"
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(mapcar #'car
|
2012-12-08 12:57:10 -05:00
|
|
|
|
(org-export-get-next-element
|
|
|
|
|
(org-element-map tree 'italic 'identity info t) info 2))))))
|
2012-07-10 13:22:04 -04:00
|
|
|
|
|
|
|
|
|
(ert-deftest test-org-export/get-previous-element ()
|
|
|
|
|
"Test `org-export-get-previous-element' specifications."
|
|
|
|
|
;; Standard test.
|
|
|
|
|
(should
|
|
|
|
|
(equal "a "
|
|
|
|
|
(org-test-with-parsed-data "* Headline\na *b*"
|
|
|
|
|
(org-export-get-previous-element
|
2012-07-27 10:13:57 -04:00
|
|
|
|
(org-element-map tree 'bold 'identity info t) info))))
|
2012-07-10 13:22:04 -04:00
|
|
|
|
;; Return nil when no previous element.
|
|
|
|
|
(should-not
|
|
|
|
|
(org-test-with-parsed-data "* Headline\n*a* b"
|
|
|
|
|
(org-export-get-previous-element
|
2012-07-27 10:13:57 -04:00
|
|
|
|
(org-element-map tree 'bold 'identity info t) info)))
|
|
|
|
|
;; Non-exportable elements are ignored.
|
|
|
|
|
(should-not
|
|
|
|
|
(let ((org-export-with-timestamps nil))
|
|
|
|
|
(org-test-with-parsed-data "<2012-03-29 Thu> \alpha"
|
|
|
|
|
(org-export-get-previous-element
|
2012-10-31 07:28:21 -04:00
|
|
|
|
(org-element-map tree 'entity 'identity info t) info))))
|
|
|
|
|
;; Find previous element in secondary strings.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "* =verb= a"
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-previous-element
|
|
|
|
|
(org-element-map tree 'plain-text 'identity info t) info)))))
|
2013-11-10 19:54:01 -05:00
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "* =verb= /italic/"
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-previous-element
|
|
|
|
|
(org-element-map tree 'italic 'identity info t) info)))))
|
2012-10-31 07:28:21 -04:00
|
|
|
|
;; Find previous element in document keywords.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "#+TITLE: =verb= a"
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-previous-element
|
|
|
|
|
(org-element-map
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(plist-get info :title) 'plain-text 'identity info t)
|
|
|
|
|
info)))))
|
2012-10-31 07:28:21 -04:00
|
|
|
|
;; Find previous element in parsed affiliated keywords.
|
|
|
|
|
(should
|
|
|
|
|
(eq 'verbatim
|
|
|
|
|
(org-test-with-parsed-data "#+CAPTION: =verb= a\nParagraph"
|
|
|
|
|
(org-element-type
|
|
|
|
|
(org-export-get-previous-element
|
2012-12-08 12:57:10 -05:00
|
|
|
|
(org-element-map tree 'plain-text 'identity info t nil t) info)))))
|
|
|
|
|
;; With optional argument N, return a list containing up to
|
|
|
|
|
;; N previous elements.
|
2012-12-10 02:53:00 -05:00
|
|
|
|
(should
|
2013-02-25 17:16:14 -05:00
|
|
|
|
(equal '(underline italic bold)
|
2012-12-10 02:53:00 -05:00
|
|
|
|
(org-test-with-parsed-data "_a_ /b/ *c* ~d~"
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(mapcar #'car
|
2012-12-10 02:53:00 -05:00
|
|
|
|
(org-export-get-previous-element
|
|
|
|
|
(org-element-map tree 'code 'identity info t) info t)))))
|
|
|
|
|
;; When N is a positive integer, return a list containing up to
|
|
|
|
|
;; N previous elements.
|
2012-12-08 12:57:10 -05:00
|
|
|
|
(should
|
2013-02-25 17:16:14 -05:00
|
|
|
|
(equal '(italic bold)
|
2012-12-08 12:57:10 -05:00
|
|
|
|
(org-test-with-parsed-data "_a_ /b/ *c* ~d~"
|
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-14 17:21:37 -04:00
|
|
|
|
(mapcar #'car
|
2012-12-08 12:57:10 -05:00
|
|
|
|
(org-export-get-previous-element
|
|
|
|
|
(org-element-map tree 'code 'identity info t) info 2))))))
|
2012-07-10 13:22:04 -04:00
|
|
|
|
|
|
|
|
|
|
2013-01-27 17:11:34 -05:00
|
|
|
|
(provide 'test-ox)
|
2012-03-10 05:37:13 -05:00
|
|
|
|
;;; test-org-export.el end here
|