From 5b778a69407b0722c97d64691140e83b2a370dd6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 20 Dec 2013 21:28:45 +0100 Subject: [PATCH] ox: Fix ^:{} handling * lisp/ox.el (org-export--remove-uninterpreted): Fix ^:{} handling. * testing/lisp/test-ox.el (test-org-export/uninterpreted): Add test. --- lisp/ox.el | 2 +- testing/lisp/test-ox.el | 119 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 117 insertions(+), 4 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 5c42f16d5..5b845a417 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -2344,7 +2344,7 @@ tree is modified by side effect and returned by the function." (let ((sub/super-p (plist-get info :with-sub-superscript)) (bracketp (org-element-property :use-brackets-p blob))) (and (or (not sub/super-p) - (and (eq sub/super-p '{}) bracketp)) + (and (eq sub/super-p '{}) (not bracketp))) (append (list (concat (if (eq (org-element-type blob) 'subscript) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 940beeb00..329158b9a 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -541,9 +541,122 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" "Test if export process ignores commented trees." (should (equal "" - (let ((org-comment-string "COMMENT")) - (org-test-with-temp-text "* COMMENT Head1" - (org-export-as (org-test-default-backend))))))) + (org-test-with-temp-text "* COMMENT Head1" + (org-export-as (org-test-default-backend)))))) + +(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))))) + ;; 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))))) + ;; 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)))) + nil nil nil '(:with-sub-superscript {})))))) (ert-deftest test-org-export/export-scope () "Test all export scopes."