branch: externals/ellama commit b1467d15e0e7b8d7c70e0c7baf476191ff0ff214 Author: Sergey Kostyaev <sskosty...@gmail.com> Commit: Sergey Kostyaev <sskosty...@gmail.com>
Add function to convert org syntax to markdown Added a new function `ellama-convert-org-to-md` that translates text from org syntax to markdown syntax using Emacs Org Export functionality. This function creates a temporary buffer, inserts the provided org text, exports it to markdown, and returns the resulting markdown string. --- ellama.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ellama.el b/ellama.el index 5bd5d8ecd2..a42faa5df8 100644 --- a/ellama.el +++ b/ellama.el @@ -1545,6 +1545,22 @@ Extract profession from this message. Be short and concise." :transform (lambda (_ _) "Provide short final answer based on final solution."))))) +(declare-function org-export-to-buffer "ox") + +(defun ellama-convert-org-to-md (text) + "Translate TEXT from org syntax to markdown syntax." + (require 'ox) + (require 'ox-md) + (let ((buf (make-temp-name "ellama-"))) + (with-temp-buffer + (insert "#+OPTIONS: toc:nil\n" text) + (org-export-to-buffer 'md buf + nil nil t t nil (lambda () (text-mode)))) + (with-current-buffer buf + (prog1 + (string-trim (buffer-substring-no-properties (point-min) (point-max))) + (kill-buffer))))) + (defun ellama-chat-done (text &optional on-done) "Chat done. Will call `ellama-chat-done-callback' and ON-DONE on TEXT."