Initial commit

This commit is contained in:
2026-03-26 01:01:07 -07:00
commit 9b2548bc96

42
org-publish-odt.el Normal file
View File

@@ -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)