@@ -2938,135 +2938,142 @@ still inferior to file-local settings.
29382938Return code as a string."
29392939 (when (symbolp backend) (setq backend (org-export-get-backend backend)))
29402940 (org-export-barf-if-invalid-backend backend)
2941- (save-excursion
2942- (save-restriction
2943- ;; Narrow buffer to an appropriate region or subtree for
2944- ;; parsing. If parsing subtree, be sure to remove main
2945- ;; headline, planning data and property drawer.
2946- (cond ((org-region-active-p)
2947- (narrow-to-region (region-beginning) (region-end)))
2948- (subtreep
2949- (org-narrow-to-subtree)
2950- (goto-char (point-min))
2951- (org-end-of-meta-data)
2952- (narrow-to-region (point) (point-max))))
2953- ;; Initialize communication channel with original buffer
2954- ;; attributes, unavailable in its copy.
2955- (let* ((org-export-current-backend (org-export-backend-name backend))
2956- (info (org-combine-plists
2957- (org-export--get-export-attributes
2958- backend subtreep visible-only body-only)
2959- (org-export--get-buffer-attributes)))
2960- (parsed-keywords
2961- (delq nil
2962- (mapcar (lambda (o) (and (eq (nth 4 o) 'parse) (nth 1 o)))
2963- (append (org-export-get-all-options backend)
2964- org-export-options-alist))))
2965- tree)
2966- ;; Update communication channel and get parse tree. Buffer
2967- ;; isn't parsed directly. Instead, all buffer modifications
2968- ;; and consequent parsing are undertaken in a temporary copy.
2969- (org-export-with-buffer-copy
2970- ;; Run first hook with current back-end's name as argument.
2971- (run-hook-with-args 'org-export-before-processing-hook
2972- (org-export-backend-name backend))
2973- (org-export-expand-include-keyword)
2974- (org-export--delete-comment-trees)
2975- (org-macro-initialize-templates org-export-global-macros)
2976- (org-macro-replace-all org-macro-templates parsed-keywords)
2977- ;; Refresh buffer properties and radio targets after previous
2978- ;; potentially invasive changes.
2979- (org-set-regexps-and-options)
2980- (org-update-radio-target-regexp)
2981- ;; Possibly execute Babel code. Re-run a macro expansion
2982- ;; specifically for {{{results}}} since inline source blocks
2983- ;; may have generated some more. Refresh buffer properties
2984- ;; and radio targets another time.
2985- (when org-export-use-babel
2986- (org-babel-exp-process-buffer)
2987- (org-macro-replace-all '(("results" . "$1")) parsed-keywords)
2941+ (org-fold-core-ignore-modifications
2942+ (save-excursion
2943+ (save-restriction
2944+ ;; Narrow buffer to an appropriate region or subtree for
2945+ ;; parsing. If parsing subtree, be sure to remove main
2946+ ;; headline, planning data and property drawer.
2947+ (cond ((org-region-active-p)
2948+ (narrow-to-region (region-beginning) (region-end)))
2949+ (subtreep
2950+ (org-narrow-to-subtree)
2951+ (goto-char (point-min))
2952+ (org-end-of-meta-data)
2953+ (narrow-to-region (point) (point-max))))
2954+ ;; Initialize communication channel with original buffer
2955+ ;; attributes, unavailable in its copy.
2956+ (let* ((org-export-current-backend (org-export-backend-name backend))
2957+ (info (org-combine-plists
2958+ (org-export--get-export-attributes
2959+ backend subtreep visible-only body-only)
2960+ (org-export--get-buffer-attributes)))
2961+ (parsed-keywords
2962+ (delq nil
2963+ (mapcar (lambda (o) (and (eq (nth 4 o) 'parse) (nth 1 o)))
2964+ (append (org-export-get-all-options backend)
2965+ org-export-options-alist))))
2966+ tree modified-tick)
2967+ ;; Update communication channel and get parse tree. Buffer
2968+ ;; isn't parsed directly. Instead, all buffer modifications
2969+ ;; and consequent parsing are undertaken in a temporary copy.
2970+ (org-export-with-buffer-copy
2971+ (font-lock-mode -1)
2972+ ;; Run first hook with current back-end's name as argument.
2973+ (run-hook-with-args 'org-export-before-processing-hook
2974+ (org-export-backend-name backend))
2975+ (org-export-expand-include-keyword)
2976+ (org-export--delete-comment-trees)
2977+ (org-macro-initialize-templates org-export-global-macros)
2978+ (org-macro-replace-all org-macro-templates parsed-keywords)
2979+ ;; Refresh buffer properties and radio targets after previous
2980+ ;; potentially invasive changes.
29882981 (org-set-regexps-and-options)
2989- (org-update-radio-target-regexp))
2990- ;; Run last hook with current back-end's name as argument.
2991- ;; Update buffer properties and radio targets one last time
2992- ;; before parsing.
2993- (goto-char (point-min))
2994- (save-excursion
2995- (run-hook-with-args 'org-export-before-parsing-hook
2996- (org-export-backend-name backend)))
2997- (org-set-regexps-and-options)
2998- (org-update-radio-target-regexp)
2999- ;; Update communication channel with environment.
3000- (setq info
3001- (org-combine-plists
3002- info (org-export-get-environment backend subtreep ext-plist)))
3003- ;; Pre-process citations environment, i.e. install
3004- ;; bibliography list, and citation processor in INFO.
3005- (org-cite-store-bibliography info)
3006- (org-cite-store-export-processor info)
3007- ;; De-activate uninterpreted data from parsed keywords.
3008- (dolist (entry (append (org-export-get-all-options backend)
3009- org-export-options-alist))
3010- (pcase entry
3011- (`(,p ,_ ,_ ,_ parse)
3012- (let ((value (plist-get info p)))
3013- (plist-put info
3014- p
3015- (org-export--remove-uninterpreted-data value info))))
3016- (_ nil)))
3017- ;; Install user's and developer's filters.
3018- (setq info (org-export-install-filters info))
3019- ;; Call options filters and update export options. We do not
3020- ;; use `org-export-filter-apply-functions' here since the
3021- ;; arity of such filters is different.
3022- (let ((backend-name (org-export-backend-name backend)))
3023- (dolist (filter (plist-get info :filter-options))
3024- (let ((result (funcall filter info backend-name)))
3025- (when result (setq info result)))))
3026- ;; Parse buffer.
3027- (setq tree (org-element-parse-buffer nil visible-only))
3028- ;; Prune tree from non-exported elements and transform
3029- ;; uninterpreted elements or objects in both parse tree and
3030- ;; communication channel.
3031- (org-export--prune-tree tree info)
3032- (org-export--remove-uninterpreted-data tree info)
3033- ;; Call parse tree filters.
3034- (setq tree
3035- (org-export-filter-apply-functions
3036- (plist-get info :filter-parse-tree) tree info))
3037- ;; Now tree is complete, compute its properties and add them
3038- ;; to communication channel.
3039- (setq info (org-export--collect-tree-properties tree info))
3040- ;; Process citations and bibliography. Replace each citation
3041- ;; and "print_bibliography" keyword in the parse tree with
3042- ;; the output of the selected citation export processor.
3043- (org-cite-process-citations info)
3044- (org-cite-process-bibliography info)
3045- ;; Eventually transcode TREE. Wrap the resulting string into
3046- ;; a template.
3047- (let* ((body (org-element-normalize-string
3048- (or (org-export-data tree info) "")))
3049- (inner-template (cdr (assq 'inner-template
3050- (plist-get info :translate-alist))))
3051- (full-body (org-export-filter-apply-functions
3052- (plist-get info :filter-body)
3053- (if (not (functionp inner-template)) body
3054- (funcall inner-template body info))
3055- info))
3056- (template (cdr (assq 'template
3057- (plist-get info :translate-alist))))
3058- (output
3059- (if (or (not (functionp template)) body-only) full-body
3060- (funcall template full-body info))))
3061- ;; Call citation export finalizer.
3062- (setq output (org-cite-finalize-export output info))
3063- ;; Remove all text properties since they cannot be
3064- ;; retrieved from an external process. Finally call
3065- ;; final-output filter and return result.
3066- (org-no-properties
3067- (org-export-filter-apply-functions
3068- (plist-get info :filter-final-output)
3069- output info))))))))
2982+ (org-update-radio-target-regexp)
2983+ (setq modified-tick (buffer-chars-modified-tick))
2984+ ;; Possibly execute Babel code. Re-run a macro expansion
2985+ ;; specifically for {{{results}}} since inline source blocks
2986+ ;; may have generated some more. Refresh buffer properties
2987+ ;; and radio targets another time.
2988+ (when org-export-use-babel
2989+ (org-babel-exp-process-buffer)
2990+ (org-macro-replace-all '(("results" . "$1")) parsed-keywords)
2991+ (unless (eq modified-tick (buffer-chars-modified-tick))
2992+ (org-set-regexps-and-options)
2993+ (org-update-radio-target-regexp))
2994+ (setq modified-tick (buffer-chars-modified-tick)))
2995+ ;; Run last hook with current back-end's name as argument.
2996+ ;; Update buffer properties and radio targets one last time
2997+ ;; before parsing.
2998+ (goto-char (point-min))
2999+ (save-excursion
3000+ (run-hook-with-args 'org-export-before-parsing-hook
3001+ (org-export-backend-name backend)))
3002+ (unless (eq modified-tick (buffer-chars-modified-tick))
3003+ (org-set-regexps-and-options)
3004+ (org-update-radio-target-regexp))
3005+ (setq modified-tick (buffer-chars-modified-tick))
3006+ ;; Update communication channel with environment.
3007+ (setq info
3008+ (org-combine-plists
3009+ info (org-export-get-environment backend subtreep ext-plist)))
3010+ ;; Pre-process citations environment, i.e. install
3011+ ;; bibliography list, and citation processor in INFO.
3012+ (org-cite-store-bibliography info)
3013+ (org-cite-store-export-processor info)
3014+ ;; De-activate uninterpreted data from parsed keywords.
3015+ (dolist (entry (append (org-export-get-all-options backend)
3016+ org-export-options-alist))
3017+ (pcase entry
3018+ (`(,p ,_ ,_ ,_ parse)
3019+ (let ((value (plist-get info p)))
3020+ (plist-put info
3021+ p
3022+ (org-export--remove-uninterpreted-data value info))))
3023+ (_ nil)))
3024+ ;; Install user's and developer's filters.
3025+ (setq info (org-export-install-filters info))
3026+ ;; Call options filters and update export options. We do not
3027+ ;; use `org-export-filter-apply-functions' here since the
3028+ ;; arity of such filters is different.
3029+ (let ((backend-name (org-export-backend-name backend)))
3030+ (dolist (filter (plist-get info :filter-options))
3031+ (let ((result (funcall filter info backend-name)))
3032+ (when result (setq info result)))))
3033+ ;; Parse buffer.
3034+ (setq tree (org-element-parse-buffer nil visible-only))
3035+ ;; Prune tree from non-exported elements and transform
3036+ ;; uninterpreted elements or objects in both parse tree and
3037+ ;; communication channel.
3038+ (org-export--prune-tree tree info)
3039+ (org-export--remove-uninterpreted-data tree info)
3040+ ;; Call parse tree filters.
3041+ (setq tree
3042+ (org-export-filter-apply-functions
3043+ (plist-get info :filter-parse-tree) tree info))
3044+ ;; Now tree is complete, compute its properties and add them
3045+ ;; to communication channel.
3046+ (setq info (org-export--collect-tree-properties tree info))
3047+ ;; Process citations and bibliography. Replace each citation
3048+ ;; and "print_bibliography" keyword in the parse tree with
3049+ ;; the output of the selected citation export processor.
3050+ (org-cite-process-citations info)
3051+ (org-cite-process-bibliography info)
3052+ ;; Eventually transcode TREE. Wrap the resulting string into
3053+ ;; a template.
3054+ (let* ((body (org-element-normalize-string
3055+ (or (org-export-data tree info) "")))
3056+ (inner-template (cdr (assq 'inner-template
3057+ (plist-get info :translate-alist))))
3058+ (full-body (org-export-filter-apply-functions
3059+ (plist-get info :filter-body)
3060+ (if (not (functionp inner-template)) body
3061+ (funcall inner-template body info))
3062+ info))
3063+ (template (cdr (assq 'template
3064+ (plist-get info :translate-alist))))
3065+ (output
3066+ (if (or (not (functionp template)) body-only) full-body
3067+ (funcall template full-body info))))
3068+ ;; Call citation export finalizer.
3069+ (setq output (org-cite-finalize-export output info))
3070+ ;; Remove all text properties since they cannot be
3071+ ;; retrieved from an external process. Finally call
3072+ ;; final-output filter and return result.
3073+ (org-no-properties
3074+ (org-export-filter-apply-functions
3075+ (plist-get info :filter-final-output)
3076+ output info)))))))))
30703077
30713078;;;###autoload
30723079(defun org-export-string-as (string backend &optional body-only ext-plist)
0 commit comments