[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 4c646a6 03/14: ox: Introduce "raw" pseudo objects
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 4c646a6 03/14: ox: Introduce "raw" pseudo objects |
Date: |
Fri, 9 Jul 2021 02:57:16 -0400 (EDT) |
branch: externals/org
commit 4c646a6bdeba1a5a55fdb78991c009e46853618b
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
ox: Introduce "raw" pseudo objects
* lisp/ox.el (org-export-raw-string): New function
(org-export-data):
(org-export-with-backend): React to raw objects.
* testing/lisp/test-ox.el (test-org-export/raw-string): New test.
A raw object is a pseudo-object (i.e., special object type that exists
only during export) with the property of being exported as-is, with no
processing from an export back-end.
It is particularly useful to add contents to, or pre-process objects
from, a parse tree.
---
lisp/ox.el | 18 ++++++++++++++++--
testing/lisp/test-ox.el | 11 +++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 6ec9b62..af7626b 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -1881,6 +1881,8 @@ Return a string."
(cond
;; Ignored element/object.
((memq data (plist-get info :ignore-list)) nil)
+ ;; Raw code.
+ ((eq type 'raw) (car (org-element-contents data)))
;; Plain text.
((eq type 'plain-text)
(org-export-filter-apply-functions
@@ -1947,7 +1949,7 @@ Return a string."
data
(cond
((not results) "")
- ((memq type '(org-data plain-text nil)) results)
+ ((memq type '(nil org-data plain-text raw)) results)
;; Append the same white space between elements or objects
;; as in the original buffer, and call appropriate filters.
(t
@@ -3668,7 +3670,8 @@ the communication channel used for export, as a plist."
(when (symbolp backend) (setq backend (org-export-get-backend backend)))
(org-export-barf-if-invalid-backend backend)
(let ((type (org-element-type data)))
- (when (memq type '(nil org-data)) (error "No foreign transcoder
available"))
+ (when (memq type '(nil org-data raw))
+ (error "No foreign transcoder available"))
(let* ((all-transcoders (org-export-get-all-transcoders backend))
(transcoder (cdr (assq type all-transcoders))))
(unless (functionp transcoder) (error "No foreign transcoder available"))
@@ -4562,6 +4565,17 @@ objects of the same type."
((funcall predicate el info) (cl-incf counter) nil)))
info 'first-match)))))
+;;;; For Raw objects
+;;
+;; `org-export-raw-string' builds a pseudo-object out of a string
+;; that any export back-end returns as-is.
+
+(defun org-export-raw-string (s)
+ "Return a raw object containing string S.
+A raw string is exported as-is, with no additional processing
+from the export back-end."
+ (unless (stringp s) (error "Wrong raw contents type: %S" s))
+ (org-element-create 'raw nil s))
;;;; For Src-Blocks
;;
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 34b2d20..3f39645 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -3812,6 +3812,17 @@ Another text. (ref:text)
(org-export-data-with-backend paragraph backend nil)))))
+;;; 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)))))
+
+
;;; Src-block and example-block
(ert-deftest test-org-export/unravel-code ()
- [elpa] externals/org updated (fdb98a4 -> 971c135), ELPA Syncer, 2021/07/09
- [elpa] externals/org 622f9fa 01/14: org: Use crm for completing tags, ELPA Syncer, 2021/07/09
- [elpa] externals/org 4c646a6 03/14: ox: Introduce "raw" pseudo objects,
ELPA Syncer <=
- [elpa] externals/org e844a6f 05/14: oc: Add Org Cite library, ELPA Syncer, 2021/07/09
- [elpa] externals/org fed07be 02/14: element: Add citation support, ELPA Syncer, 2021/07/09
- [elpa] externals/org a922b17 04/14: faces: Add `org-cite' and `org-cite-key' faces, ELPA Syncer, 2021/07/09
- [elpa] externals/org 4415635 06/14: oc-basic: Implement `basic' citation processor, ELPA Syncer, 2021/07/09
- [elpa] externals/org a20a3ad 08/14: Plug citations into `org-open-at-point', ELPA Syncer, 2021/07/09
- [elpa] externals/org d6cb37f 12/14: oc-natbib: Implement `natbib' citation processor, ELPA Syncer, 2021/07/09
- [elpa] externals/org 2c2b720 07/14: ox: Plug citations into export process, ELPA Syncer, 2021/07/09
- [elpa] externals/org 524d8fe 09/14: Plug citations into fontification process, ELPA Syncer, 2021/07/09
- [elpa] externals/org ef79a8d 10/14: org-keys: Plug citation insertion, ELPA Syncer, 2021/07/09
- [elpa] externals/org c089c23 11/14: Allow `org-edit-special' to open "bibliography" files, ELPA Syncer, 2021/07/09