From 5c3b1765d219fc55edac393460128b9cd8d0d013 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 24 Jun 2013 20:55:24 +0200 Subject: [PATCH 2/2] Export back-ends: Apply changes to back-end structure * lisp/ox-html.el (org-html--format-toc-headline): Make use of anonymous back-ends. * lisp/ox-odt.el (org-odt-footnote-reference): Make use of anonymous back-ends. (org-odt-format-label, org-odt-toc, org-odt-format-headline--wrap): Use `org-export-with-backend' instead of `org-export-with-translations'. * contrib/lisp/ox-freemind.el (org-freemind--build-node-contents): Use `org-export-with-backend' instead of `org-export-with-translations'. --- contrib/lisp/ox-freemind.el | 11 +++--- lisp/ox-html.el | 19 ++++++----- lisp/ox-odt.el | 83 +++++++++++++++++++++++---------------------- 3 files changed, 57 insertions(+), 56 deletions(-) diff --git a/contrib/lisp/ox-freemind.el b/contrib/lisp/ox-freemind.el index 4e90eff..d31c65f 100644 --- a/contrib/lisp/ox-freemind.el +++ b/contrib/lisp/ox-freemind.el @@ -316,12 +316,11 @@ will result in following node: (element-contents (org-element-contents element)) (section (assoc 'section element-contents)) (section-contents - (let* ((translations - (nconc (list (cons 'section - (lambda (section contents info) - contents))) - (plist-get info :translate-alist)))) - (org-export-data-with-translations section translations info))) + (let ((backend (org-export-create-backend + :parent (org-export-backend-name + (plist-get info :back-end)) + :translations '(section . (lambda (e c i) c))))) + (org-export-data-with-backend section backend info))) (itemized-contents-p (let ((first-child-headline (org-element-map element-contents 'headline 'identity info t))) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 9ce73c4..0c997b4 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1983,16 +1983,17 @@ INFO is a plist used as a communication channel." headline-number "-")))) ;; Body. (concat section-number - (org-export-data-with-translations + (org-export-data-with-backend (org-export-get-alt-title headline info) - ;; Ignore any footnote-reference, link, - ;; radio-target and target in table of contents. - (append - '((footnote-reference . ignore) - (link . (lambda (link desc i) desc)) - (radio-target . (lambda (radio desc i) desc)) - (target . ignore)) - (org-export-backend-translate-table 'html)) + ;; Create an anonymous back-end that will ignore + ;; any footnote-reference, link, radio-target and + ;; target in table of contents. + (org-export-create-backend + :parent 'html + :transcoders '((footnote-reference . ignore) + (link . (lambda (object c i) c)) + (radio-target . (lambda (object c i) c)) + (target . ignore))) info) (and tags "   ") (org-html--tags tags))))) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 1cccdc6..abf88cd 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -1152,20 +1152,19 @@ See `org-odt--build-date-styles' for implementation details." (let* ((title (org-export-translate "Table of Contents" :utf-8 info)) (headlines (org-export-collect-headlines info (and (wholenump depth) depth))) - (translations (nconc (mapcar - (lambda (type) - (cons type (lambda (data contents info) - contents))) - (list 'radio-target)) - (plist-get info :translate-alist)))) + (backend (org-export-create-backend + :parent (org-export-backend-name + (plist-get info :back-end)) + :transcoders (mapcar + (lambda (type) (cons type (lambda (d c i) c))) + (list 'radio-target))))) (when headlines (concat (org-odt-begin-toc title depth) (mapconcat (lambda (headline) (let* ((entry (org-odt-format-headline--wrap - headline translations info - 'org-odt-format-toc-headline)) + headline backend info 'org-odt-format-toc-headline)) (level (org-export-get-relative-level headline info)) (style (format "Contents_20_%d" level))) (format "\n%s" @@ -1731,18 +1730,22 @@ CONTENTS is nil. INFO is a plist holding contextual information." (t (let* ((raw (org-export-get-footnote-definition footnote-reference info)) - (translations - (cons (cons 'paragraph - (lambda (p c i) - (org-odt--format-paragraph - p c "Footnote" "OrgFootnoteCenter" - "OrgFootnoteQuotations"))) - (org-export-backend-translate-table 'odt))) - (def (let ((def (org-trim (org-export-data-with-translations - raw translations info)))) - (if (eq (org-element-type raw) 'org-data) def - (format "\n%s" - "Footnote" def))))) + (def + (let ((def (org-trim + (org-export-data-with-backend + raw + (org-export-create-backend + :parent 'odt + :transcoders + '((paragraph . (lambda (p c i) + (org-odt--format-paragraph + p c "Footnote" + "OrgFootnoteCenter" + "OrgFootnoteQuotations"))))) + info)))) + (if (eq (org-element-type raw) 'org-data) def + (format "\n%s" + "Footnote" def))))) (funcall --format-footnote-definition n def)))))))) @@ -1775,13 +1778,12 @@ CONTENTS is nil. INFO is a plist holding contextual information." "%s" "OrgTag" tag)) tags " : ")))))) -(defun org-odt-format-headline--wrap (headline translations info - &optional format-function - &rest extra-keys) - "Transcode a HEADLINE element from Org to ODT. -CONTENTS holds the contents of the headline. INFO is a plist -holding contextual information." - (setq translations (or translations (plist-get info :translate-alist))) +(defun org-odt-format-headline--wrap (headline backend info + &optional format-function + &rest extra-keys) + "Transcode a HEADLINE element using BACKEND. +INFO is a plist holding contextual information." + (setq backend (or backend (plist-get info :back-end))) (let* ((level (+ (org-export-get-relative-level headline info))) (headline-number (org-export-get-headline-number headline info)) (section-number (and (org-export-numbered-headline-p headline info) @@ -1789,13 +1791,13 @@ holding contextual information." headline-number "."))) (todo (and (plist-get info :with-todo-keywords) (let ((todo (org-element-property :todo-keyword headline))) - (and todo (org-export-data-with-translations - todo translations info))))) + (and todo + (org-export-data-with-backend todo backend info))))) (todo-type (and todo (org-element-property :todo-type headline))) (priority (and (plist-get info :with-priority) (org-element-property :priority headline))) - (text (org-export-data-with-translations - (org-element-property :title headline) translations info)) + (text (org-export-data-with-backend + (org-element-property :title headline) backend info)) (tags (and (plist-get info :with-tags) (org-export-get-tags headline info))) (headline-label (concat "sec-" (mapconcat 'number-to-string @@ -1805,7 +1807,7 @@ holding contextual information." ((functionp org-odt-format-headline-function) (function* (lambda (todo todo-type priority text tags - &allow-other-keys) + &allow-other-keys) (funcall org-odt-format-headline-function todo todo-type priority text tags)))) (t 'org-odt-format-headline)))) @@ -1934,7 +1936,7 @@ holding contextual information." (let ((format-function (function* (lambda (todo todo-type priority text tags - &key contents &allow-other-keys) + &key contents &allow-other-keys) (funcall org-odt-format-inlinetask-function todo todo-type priority text tags contents))))) (org-odt-format-headline--wrap @@ -2149,15 +2151,14 @@ SHORT-CAPTION are strings." ;; will do. (short-caption (let ((short-caption (or short-caption caption)) - (translations (nconc (mapcar - (lambda (type) - (cons type (lambda (data contents info) - contents))) - org-element-all-objects) - (plist-get info :translate-alist)))) + (backend (org-export-create-backend + :parent (org-export-backend-name + (plist-get info :back-end)) + :transcoders + (mapcar (lambda (type) (cons type (lambda (o c i) c))) + org-element-all-objects)))) (when short-caption - (org-export-data-with-translations short-caption - translations info))))) + (org-export-data-with-backend short-caption backend info))))) (when (or label caption) (let* ((default-category (case (org-element-type element) -- 1.8.3.2