>From bae307895b934328f10f003758446b11cbc13beb Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 27 Sep 2015 10:59:20 +0200 Subject: [PATCH] ox: Implement draft mode * lisp/ox.el (org-export-as-draft): New variable. (org-export-dispatch-use-expert-ui): Document new export option. (org-export-data): Ignore user errors when in draft mode. (org-export-as): Add new optional argument to toggle draft mode. Ignore unknown macros. (org-export-string-as): (org-export-to-buffer): (org-export-to-file): Handle signature change. (org-export-dispatch): (org-export--dispatch-ui): (org-export--dispatch-action): Provide a mean to toggle draft mode. * lisp/ox-ascii.el (ascii): (org-ascii-export-as-ascii): (org-ascii-export-to-ascii): * lisp/ox-beamer.el (beamer): (org-beamer-export-as-latex): (org-beamer-export-to-latex): (org-beamer-export-to-pdf): * lisp/ox-html.el (html): (org-html-export-as-html): * lisp/ox-icalendar.el (icalendar): * lisp/ox-latex.el (latex): (org-latex-export-as-latex): (org-latex-export-to-latex): (org-latex-export-to-pdf): * lisp/ox-man.el (man): (org-man-export-to-man): (org-man-export-to-pdf): * lisp/ox-md.el (md): (org-md-export-as-markdown): (org-md-export-to-markdown): * lisp/ox-odt.el (odt): (org-odt-export-to-odt): * lisp/ox-org.el (org): (org-org-export-to-org): * lisp/ox-publish.el (org-publish-org-to): * lisp/ox-texinfo.el (texinfo): (org-texinfo-export-to-texinfo): (org-texinfo-export-to-info): Handle signature change. * testing/lisp/test-ox.el (test-org-export/handle-options): (test-org-export/with-timestamps): (test-org-export/uninterpreted): (test-org-export/expand-macro): (test-org-export/footnote-first-reference-p): (test-org-export/handle-inlinetasks): Update tests. --- lisp/ox-ascii.el | 39 +++--- lisp/ox-beamer.el | 21 +++- lisp/ox-html.el | 11 +- lisp/ox-icalendar.el | 4 +- lisp/ox-latex.el | 26 ++-- lisp/ox-man.el | 16 ++- lisp/ox-md.el | 25 ++-- lisp/ox-odt.el | 21 ++-- lisp/ox-org.el | 13 +- lisp/ox-publish.el | 2 +- lisp/ox-texinfo.el | 20 ++-- lisp/ox.el | 311 ++++++++++++++++++++++++++++-------------------- testing/lisp/test-ox.el | 123 +++++++++---------- 13 files changed, 376 insertions(+), 256 deletions(-) diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el index 5cc70bd..b50cebb 100644 --- a/lisp/ox-ascii.el +++ b/lisp/ox-ascii.el @@ -97,23 +97,23 @@ :menu-entry '(?t "Export to Plain Text" ((?A "As ASCII buffer" - (lambda (a s v b) - (org-ascii-export-as-ascii a s v b '(:ascii-charset ascii)))) + (lambda (a s v b d) + (org-ascii-export-as-ascii a s v b d '(:ascii-charset ascii)))) (?a "As ASCII file" - (lambda (a s v b) - (org-ascii-export-to-ascii a s v b '(:ascii-charset ascii)))) + (lambda (a s v b d) + (org-ascii-export-to-ascii a s v b d '(:ascii-charset ascii)))) (?L "As Latin1 buffer" - (lambda (a s v b) - (org-ascii-export-as-ascii a s v b '(:ascii-charset latin1)))) + (lambda (a s v b d) + (org-ascii-export-as-ascii a s v b d '(:ascii-charset latin1)))) (?l "As Latin1 file" - (lambda (a s v b) - (org-ascii-export-to-ascii a s v b '(:ascii-charset latin1)))) + (lambda (a s v b d) + (org-ascii-export-to-ascii a s v b d '(:ascii-charset latin1)))) (?U "As UTF-8 buffer" - (lambda (a s v b) - (org-ascii-export-as-ascii a s v b '(:ascii-charset utf-8)))) + (lambda (a s v b d) + (org-ascii-export-as-ascii a s v b d '(:ascii-charset utf-8)))) (?u "As UTF-8 file" - (lambda (a s v b) - (org-ascii-export-to-ascii a s v b '(:ascii-charset utf-8)))))) + (lambda (a s v b d) + (org-ascii-export-to-ascii a s v b d '(:ascii-charset utf-8)))))) :filters-alist '((:filter-headline . org-ascii-filter-headline-blank-lines) (:filter-parse-tree org-ascii-filter-paragraph-spacing org-ascii-filter-comment-spacing) @@ -2023,7 +2023,7 @@ a communication channel." ;;;###autoload (defun org-ascii-export-as-ascii - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to a text buffer. If narrowing is active in the current buffer, only export its @@ -2045,6 +2045,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, strip title and table of contents from output. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -2054,11 +2057,12 @@ will be displayed when `org-export-show-temporary-export-buffer' is non-nil." (interactive) (org-export-to-buffer 'ascii "*Org ASCII Export*" - async subtreep visible-only body-only ext-plist (lambda () (text-mode)))) + async subtreep visible-only body-only draft ext-plist + (lambda () (text-mode)))) ;;;###autoload (defun org-ascii-export-to-ascii - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to a text file. If narrowing is active in the current buffer, only export its @@ -2080,6 +2084,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, strip title and table of contents from output. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -2088,7 +2095,7 @@ Return output file's name." (interactive) (let ((file (org-export-output-file-name ".txt" subtreep))) (org-export-to-file 'ascii file - async subtreep visible-only body-only ext-plist))) + async subtreep visible-only body-only draft ext-plist))) ;;;###autoload (defun org-ascii-publish-to-ascii (plist filename pub-dir) diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index 3119bd4..f99182a 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -238,9 +238,9 @@ Return overlay specification, as a string, or nil." (?b "As LaTeX file (Beamer)" org-beamer-export-to-latex) (?P "As PDF file (Beamer)" org-beamer-export-to-pdf) (?O "As PDF file and open (Beamer)" - (lambda (a s v b) - (if a (org-beamer-export-to-pdf t s v b) - (org-open-file (org-beamer-export-to-pdf nil s v b))))))) + (lambda (a s v b d) + (if a (org-beamer-export-to-pdf t s v b d) + (org-open-file (org-beamer-export-to-pdf nil s v b d))))))) :options-alist '((:headline-levels nil "H" org-beamer-frame-level) (:latex-class "LATEX_CLASS" nil "beamer" t) @@ -999,7 +999,7 @@ value." ;;;###autoload (defun org-beamer-export-as-latex - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer as a Beamer buffer. If narrowing is active in the current buffer, only export its @@ -1021,6 +1021,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -1034,7 +1037,7 @@ is non-nil." ;;;###autoload (defun org-beamer-export-to-latex - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer as a Beamer presentation (tex). If narrowing is active in the current buffer, only export its @@ -1056,6 +1059,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -1068,7 +1074,7 @@ Return output file's name." ;;;###autoload (defun org-beamer-export-to-pdf - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer as a Beamer presentation (PDF). If narrowing is active in the current buffer, only export its @@ -1090,6 +1096,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 960bee8..fa5a982 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -104,9 +104,9 @@ ((?H "As HTML buffer" org-html-export-as-html) (?h "As HTML file" org-html-export-to-html) (?o "As HTML file and open" - (lambda (a s v b) - (if a (org-html-export-to-html t s v b) - (org-open-file (org-html-export-to-html nil s v b))))))) + (lambda (a s v b d) + (if a (org-html-export-to-html t s v b d) + (org-open-file (org-html-export-to-html nil s v b d))))))) :options-alist '((:html-doctype "HTML_DOCTYPE" nil org-html-doctype) (:html-container "HTML_CONTAINER" nil org-html-container-element) @@ -3505,7 +3505,7 @@ contextual information." ;;;###autoload (defun org-html-export-as-html - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to an HTML buffer. If narrowing is active in the current buffer, only export its @@ -3527,6 +3527,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\" and \"\" tags. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index aefddf8..d5fc97e 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -276,9 +276,9 @@ re-read the iCalendar file.") '(?c "Export to iCalendar" ((?f "Current file" org-icalendar-export-to-ics) (?a "All agenda files" - (lambda (a s v b) (org-icalendar-export-agenda-files a))) + (lambda (a &rest _) (org-icalendar-export-agenda-files a))) (?c "Combine all agenda files" - (lambda (a s v b) (org-icalendar-combine-agenda-files a)))))) + (lambda (a &rest _) (org-icalendar-combine-agenda-files a)))))) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 1840a54..73968a0 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -97,9 +97,9 @@ (?l "As LaTeX file" org-latex-export-to-latex) (?p "As PDF file" org-latex-export-to-pdf) (?o "As PDF file and open" - (lambda (a s v b) - (if a (org-latex-export-to-pdf t s v b) - (org-open-file (org-latex-export-to-pdf nil s v b))))))) + (lambda (a s v b d) + (if a (org-latex-export-to-pdf t s v b d) + (org-open-file (org-latex-export-to-pdf nil s v b d))))))) :filters-alist '((:filter-options . org-latex-math-block-options-filter) (:filter-parse-tree org-latex-math-block-tree-filter org-latex-matrices-tree-filter)) @@ -3310,7 +3310,7 @@ contextual information." ;;;###autoload (defun org-latex-export-as-latex - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer as a LaTeX buffer. If narrowing is active in the current buffer, only export its @@ -3332,6 +3332,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -3341,7 +3344,8 @@ will be displayed when `org-export-show-temporary-export-buffer' is non-nil." (interactive) (org-export-to-buffer 'latex "*Org LATEX Export*" - async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode)))) + async subtreep visible-only body-only draft ext-plist + (lambda () (LaTeX-mode)))) ;;;###autoload (defun org-latex-convert-region-to-latex () @@ -3354,7 +3358,7 @@ command to convert it." ;;;###autoload (defun org-latex-export-to-latex - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to a LaTeX file. If narrowing is active in the current buffer, only export its @@ -3376,17 +3380,20 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings." (interactive) (let ((outfile (org-export-output-file-name ".tex" subtreep))) (org-export-to-file 'latex outfile - async subtreep visible-only body-only ext-plist))) + async subtreep visible-only body-only draft ext-plist))) ;;;###autoload (defun org-latex-export-to-pdf - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to LaTeX then process through to PDF. If narrowing is active in the current buffer, only export its @@ -3408,6 +3415,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. diff --git a/lisp/ox-man.el b/lisp/ox-man.el index a5d0d49..edb4e15 100644 --- a/lisp/ox-man.el +++ b/lisp/ox-man.el @@ -104,9 +104,9 @@ ((?m "As MAN file" org-man-export-to-man) (?p "As PDF file" org-man-export-to-pdf) (?o "As PDF file and open" - (lambda (a s v b) - (if a (org-man-export-to-pdf t s v b) - (org-open-file (org-man-export-to-pdf nil s v b))))))) + (lambda (a s v b d) + (if a (org-man-export-to-pdf t s v b d) + (org-open-file (org-man-export-to-pdf nil s v b d))))))) :options-alist '((:man-class "MAN_CLASS" nil nil t) (:man-class-options "MAN_CLASS_OPTIONS" nil nil t) @@ -1115,7 +1115,7 @@ contextual information." ;;; Interactive functions (defun org-man-export-to-man - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to a Man file. If narrowing is active in the current buffer, only export its @@ -1137,6 +1137,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only the body without any markers. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -1148,7 +1151,7 @@ Return output file's name." async subtreep visible-only body-only ext-plist))) (defun org-man-export-to-pdf - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to Groff then process through to PDF. If narrowing is active in the current buffer, only export its @@ -1170,6 +1173,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write between markers. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 602c149..502a15b 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -60,12 +60,13 @@ This variable can be set to either `atx' or `setext'." :menu-entry '(?m "Export to Markdown" ((?M "To temporary buffer" - (lambda (a s v b) (org-md-export-as-markdown a s v))) - (?m "To file" (lambda (a s v b) (org-md-export-to-markdown a s v))) + (lambda (a s v b d) (org-md-export-as-markdown a s v nil d))) + (?m "To file" + (lambda (a s v b d) (org-md-export-to-markdown a s v nil d))) (?o "To file and open" - (lambda (a s v b) - (if a (org-md-export-to-markdown t s v) - (org-open-file (org-md-export-to-markdown nil s v))))))) + (lambda (a s v b d) + (if a (org-md-export-to-markdown t s v nil d) + (org-open-file (org-md-export-to-markdown nil s v nil d))))))) :translate-alist '((bold . org-md-bold) (code . org-md-verbatim) (example-block . org-md-example-block) @@ -487,7 +488,7 @@ as a communication channel." ;;; Interactive function ;;;###autoload -(defun org-md-export-as-markdown (&optional async subtreep visible-only) +(defun org-md-export-as-markdown (&optional async subtreep visible-only draft) "Export current buffer to a Markdown buffer. If narrowing is active in the current buffer, only export its @@ -506,12 +507,15 @@ first. When optional argument VISIBLE-ONLY is non-nil, don't export contents of hidden elements. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + Export is done in a buffer named \"*Org MD Export*\", which will be displayed when `org-export-show-temporary-export-buffer' is non-nil." (interactive) (org-export-to-buffer 'md "*Org MD Export*" - async subtreep visible-only nil nil (lambda () (text-mode)))) + async subtreep visible-only nil nil nil (lambda () (text-mode)))) ;;;###autoload (defun org-md-convert-region-to-md () @@ -524,7 +528,7 @@ this command to convert it." ;;;###autoload -(defun org-md-export-to-markdown (&optional async subtreep visible-only) +(defun org-md-export-to-markdown (&optional async subtreep visible-only draft) "Export current buffer to a Markdown file. If narrowing is active in the current buffer, only export its @@ -543,10 +547,13 @@ first. When optional argument VISIBLE-ONLY is non-nil, don't export contents of hidden elements. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + Return output file's name." (interactive) (let ((outfile (org-export-output-file-name ".md" subtreep))) - (org-export-to-file 'md outfile async subtreep visible-only))) + (org-export-to-file 'md outfile async subtreep visible-only nil draft))) ;;;###autoload (defun org-md-publish-to-md (plist filename pub-dir) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 75353a0..76f105e 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -92,9 +92,10 @@ '(?o "Export to ODT" ((?o "As ODT file" org-odt-export-to-odt) (?O "As ODT file and open" - (lambda (a s v b) - (if a (org-odt-export-to-odt t s v) - (org-open-file (org-odt-export-to-odt nil s v) 'system)))))) + (lambda (a s v b d) + (if a (org-odt-export-to-odt t s v nil d) + (org-open-file + (org-odt-export-to-odt nil s v nil d) 'system)))))) :options-alist '((:odt-styles-file "ODT_STYLES_FILE" nil nil t) (:description "DESCRIPTION" nil nil newline) @@ -4210,7 +4211,8 @@ formula file." ;;;; Export to OpenDocument Text ;;;###autoload -(defun org-odt-export-to-odt (&optional async subtreep visible-only ext-plist) +(defun org-odt-export-to-odt + (&optional async subtreep visible-only draft ext-plist) "Export current buffer to a ODT file. If narrowing is active in the current buffer, only export its @@ -4229,6 +4231,9 @@ first. When optional argument VISIBLE-ONLY is non-nil, don't export contents of hidden elements. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -4256,8 +4261,9 @@ Return output file's name." (let ((nxml-auto-insert-xml-declaration-flag nil)) (find-file-noselect (concat org-odt-zip-dir "content.xml") t)))) - (output (org-export-as - 'odt ,subtreep ,visible-only nil ,ext-plist))) + (output + (org-export-as + 'odt ,subtreep ,visible-only nil ,draft ,ext-plist))) (with-current-buffer out-buf (erase-buffer) (insert output))))))) @@ -4271,7 +4277,8 @@ Return output file's name." ;; styles. (hfy-user-sheet-assoc nil)) ;; Initialize content.xml and kick-off the export process. - (let ((output (org-export-as 'odt subtreep visible-only nil ext-plist)) + (let ((output + (org-export-as 'odt subtreep visible-only nil draft ext-plist)) (out-buf (progn (require 'nxml-mode) (let ((nxml-auto-insert-xml-declaration-flag nil)) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index b395577..c19147b 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -105,9 +105,9 @@ setting of `org-html-htmlize-output-type' is `css'." ((?O "As Org buffer" org-org-export-as-org) (?o "As Org file" org-org-export-to-org) (?v "As Org file and open" - (lambda (a s v b) - (if a (org-org-export-to-org t s v b) - (org-open-file (org-org-export-to-org nil s v b)))))))) + (lambda (a s v b d) + (if a (org-org-export-to-org t s v b d) + (org-open-file (org-org-export-to-org nil s v b d)))))))) (defun org-org-identity (blob contents info) "Transcode BLOB element or object back into Org syntax. @@ -244,7 +244,7 @@ non-nil." ;;;###autoload (defun org-org-export-to-org - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to an org file. If narrowing is active in the current buffer, only export its @@ -266,6 +266,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, strip document keywords from output. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -274,7 +277,7 @@ Return output file name." (interactive) (let ((outfile (org-export-output-file-name ".org" subtreep))) (org-export-to-file 'org outfile - async subtreep visible-only body-only ext-plist))) + async subtreep visible-only body-only draft ext-plist))) ;;;###autoload (defun org-org-publish-to-org (plist filename pub-dir) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 20cacf9..79fffc9 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -582,7 +582,7 @@ Return output file name." (org-export-output-file-name extension nil pub-dir)) (body-p (plist-get plist :body-only))) (org-export-to-file backend output-file - nil nil nil body-p + nil nil nil body-p nil ;; Add `org-publish--collect-references' and ;; `org-publish-collect-index' to final output ;; filters. The latter isn't dependent on diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index c8c6554..0526eeb 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -88,9 +88,9 @@ ((?t "As TEXI file" org-texinfo-export-to-texinfo) (?i "As INFO file" org-texinfo-export-to-info) (?o "As INFO file and open" - (lambda (a s v b) - (if a (org-texinfo-export-to-info t s v b) - (org-open-file (org-texinfo-export-to-info nil s v b))))))) + (lambda (a s v b d) + (if a (org-texinfo-export-to-info t s v b d) + (org-open-file (org-texinfo-export-to-info nil s v b d))))))) :options-alist '((:texinfo-filename "TEXINFO_FILENAME" nil nil t) (:texinfo-class "TEXINFO_CLASS" nil org-texinfo-default-class t) @@ -1483,7 +1483,7 @@ contextual information." ;;; Interactive functions (defun org-texinfo-export-to-texinfo - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to a Texinfo file. If narrowing is active in the current buffer, only export its @@ -1505,6 +1505,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -1514,10 +1517,10 @@ Return output file's name." (let ((outfile (org-export-output-file-name ".texi" subtreep)) (org-export-coding-system org-texinfo-coding-system)) (org-export-to-file 'texinfo outfile - async subtreep visible-only body-only ext-plist))) + async subtreep visible-only body-only draft ext-plist))) (defun org-texinfo-export-to-info - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) "Export current buffer to Texinfo then process through to INFO. If narrowing is active in the current buffer, only export its @@ -1539,6 +1542,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only write code between \"\\begin{document}\" and \"\\end{document}\". +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -1551,7 +1557,7 @@ Return INFO file's name." (let ((outfile (org-export-output-file-name ".texi" subtreep)) (org-export-coding-system org-texinfo-coding-system)) (org-export-to-file 'texinfo outfile - async subtreep visible-only body-only ext-plist + async subtreep visible-only body-only draft ext-plist (lambda (file) (org-texinfo-compile file))))) ;;;###autoload diff --git a/lisp/ox.el b/lisp/ox.el index 0d6711c..c3d54cd 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -857,6 +857,16 @@ automatically. But you can retrieve them with \\[org-export-stack]." :package-version '(Org . "8.0") :type 'boolean) +(defcustom org-export-as-draft nil + "Non-nil means export is allowed to produce a draft. +When in draft mode, invalid links and macros do not throw an +error and stop export process. Instead, they are marked as +invalid in the produced output." + :group 'org-export-general + :version "25.1" + :package-version '(Org . "8.4") + :type 'boolean) + (defcustom org-export-async-init-file nil "File used to initialize external export process. @@ -882,9 +892,9 @@ for current export scope is added to the prompt (\"b\" when output is restricted to body only, \"s\" when it is restricted to the current subtree, \"v\" when only visible elements are considered for export, \"f\" when publishing functions should be -passed the FORCE argument and \"a\" when the export should be -asynchronous). Also, [?] allows to switch back to standard -mode." +passed the FORCE argument, \"a\" when the export should be +asynchronous and \"d\" when document is to be exported as +a draft). Also, [?] allows to switch back to standard mode." :group 'org-export-general :version "24.4" :package-version '(Org . "8.0") @@ -1851,91 +1861,107 @@ string. INFO is a plist holding export options. Return a string." (or (gethash data (plist-get info :exported-data)) - (let* ((type (org-element-type data)) - (results - (cond - ;; Ignored element/object. - ((memq data (plist-get info :ignore-list)) nil) - ;; Plain text. - ((eq type 'plain-text) - (org-export-filter-apply-functions - (plist-get info :filter-plain-text) - (let ((transcoder (org-export-transcoder data info))) - (if transcoder (funcall transcoder data info) data)) - info)) - ;; Secondary string. - ((not type) - (mapconcat (lambda (obj) (org-export-data obj info)) data "")) - ;; Element/Object without contents or, as a special - ;; case, headline with archive tag and archived trees - ;; restricted to title only. - ((or (not (org-element-contents data)) - (and (eq type 'headline) - (eq (plist-get info :with-archived-trees) 'headline) - (org-element-property :archivedp data))) - (let ((transcoder (org-export-transcoder data info))) - (or (and (functionp transcoder) - (funcall transcoder data nil info)) - ;; Export snippets never return a nil value so - ;; that white spaces following them are never - ;; ignored. - (and (eq type 'export-snippet) "")))) - ;; Element/Object with contents. - (t - (let ((transcoder (org-export-transcoder data info))) - (when transcoder - (let* ((greaterp (memq type org-element-greater-elements)) - (objectp - (and (not greaterp) - (memq type org-element-recursive-objects))) - (contents - (mapconcat - (lambda (element) (org-export-data element info)) - (org-element-contents - (if (or greaterp objectp) data - ;; Elements directly containing - ;; objects must have their indentation - ;; normalized first. - (org-element-normalize-contents - data - ;; When normalizing contents of the - ;; first paragraph in an item or - ;; a footnote definition, ignore - ;; first line's indentation: there is - ;; none and it might be misleading. - (when (eq type 'paragraph) - (let ((parent (org-export-get-parent data))) - (and - (eq (car (org-element-contents parent)) - data) - (memq (org-element-type parent) - '(footnote-definition item)))))))) - ""))) - (funcall transcoder data - (if (not greaterp) contents - (org-element-normalize-string contents)) - info)))))))) - ;; Final result will be memoized before being returned. - (puthash - data - (cond - ((not results) "") - ((memq type '(org-data plain-text nil)) results) - ;; Append the same white space between elements or objects - ;; as in the original buffer, and call appropriate filters. - (t - (let ((results + (cl-macrolet ((ignore-errors-in-draft + (&rest body) + `(condition-case err + (progn ,@body) + (user-error + (if (memq 'draft (plist-get info :export-options)) + (org-export-data + (format "[INVALID %s]" + (upcase (symbol-name type))) + info) + (user-error (nth 1 err))))))) + (let* ((type (org-element-type data)) + (results + (cond + ;; Ignored element/object. + ((memq data (plist-get info :ignore-list)) nil) + ;; Plain text. + ((eq type 'plain-text) (org-export-filter-apply-functions - (plist-get info (intern (format ":filter-%s" type))) - (let ((post-blank (or (org-element-property :post-blank data) - 0))) - (if (memq type org-element-all-elements) - (concat (org-element-normalize-string results) - (make-string post-blank ?\n)) - (concat results (make-string post-blank ?\s)))) - info))) - results))) - (plist-get info :exported-data))))) + (plist-get info :filter-plain-text) + (let ((transcoder (org-export-transcoder data info))) + (if transcoder (funcall transcoder data info) data)) + info)) + ;; Secondary string. + ((not type) + (mapconcat (lambda (o) (org-export-data o info)) data "")) + ;; Element/Object without contents or, as a special + ;; case, headline with archive tag and archived trees + ;; restricted to title only. + ((or (not (org-element-contents data)) + (and (eq type 'headline) + (eq (plist-get info :with-archived-trees) + 'headline) + (org-element-property :archivedp data))) + (let ((transcoder (org-export-transcoder data info))) + (or (and (functionp transcoder) + (ignore-errors-in-draft + (funcall transcoder data nil info))) + ;; Export snippets never return a nil value so + ;; that white spaces following them are never + ;; ignored. + (and (eq type 'export-snippet) "")))) + ;; Element/Object with contents. + (t + (let ((transcoder (org-export-transcoder data info))) + (when transcoder + (let* ((greaterp + (memq type org-element-greater-elements)) + (objectp + (and (not greaterp) + (memq type org-element-recursive-objects))) + (contents + (mapconcat + (lambda (e) (org-export-data e info)) + (org-element-contents + (if (or greaterp objectp) data + ;; Elements directly containing + ;; objects must have their + ;; indentation normalized first. + (org-element-normalize-contents + data + ;; When normalizing contents of the + ;; first paragraph in an item or + ;; a footnote definition, ignore + ;; first line's indentation: there + ;; is none and it might be + ;; misleading. + (when (eq type 'paragraph) + (let ((p (org-export-get-parent data))) + (and (eq (car (org-element-contents p)) + data) + (memq (org-element-type p) + '(footnote-definition + item)))))))) + ""))) + (ignore-errors-in-draft + (funcall transcoder data + (if (not greaterp) contents + (org-element-normalize-string contents)) + info))))))))) + ;; Final result will be memoized before being returned. + (puthash + data + (cond + ((not results) "") + ((memq type '(org-data plain-text nil)) results) + ;; Append the same white space between elements or objects + ;; as in the original buffer, and call appropriate filters. + (t + (let ((results + (org-export-filter-apply-functions + (plist-get info (intern (format ":filter-%s" type))) + (let ((post-blank + (or (org-element-property :post-blank data) 0))) + (if (memq type org-element-all-elements) + (concat (org-element-normalize-string results) + (make-string post-blank ?\n)) + (concat results (make-string post-blank ?\s)))) + info))) + results))) + (plist-get info :exported-data)))))) (defun org-export-data-with-backend (data backend info) "Convert DATA into BACKEND format. @@ -2866,7 +2892,7 @@ not, are considered." ;;;###autoload (defun org-export-as - (backend &optional subtreep visible-only body-only ext-plist) + (backend &optional subtreep visible-only body-only draft ext-plist) "Transcode current Org buffer into BACKEND code. BACKEND is either an export back-end, as returned by, e.g., @@ -2888,6 +2914,9 @@ contents of hidden elements. When optional argument BODY-ONLY is non-nil, only return body code, without surrounding template. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + Optional argument EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -2915,7 +2944,8 @@ Return code as a string." (delq nil (list (and subtreep 'subtree) (and visible-only 'visible-only) - (and body-only 'body-only)))) + (and body-only 'body-only) + (and draft 'draft)))) (org-export--get-buffer-attributes))) (parsed-keywords (delq nil @@ -2986,8 +3016,25 @@ Return code as a string." (cons "email" (org-element-interpret-data (plist-get info :email))) (cons "title" (org-element-interpret-data (plist-get info :title))) (cons "results" "$1")) - 'finalize + (and (not draft) 'finalize) parsed-keywords) + ;; In draft mode, macros are left as-is in the buffer. + ;; However, no export back-end handles them so they will end + ;; up being silently ignored. As a consequence, replace them + ;; with more prominent markup. + (when draft + (save-excursion + (goto-char (point-min)) + (while (search-forward "{{{" nil t) + (let ((object (org-element-context))) + (when (eq (org-element-type object) 'macro) + (delete-region + (org-element-property :begin object) + (progn (goto-char (org-element-property :end object)) + (skip-chars-backward " \t") + (point))) + (insert (format "[INVALID MACRO: %s]" + (org-element-property :key object)))))))) ;; Parse buffer. (setq tree (org-element-parse-buffer nil visible-only)) ;; Merge footnote definitions outside scope into parse tree. @@ -3030,7 +3077,7 @@ Return code as a string." info)))))))) ;;;###autoload -(defun org-export-string-as (string backend &optional body-only ext-plist) +(defun org-export-string-as (string backend &optional body-only draft ext-plist) "Transcode STRING into BACKEND code. BACKEND is either an export back-end, as returned by, e.g., @@ -3040,6 +3087,9 @@ a registered back-end. When optional argument BODY-ONLY is non-nil, only return body code, without preamble nor postamble. +When optional argument DRAFT is non-nil, ignore user +errors (e.g., invalid links) during the process. + Optional argument EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings. @@ -3048,7 +3098,7 @@ Return code as a string." (with-temp-buffer (insert string) (let ((org-inhibit-startup t)) (org-mode)) - (org-export-as backend nil nil body-only ext-plist))) + (org-export-as backend nil nil body-only draft ext-plist))) ;;;###autoload (defun org-export-replace-region-by (backend) @@ -5754,9 +5804,9 @@ and `org-export-to-file' for more specialized functions." ;;;###autoload (defun org-export-to-buffer - (backend buffer - &optional async subtreep visible-only body-only ext-plist - post-process) + (backend buffer + &optional async subtreep visible-only body-only draft + ext-plist post-process) "Call `org-export-as' with output to a specified buffer. BACKEND is either an export back-end, as returned by, e.g., @@ -5772,7 +5822,7 @@ through the `org-export-stack' interface. When ASYNC is nil, the buffer is displayed if `org-export-show-temporary-export-buffer' is non-nil. -Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and +Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY, DRAFT and EXT-PLIST are similar to those used in `org-export-as', which see. @@ -5782,10 +5832,11 @@ from BUFFER, with point at its beginning. Export back-ends can use it to set a major mode there, e.g, (defun org-latex-export-as-latex - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) (interactive) (org-export-to-buffer \\='latex \"*Org LATEX Export*\" - async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode)))) + async subtreep visible-only body-only draft ext-plist + (lambda () (LaTeX-mode)))) This function returns BUFFER." (declare (indent 2)) @@ -5800,9 +5851,10 @@ This function returns BUFFER." (org-export-add-to-stack (current-buffer) ',backend) (ignore-errors (funcall ,post-process)))) `(org-export-as - ',backend ,subtreep ,visible-only ,body-only ',ext-plist)) + ',backend ,subtreep ,visible-only ,body-only ,draft ',ext-plist)) (let ((output - (org-export-as backend subtreep visible-only body-only ext-plist)) + (org-export-as + backend subtreep visible-only body-only draft ext-plist)) (buffer (get-buffer-create buffer)) (encoding buffer-file-coding-system)) (when (and (org-string-nw-p output) (org-export--copy-to-kill-ring-p)) @@ -5819,8 +5871,8 @@ This function returns BUFFER." ;;;###autoload (defun org-export-to-file - (backend file &optional async subtreep visible-only body-only ext-plist - post-process) + (backend file &optional async subtreep visible-only body-only draft + ext-plist post-process) "Call `org-export-as' with output to a specified file. BACKEND is either an export back-end, as returned by, e.g., @@ -5832,7 +5884,7 @@ A non-nil optional argument ASYNC means the process should happen asynchronously. The resulting buffer will then be accessible through the `org-export-stack' interface. -Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and +Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY, DRAFT and EXT-PLIST are similar to those used in `org-export-as', which see. @@ -5842,11 +5894,11 @@ has to return a file name, or nil. Export back-ends can use this to send the output file through additional processing, e.g, (defun org-latex-export-to-latex - (&optional async subtreep visible-only body-only ext-plist) + (&optional async subtreep visible-only body-only draft ext-plist) (interactive) (let ((outfile (org-export-output-file-name \".tex\" subtreep))) (org-export-to-file \\='latex outfile - async subtreep visible-only body-only ext-plist + async subtreep visible-only body-only draft ext-plist (lambda (file) (org-latex-compile file))) The function returns either a file name returned by POST-PROCESS, @@ -5861,15 +5913,16 @@ or FILE." (org-export-add-to-stack (expand-file-name file) ',backend)) `(let ((output (org-export-as - ',backend ,subtreep ,visible-only ,body-only + ',backend ,subtreep ,visible-only ,body-only ,draft ',ext-plist))) (with-temp-buffer (insert output) (let ((coding-system-for-write ',encoding)) (write-file ,file))) (or (ignore-errors (funcall ',post-process ,file)) ,file))) - (let ((output (org-export-as - backend subtreep visible-only body-only ext-plist))) + (let ((output + (org-export-as + backend subtreep visible-only body-only draft ext-plist))) (with-temp-buffer (insert output) (let ((coding-system-for-write encoding)) @@ -6117,7 +6170,8 @@ When ARG is \\[universal-argument] \\[universal-argument], display the asynchron (setq org-export-dispatch-last-action (org-export--dispatch-ui (list org-export-initial-scope - (and org-export-in-background 'async)) + (and org-export-in-background 'async) + (and org-export-as-draft 'draft)) nil org-export-dispatch-use-expert-ui))) (and (get-buffer "*Org Export Dispatcher*") @@ -6158,7 +6212,8 @@ When ARG is \\[universal-argument] \\[universal-argument], display the asynchron (and (memq 'async optns) t) (and (memq 'subtree optns) t) (and (memq 'visible optns) t) - (and (memq 'body optns) t))))))) + (and (memq 'body optns) t) + (and (memq 'draft optns) t))))))) (defun org-export--dispatch-ui (options first-key expertp) "Handle interface for `org-export-dispatch'. @@ -6170,6 +6225,7 @@ export. It can contain any of the following symbols: `visible' restricts export to visible part of buffer. `force' force publishing files. `async' use asynchronous export process +`draft' export using a more permissive mode FIRST-KEY is the key pressed to select the first level menu. It is nil when this menu hasn't been selected yet. @@ -6208,13 +6264,13 @@ back to standard interface." 'car-less-than-car)) ;; Compute a list of allowed keys based on the first key ;; pressed, if any. Some keys - ;; (?^B, ?^V, ?^S, ?^F, ?^A, ?&, ?# and ?q) are always + ;; (?^B, ?^V, ?^S, ?^F, ?^A, ?^D, ?&, ?# and ?q) are always ;; available. (allowed-keys - (nconc (list 2 22 19 6 1) - (if (not first-key) (org-uniquify (mapcar 'car entries)) + (nconc (list 2 22 19 6 1 4) + (if (not first-key) (org-uniquify (mapcar #'car entries)) (let (sub-menu) - (dolist (entry entries (sort (mapcar 'car sub-menu) '<)) + (dolist (entry entries (sort (mapcar #'car sub-menu) #'<)) (when (eq (car entry) first-key) (setq sub-menu (append (nth 2 entry) sub-menu)))))) (cond ((eq first-key ?P) (list ?f ?p ?x ?a)) @@ -6229,7 +6285,7 @@ back to standard interface." ;; Options are hard-coded. (format "[%s] Body only: %s [%s] Visible only: %s \[%s] Export scope: %s [%s] Force publishing: %s -\[%s] Async export: %s\n\n" +\[%s] Async export: %s [%s] Draft mode : %s\n\n" (funcall fontify-key "C-b" t) (funcall fontify-value (if (memq 'body options) "On " "Off")) @@ -6244,7 +6300,10 @@ back to standard interface." (if (memq 'force options) "On " "Off")) (funcall fontify-key "C-a" t) (funcall fontify-value - (if (memq 'async options) "On " "Off"))) + (if (memq 'async options) "On " "Off")) + (funcall fontify-key "C-d" t) + (funcall fontify-value + (if (memq 'draft options) "On " "Off"))) ;; Display registered back-end entries. When a key ;; appears for the second time, do not create another ;; entry, but append its sub-menu to existing menu. @@ -6296,12 +6355,13 @@ back to standard interface." (expert-prompt (when expertp (format - "Export command (C-%s%s%s%s%s) [%s]: " + "Export command (C-%s%s%s%s%s%s) [%s]: " (if (memq 'body options) (funcall fontify-key "b" t) "b") (if (memq 'visible options) (funcall fontify-key "v" t) "v") (if (memq 'subtree options) (funcall fontify-key "s" t) "s") (if (memq 'force options) (funcall fontify-key "f" t) "f") (if (memq 'async options) (funcall fontify-key "a" t) "a") + (if (memq 'draft options) (funcall fontify-key "d" t) "d") (mapconcat (lambda (k) ;; Strip control characters. (unless (< k 27) (char-to-string k))) @@ -6346,8 +6406,8 @@ EXPERTP are the same as defined in `org-export--dispatch-ui', which see. Toggle export options when required. Otherwise, return value is -a list with action as CAR and a list of interactive export -options as CDR." +a list with action as car and a list of interactive export +options as cdr." (let (key) ;; Scrolling: when in non-expert mode, act on motion keys (C-n, ;; C-p, SPC, DEL). @@ -6388,11 +6448,11 @@ options as CDR." ((eq key ?#) (cons 'template (memq 'subtree options))) ;; Switch to asynchronous export stack. ((eq key ?&) '(stack)) - ;; Toggle options: C-b (2) C-v (22) C-s (19) C-f (6) C-a (1). - ((memq key '(2 22 19 6 1)) + ;; Options: C-b (2) C-v (22) C-s (19) C-f (6) C-a (1) C-d (4). + ((memq key '(2 22 19 6 1 4)) (org-export--dispatch-ui (let ((option (cl-case key (2 'body) (22 'visible) (19 'subtree) - (6 'force) (1 'async)))) + (6 'force) (1 'async) (4 'draft)))) (if (memq option options) (remq option options) (cons option options))) first-key expertp)) @@ -6413,10 +6473,9 @@ options as CDR." ;; path. Indeed, derived backends can share the same ;; FIRST-KEY. (t (catch 'found - (mapc (lambda (entry) - (let ((match (assq key (nth 2 entry)))) - (when match (throw 'found (nth 2 match))))) - (member (assq first-key entries) entries))))) + (dolist (entry (member (assq first-key entries) entries)) + (let ((match (assq key (nth 2 entry)))) + (when match (throw 'found (nth 2 match)))))))) options)) ;; Otherwise, enter sub-menu. (t (org-export--dispatch-ui options key expertp))))) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index c5e2218..6cccace 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -401,14 +401,14 @@ Paragraph" 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"))))))) + nil nil nil nil '(:exclude-tags ("noexp"))))))) ;; Test include tags for headlines and inlinetasks. (should (equal "* H2\n** Sub :exp:\n*** Sub Sub\n" (org-test-with-temp-text "* H1\n* H2\n** Sub :exp:\n*** Sub Sub\n* H3" (let ((org-tags-column 0)) (org-export-as (org-test-default-backend) - nil nil nil '(:select-tags ("exp"))))))) + nil nil nil nil '(:select-tags ("exp"))))))) ;; If there is an include tag, ignore the section before the first ;; headline, if any. (should @@ -416,13 +416,13 @@ Paragraph" (org-test-with-temp-text "First section\n* H1 :exp:\nBody" (let ((org-tags-column 0)) (org-export-as (org-test-default-backend) - nil nil nil '(:select-tags ("exp"))))))) + nil nil nil nil '(:select-tags ("exp"))))))) (should-not (equal "* H1 :exp:\n" (org-test-with-temp-text "* H1 :exp:\nBody" (let ((org-tags-column 0)) (org-export-as (org-test-default-backend) - nil nil nil '(:select-tags ("exp"))))))) + nil nil nil nil '(:select-tags ("exp"))))))) ;; Test mixing include tags and exclude tags. (should (string-match @@ -433,7 +433,7 @@ Paragraph" ** Sub-Head2 * Head2 :noexport: ** Sub-Head1 :export:" - (org-export-as (org-test-default-backend) nil nil nil + (org-export-as (org-test-default-backend) nil nil nil nil '(:select-tags ("export") :exclude-tags ("noexport")))))) ;; Ignore tasks. (should @@ -443,13 +443,13 @@ Paragraph" org-export-filter-final-output-functions) (org-test-with-temp-text "* TODO Head1" (org-export-as (org-test-default-backend) - nil nil nil '(:with-tasks nil)))))) + nil nil nil nil '(:with-tasks nil)))))) (should (equal "* TODO Head1\n" (let ((org-todo-keywords '((sequence "TODO" "DONE")))) (org-test-with-temp-text "* TODO Head1" (org-export-as (org-test-default-backend) - nil nil nil '(:with-tasks t)))))) + nil nil nil nil '(:with-tasks t)))))) ;; Archived tree. (should (equal "" @@ -458,13 +458,13 @@ Paragraph" (org-test-with-temp-text "* Head1 :archive:" (let ((org-archive-tag "archive")) (org-export-as (org-test-default-backend) - nil nil nil '(:with-archived-trees nil))))))) + nil nil nil nil '(:with-archived-trees nil))))))) (should (string-match "\\* Head1[ \t]+:archive:" (org-test-with-temp-text "* Head1 :archive:\nbody\n** Sub-head 2" (let ((org-archive-tag "archive")) - (org-export-as (org-test-default-backend) nil nil nil + (org-export-as (org-test-default-backend) nil nil nil nil '(:with-archived-trees headline)))))) (should (string-match @@ -472,20 +472,20 @@ Paragraph" (org-test-with-temp-text "* Head1 :archive:" (let ((org-archive-tag "archive")) (org-export-as (org-test-default-backend) - nil nil nil '(:with-archived-trees t)))))) + nil nil nil nil '(:with-archived-trees t)))))) ;; Clocks. (should (string-match "CLOCK: \\[2012-04-29 .* 10:45\\]" (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))))) + nil nil nil nil '(:with-clocks t))))) (should (equal "" (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)))))) + nil nil nil nil '(:with-clocks nil)))))) ;; Drawers. (should (equal "" @@ -493,48 +493,50 @@ Paragraph" 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)))))) + nil nil nil nil '(:with-drawers nil)))))) (should (equal ":TEST:\ncontents\n:END:\n" (org-test-with-temp-text ":TEST:\ncontents\n:END:" (org-export-as (org-test-default-backend) - nil nil nil '(:with-drawers t))))) + nil nil nil nil '(:with-drawers t))))) (should (equal ":FOO:\nkeep\n:END:\n" (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")))))) + nil nil nil nil '(:with-drawers ("FOO")))))) (should (equal ":FOO:\nkeep\n:END:\n" (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")))))) + nil nil nil nil '(:with-drawers (not "BAR")))))) ;; Fixed-width. (should (equal ": A\n" (org-test-with-temp-text ": A" - (org-export-as (org-test-default-backend) nil nil nil + (org-export-as (org-test-default-backend) nil nil nil nil '(:with-fixed-width t))))) (should (equal "" (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 + (org-export-as (org-test-default-backend) nil nil nil nil '(:with-fixed-width nil)))))) ;; Footnotes. (should (equal "Footnote?" (let ((org-footnote-section nil)) (org-test-with-temp-text "Footnote?[fn:1]\n\n[fn:1] Def" - (org-trim (org-export-as (org-test-default-backend) - nil nil nil '(:with-footnotes nil))))))) + (org-trim + (org-export-as (org-test-default-backend) + nil nil nil nil '(:with-footnotes nil))))))) (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" - (org-trim (org-export-as (org-test-default-backend) - nil nil nil '(:with-footnotes t))))))) + (org-trim + (org-export-as (org-test-default-backend) + nil nil nil nil '(:with-footnotes t))))))) ;; Inlinetasks. (when (featurep 'org-inlinetask) (should @@ -545,7 +547,7 @@ Paragraph" org-export-filter-final-output-functions) (org-test-with-temp-text "*************** Task" (org-export-as (org-test-default-backend) - nil nil nil '(:with-inlinetasks nil)))))) + nil nil nil nil '(:with-inlinetasks nil)))))) (should (equal "" @@ -555,7 +557,7 @@ Paragraph" (org-test-with-temp-text "*************** Task\nContents\n*************** END" (org-export-as (org-test-default-backend) - nil nil nil '(:with-inlinetasks nil))))))) + nil nil nil nil '(:with-inlinetasks nil))))))) ;; Plannings. (should (string-match @@ -563,32 +565,32 @@ Paragraph" (let ((org-closed-string "CLOSED:")) (org-test-with-temp-text "* H\nCLOSED: [2012-04-29 sun. 10:45]" (org-export-as (org-test-default-backend) - nil nil nil '(:with-planning t)))))) + nil nil nil nil '(:with-planning t)))))) (should (equal "* H\n" (let ((org-closed-string "CLOSED:")) (org-test-with-temp-text "* H\nCLOSED: [2012-04-29 sun. 10:45]" (org-export-as (org-test-default-backend) - nil nil nil '(:with-planning nil)))))) + nil nil nil nil '(:with-planning nil)))))) ;; 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))))) + nil 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))))) + nil 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")))))) + nil nil nil nil '(:with-properties ("B")))))) ;; Statistics cookies. (should (equal "* Stats" @@ -596,20 +598,21 @@ Paragraph" org-export-filter-final-output-functions) (org-trim (org-test-with-temp-text "* Stats [0/0]" - (org-export-as (org-test-default-backend) - nil nil nil '(:with-statistics-cookies nil))))))) + (org-export-as + (org-test-default-backend) + nil nil nil nil '(:with-statistics-cookies nil))))))) ;; Tables. (should (equal "| A |\n" (org-test-with-temp-text "| A |" - (org-export-as (org-test-default-backend) nil nil nil + (org-export-as (org-test-default-backend) nil nil nil nil '(:with-tables t))))) (should (equal "" (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 + (org-export-as (org-test-default-backend) nil nil nil nil '(:with-tables nil))))))) (ert-deftest test-org-export/with-timestamps () @@ -620,7 +623,7 @@ Paragraph" "\\[2012-04-29 .*? 10:45\\]<2012-04-29 .*? 10:45>" (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 t))))) + nil nil nil nil '(:with-timestamps t))))) ;; nil value. (should (equal @@ -630,7 +633,7 @@ Paragraph" (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))))))) + nil nil nil nil '(:with-timestamps nil))))))) ;; `active' value. (should (string-match @@ -640,7 +643,7 @@ Paragraph" Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (org-export-as (org-test-default-backend) - nil nil nil '(:with-timestamps active))))) + nil nil nil nil '(:with-timestamps active))))) ;; `inactive' value. (should (string-match @@ -650,7 +653,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (org-export-as (org-test-default-backend) - nil nil nil '(:with-timestamps inactive)))))) + nil nil nil nil '(:with-timestamps inactive)))))) (ert-deftest test-org-export/comment-tree () "Test if export process ignores commented trees." @@ -672,7 +675,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-entities t))))) (should (equal "\\alpha\n" (org-test-with-temp-text "\\alpha" @@ -681,7 +684,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-entities nil))))) ;; Emphasis. (should (equal "dummy\n" @@ -691,7 +694,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-emphasize t))))) (should (equal "*bold*\n" (org-test-with-temp-text "*bold*" @@ -700,7 +703,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-emphasize nil))))) ;; LaTeX environment. (should (equal "dummy\n" @@ -709,7 +712,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (org-export-create-backend :transcoders '((latex-environment . (lambda (l c i) "dummy")) (section . (lambda (s c i) c)))) - nil nil nil '(:with-latex t))))) + nil 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}" @@ -717,7 +720,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (org-export-create-backend :transcoders '((latex-environment . (lambda (l c i) "dummy")) (section . (lambda (s c i) c)))) - nil nil nil '(:with-latex verbatim))))) + nil nil nil nil '(:with-latex verbatim))))) ;; LaTeX fragment. (should (equal "dummy\n" @@ -727,7 +730,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-latex t))))) (should (equal "$1$\n" (org-test-with-temp-text "$1$" @@ -736,7 +739,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-latex verbatim))))) ;; Sub/superscript. (should (equal "adummy\n" @@ -746,7 +749,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-sub-superscript t))))) (should (equal "a_b\n" (org-test-with-temp-text "a_b" @@ -755,7 +758,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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))))) + nil nil nil nil '(:with-sub-superscript nil))))) (should (equal "a_b\n" (org-test-with-temp-text "a_b" @@ -764,7 +767,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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 nil nil nil '(:with-sub-superscript {}))))) (should (equal "adummy\n" (org-test-with-temp-text "a_{b}" @@ -773,7 +776,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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 nil nil nil '(:with-sub-superscript {}))))) ;; Also handle uninterpreted objects in title. (should (equal "a_b" @@ -785,7 +788,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (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))))) + nil nil nil nil '(:with-sub-superscript nil))))) ;; Handle uninterpreted objects in captions. (should (equal "adummy\n" @@ -797,7 +800,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (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))))) + nil nil nil nil '(:with-sub-superscript t))))) (should (equal "a_b\n" (org-test-with-temp-text "#+CAPTION: a_b\nParagraph" @@ -808,7 +811,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" (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))))) + nil nil nil nil '(:with-sub-superscript nil))))) ;; Special case: multiples uninterpreted objects in a row. (should (equal "a_b_c_d\n" @@ -818,7 +821,7 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]" :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 nil nil nil '(:with-sub-superscript {})))))) (ert-deftest test-org-export/export-scope () "Test all export scopes." @@ -1175,7 +1178,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote :options '((:k "K" nil nil parse))))) (org-test-with-temp-text "#+MACRO: m v\n* H\n:PROPERTIES:\n:EXPORT_K: {{{m}}}\n:END:" - (org-export-as backend nil nil nil '(:with-properties t)))))) + (org-export-as backend nil nil nil nil '(:with-properties t)))))) ;; Expand specific macros. (should (equal "me 2012-03-29 address@hidden Title\n" @@ -1671,7 +1674,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote "")) (section . (lambda (s c i) c)) (paragraph . (lambda (p c i) c)))) - nil nil nil '(:with-footnotes t)) + nil nil nil nil '(:with-footnotes t)) (nreverse result))))) ;; Limit check to DATA, when non-nil. (should @@ -1719,7 +1722,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote (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)) + nil nil nil nil '(:with-footnotes t)) (nreverse result))))) (should (equal @@ -1740,7 +1743,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote (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)) + nil nil nil nil '(:with-footnotes t)) (nreverse result)))))) (ert-deftest test-org-export/get-footnote-number () @@ -2254,7 +2257,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote org-export-filter-final-output-functions) (org-test-with-temp-text "*** Inlinetask :noexp:\nContents\n*** end" (org-export-as (org-test-default-backend) - nil nil nil '(:exclude-tags ("noexp"))))))) + nil nil nil nil '(:exclude-tags ("noexp"))))))) ;; Inlinetask with an include tag. (should (equal @@ -2263,7 +2266,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote (org-tags-column 0)) (org-test-with-temp-text "* H1\n* H2\n*** Inline :exp:" (org-export-as (org-test-default-backend) - nil nil nil '(:select-tags ("exp"))))))) + nil nil nil nil '(:select-tags ("exp"))))))) ;; Ignore inlinetask with a TODO keyword and tasks excluded. (should (equal "" @@ -2273,7 +2276,7 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote org-export-filter-final-output-functions) (org-test-with-temp-text "*** TODO Inline" (org-export-as (org-test-default-backend) - nil nil nil '(:with-tasks nil)))))))) + nil nil nil nil '(:with-tasks nil)))))))) -- 2.5.3