*** org-mode/lisp/ox.el 2024-08-05 17:15:57.631928954 +0200 --- org-mode-multipage/lisp/ox.el 2024-08-03 12:57:24.346459632 +0200 *************** *** 215,220 **** --- 215,221 ---- (:filter-latex-fragment . org-export-filter-latex-fragment-functions) (:filter-line-break . org-export-filter-line-break-functions) (:filter-link . org-export-filter-link-functions) + (:multipage-split . org-export-multipage-split-functions) (:filter-node-property . org-export-filter-node-property-functions) (:filter-options . org-export-filter-options-functions) (:filter-paragraph . org-export-filter-paragraph-functions) *************** *** 1883,1891 **** INFO is a plist containing export directives." (let ((type (org-element-type blob))) ;; Return contents only for complete parse trees. ! (if (eq type 'org-data) (lambda (_datum contents _info) contents) ! (let ((transcoder (cdr (assq type (plist-get info :translate-alist))))) ! (and (functionp transcoder) transcoder))))) (defun org-export--keep-spaces (data info) "Non-nil, when post-blank spaces after removing DATA should be preserved. --- 1884,1894 ---- INFO is a plist containing export directives." (let ((type (org-element-type blob))) ;; Return contents only for complete parse trees. ! (let ((transcoder (cdr (assq type (plist-get info :translate-alist))))) ! (cond ! ((functionp transcoder) transcoder) ! ;; Use default org-data transcoder unless specified. ! ((eq type 'org-data) #'org-export-transcode-org-data))))) (defun org-export--keep-spaces (data info) "Non-nil, when post-blank spaces after removing DATA should be preserved. *************** *** 1928,1934 **** The `:filter-parse-tree' filters are not applied. ! Return a string." (or (gethash data (plist-get info :exported-data)) ;; Handle broken links according to ;; `org-export-with-broken-links'. --- 1931,1937 ---- The `:filter-parse-tree' filters are not applied. ! Return a string or a list of strings." (or (gethash data (plist-get info :exported-data)) ;; Handle broken links according to ;; `org-export-with-broken-links'. *************** *** 2194,2199 **** --- 2197,2205 ---- as a plist. It must return a string that will be used as the final export output.") + (defvar org-export-multipage-split-functions nil + "List of functions applied when multipage output has to be split.") + ;;;; Elements Filters *************** *** 2537,2542 **** --- 2543,2549 ---- (let (plist) ;; Install user-defined filters with `org-export-filters-alist' ;; and filters already in INFO (through ext-plist mechanism). + (setq tmp-info info) (dolist (p org-export-filters-alist) (let* ((prop (car p)) (info-value (plist-get info prop)) *************** *** 2548,2553 **** --- 2555,2561 ---- (append (if (listp info-value) info-value (list info-value)) default-value))))) + (setq global-prop org-export-filters-alist) ;; Prepend backend specific filters to that list. (dolist (p (org-export-get-all-filters (plist-get info :back-end))) ;; Single values get consed, lists are appended. *************** *** 2967,2973 **** with external parameters overriding Org default settings, but still inferior to file-local settings. ! Return code as a string." (when (symbolp backend) (setq backend (org-export-get-backend backend))) (org-export-barf-if-invalid-backend backend) (org-fold-core-ignore-modifications --- 2975,2983 ---- with external parameters overriding Org default settings, but still inferior to file-local settings. ! Return code as a string or a list of strings. ! The returned strings will have their `org-export-info' property set to ! export information channel." (when (symbolp backend) (setq backend (org-export-get-backend backend))) (org-export-barf-if-invalid-backend backend) (org-fold-core-ignore-modifications *************** *** 3004,3034 **** backend info subtreep visible-only ext-plist)) ;; Eventually transcode TREE. Wrap the resulting string into ;; a template. ! (let* ((body (org-element-normalize-string ! (or (org-export-data (plist-get info :parse-tree) info) ! ""))) ! (inner-template (cdr (assq 'inner-template ! (plist-get info :translate-alist)))) ! (full-body (org-export-filter-apply-functions ! (plist-get info :filter-body) ! (if (not (functionp inner-template)) body ! (funcall inner-template body info)) ! info)) ! (template (cdr (assq 'template ! (plist-get info :translate-alist)))) ! (output ! (if (or (not (functionp template)) body-only) full-body ! (funcall template full-body info)))) ;; Call citation export finalizer. (when (plist-get info :with-cite-processors) ! (setq output (org-cite-finalize-export output info))) ! ;; Remove all text properties since they cannot be ! ;; retrieved from an external process. Finally call ! ;; final-output filter and return result. ! (org-no-properties ! (org-export-filter-apply-functions ! (plist-get info :filter-final-output) ! output info))))))))) (defun org-export--annotate-info (backend info &optional subtreep visible-only ext-plist) "Annotate the INFO plist according to the BACKEND. --- 3014,3059 ---- backend info subtreep visible-only ext-plist)) ;; Eventually transcode TREE. Wrap the resulting string into ;; a template. ! (let ((output ! (or (org-export-data (plist-get info :parse-tree) info) ! ""))) ! (setq output (ensure-list output)) ;; Call citation export finalizer. (when (plist-get info :with-cite-processors) ! (setq output ! (mapcar ! (lambda (o) (org-cite-finalize-export o info)) ! output))) ! (let ((filters (plist-get info :filter-final-output))) ! ;; Call final-output filter and return result. ! (setq output ! (mapcar ! (lambda (o) (org-export-filter-apply-functions filters o info)) ! output))) ! ;; Apply org-export-info property. ! (setq output ! (mapcar ! (lambda (o) (org-add-props o nil ! :output-file (get-text-property 0 :output-file o) ! 'org-export-info info)) ! output)) ! (if (length= output 1) (car output) output)))))))) ! ! (defun org-export-transcode-org-data (_ body info) ! "Transcode `org-data' node with BODY. Return transcoded string. ! INFO is the communication channel plist." ! (let* ((inner-template (cdr (assq 'inner-template ! (plist-get info :translate-alist)))) ! (full-body (org-export-filter-apply-functions ! (plist-get info :filter-body) ! (if (not (functionp inner-template)) body ! (funcall inner-template body info)) ! info)) ! (template (cdr (assq 'template ! (plist-get info :translate-alist)))) ! (body-only (memq 'body-only (plist-get info :export-options)))) ! (if (or (not (functionp template)) body-only) full-body ! (funcall template full-body info)))) (defun org-export--annotate-info (backend info &optional subtreep visible-only ext-plist) "Annotate the INFO plist according to the BACKEND. *************** *** 3107,3120 **** (_ nil))) ;; Install user's and developer's filters. (setq info (org-export-install-filters info)) ;; Call options filters and update export options. We do not ;; use `org-export-filter-apply-functions' here since the ;; arity of such filters is different. (let ((backend-name (org-export-backend-name backend))) (dolist (filter (plist-get info :filter-options)) ! (let ((result (funcall filter info backend-name))) ! (when result (setq info result))))) ;; Parse buffer. (setq tree (org-element-parse-buffer nil visible-only 'defer)) ;; Prune tree from non-exported elements and transform ;; uninterpreted elements or objects in both parse tree and --- 3132,3147 ---- (_ nil))) ;; Install user's and developer's filters. (setq info (org-export-install-filters info)) + ;; Call options filters and update export options. We do not ;; use `org-export-filter-apply-functions' here since the ;; arity of such filters is different. (let ((backend-name (org-export-backend-name backend))) (dolist (filter (plist-get info :filter-options)) ! (let ((result (funcall filter info backend-name))) ! (when result (setq info result))))) ;; Parse buffer. + (setq tree (org-element-parse-buffer nil visible-only 'defer)) ;; Prune tree from non-exported elements and transform ;; uninterpreted elements or objects in both parse tree and *************** *** 3131,3136 **** --- 3158,3166 ---- ;; to communication channel. This is responsible for setting ;; :parse-tree to TREE. (setq info (org-export--collect-tree-properties tree info)) + (when (plist-get info :multipage) + (setq tree (org-export-filter-apply-functions + (plist-get info :multipage-split) tree info))) ;; Process citations and bibliography. Replace each citation ;; and "print_bibliography" keyword in the parse tree with ;; the output of the selected citation export processor. *************** *** 6140,6145 **** --- 6170,6195 ---- ("uk" :html "Автор" :utf-8 "Автор") ("zh-CN" :html "作者" :utf-8 "作者") ("zh-TW" :html "作者" :utf-8 "作者")) + ("Chapter %s" + ("ar" :default "الفصل %s") + ("cs" :default "kapitola %s") + ("da" :default "kapitel %s") + ("de" :default "Kapitel %s") + ("es" :ascii "capitulo %s" :html "capítulo %s" :default "capítulo %s") + ("et" :html "peatükk %s" :utf-8 "peatükk %s") + ("fa" :default "فصل %s") + ("fr" :default "chapitre %s") + ("it" :default "capitolo %s") + ("ja" :default "章 %s") + ("nl" :default "hoofdstuk %s" + :html "hoofdstuk %s" :latex "hoofdstuk~%s") + ("pt_BR" :ascii "capitulo %s" :html "capítulo %s" :default "capítulo %s") + ("ro" :default "capitol %s") + ("ru" :html "глава %s" + :utf-8 "глава %s") + ("sl" :default "odsek %s") + ("tr" :html "bölüm" :default "bölüm %s") + ("zh-CN" :html "章节" :utf-8 "章节 %s")) ("Continued from previous page" ("ar" :default "تتمة الصفحة السابقة") ("cs" :default "Pokračování z předchozí strany") *************** *** 6269,6274 **** --- 6319,6326 ---- ("sv" :default "Illustration") ("tr" :default "Şekil") ("zh-CN" :html "图" :utf-8 "图")) + ("Fig. %s" + ("de" :default "Abb. %s")) ("Figure %d:" ("ar" :default "شكل %d:") ("cs" :default "Obrázek %d:") *************** *** 6436,6441 **** --- 6488,6515 ---- ("sl" :default "Reference") ("sv" :default "Referenser") ("tr" :default "Referanslar")) + ("Section %s" + ("ar" :default "انظر قسم %s") + ("cs" :default "sekce %s") + ("da" :default "afsnit %s") + ("de" :default "Abschnitt %s") + ("es" :ascii "seccion %s" :html "sección %s" :default "sección %s") + ("et" :html "peatükki %s" :utf-8 "peatükki %s") + ;; ("fa" :default "نمایش بخش %s") + ("fr" :default "section %s") + ("it" :default "sezione %s") + ;; ("ja" :default "セクション %s を参照") + ("nl" :default "sectie %s" + :html "sectie %s" :latex "sectie~%s") + ("pt_BR" :html "seção %s" :default "seção %s" + :ascii "secao %s") + ("ro" :default "secțiunea %s") + ("ru" :html "&раздел %s" + :utf-8 "раздел %s") + ("sl" :default "poglavje %d") + ("tr" :default "bölüm %s") + ;; ("zh-CN" :html "参见第%s节" :utf-8 "参见第%s节") + ) ("See figure %s" ("cs" :default "Viz obrázek %s") ("et" :default "Vaata joonist %s") *************** *** 6813,6818 **** --- 6887,6918 ---- (switch-to-buffer-other-window buffer)) buffer))) + (defun org-export--write-output (output encoding) + "Write OUTPUT to file with ENCODING. + OUTPUT may be a string or a list of strings. + The target file is retrieved from :output-file OUTPUT property or + :output-file property in plist stored in `org-export-info' property of + each string. + + Return the file name or a list of file names." + (if (listp output) (mapcar #'org-export--write-output output) + (setq tmp-debug output) + (let ((file (or + (get-text-property 0 :output-file output) + (plist-get + (get-text-property 0 'org-export-info output) + :output-file)))) + (with-temp-buffer + (insert output) + ;; Ensure final newline. This is what was done + ;; historically, when we used `write-file'. + ;; Note that adding a newline is only safe for + ;; non-binary data. + (unless (bolp) (insert "\n")) + (let ((coding-system-for-write encoding)) + (write-region nil nil file)) + file)))) + ;;;###autoload (defun org-export-to-file (backend file &optional async subtreep visible-only body-only ext-plist *************** *** 6861,6893 **** `(let ((output (org-export-as ',backend ,subtreep ,visible-only ,body-only ! ',ext-plist))) ! (with-temp-buffer ! (insert output) ! ;; Ensure final newline. This is what was done ! ;; historically, when we used `write-file'. ! ;; Note that adding a newline is only safe for ! ;; non-binary data. ! (unless (bolp) (insert "\n")) ! (let ((coding-system-for-write ',encoding)) ! (write-region nil nil ,file))) ! (or (ignore-errors (funcall ',post-process ,file)) ,file))) (let ((output (org-export-as ! backend subtreep visible-only body-only ext-plist))) ! (with-temp-buffer ! (insert output) ! ;; Ensure final newline. This is what was done ! ;; historically, when we used `write-file'. ! ;; Note that adding a newline is only safe for ! ;; non-binary data. ! (unless (bolp) (insert "\n")) ! (let ((coding-system-for-write encoding)) ! (write-region nil nil file))) (when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p output)) (org-kill-new output)) ;; Get proper return value. ! (or (and (functionp post-process) (funcall post-process file)) ! file)))))) (defun org-export-output-file-name (extension &optional subtreep pub-dir) "Return output file's name according to buffer specifications. --- 6961,6983 ---- `(let ((output (org-export-as ',backend ,subtreep ,visible-only ,body-only ! ',ext-plist)) ! file) ! (setq file (org-export--write-output output ',encoding)) ! (let ((post (lambda (f) (or (ignore-errors (funcall ',post-process f)) f)))) ! (if (listp file) (mapcar post file) (funcall post file))))) (let ((output (org-export-as ! backend subtreep visible-only body-only ext-plist)) ! file) ! (setq file (org-export--write-output output encoding)) (when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p output)) (org-kill-new output)) ;; Get proper return value. ! (let ((post (lambda (f) ! (or (and (functionp post-process) ! (funcall post-process f)) ! f)))) ! (if (listp file) (mapcar post file) (funcall post file)))))))) (defun org-export-output-file-name (extension &optional subtreep pub-dir) "Return output file's name according to buffer specifications.