From 1c62cd1ddc073b6cc4dcb8f3755431ced9bbd9e9 Mon Sep 17 00:00:00 2001 From: pi-bot-01 Date: Thu, 26 Mar 2026 01:01:07 -0700 Subject: [PATCH] Initial commit --- org-publish-odt-el.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 org-publish-odt-el.el diff --git a/org-publish-odt-el.el b/org-publish-odt-el.el new file mode 100644 index 0000000..db33f51 --- /dev/null +++ b/org-publish-odt-el.el @@ -0,0 +1,42 @@ +;;; Provides a odt publishing action for org-publish + +(defun org-odt-publish-to-odt (plist filename pub-dir) + "Publish an org file to ODT. + +FILENAME is the filename of the Org file to be published. PLIST +is the property list of the given project. PUB-DIR is the publishing +directory. + +Return output file name." + (unless (or (not pub-dir) (file-exists-p pub-dir)) (make-directory pub-dir t)) + ;; Check if a buffer visiting FILENAME is already open. + (let* ((org-inhibit-startup t) + (visiting (find-buffer-visiting filename)) + (work-buffer (or visiting (find-file-noselect filename)))) + (unwind-protect + (with-current-buffer work-buffer + (let ((outfile (org-export-output-file-name ".odt" nil pub-dir))) + (org-odt--export-wrap + outfile + (let* ((org-odt-embedded-images-count 0) + (org-odt-embedded-formulas-count 0) + (org-odt-object-counters nil) + (hfy-user-sheet-assoc nil)) + (let ((output (org-export-as 'odt nil nil nil + (org-combine-plists + plist + `(:crossrefs + ,(org-publish-cache-get-file-property + (expand-file-name filename) :crossrefs nil t) + :filter-final-output + (org-publish--store-crossrefs + org-publish-collect-index + ,@(plist-get plist :filter-final-output)))))) + (out-buf (progn (require 'nxml-mode) + (let ((nxml-auto-insert-xml-declaration-flag nil)) + (find-file-noselect + (concat org-odt-zip-dir "content.xml") t))))) + (with-current-buffer out-buf (erase-buffer) (insert output)))))))) + (unless visiting (kill-buffer work-buffer)))) + +(provide 'org-publish-odt)