help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Org to Markdown programmatically


From: Jean Louis
Subject: Org to Markdown programmatically
Date: Tue, 04 May 2021 11:48:30 +0300

As I am editing database strings, not files, I have to export
programmatically Org blobs into HTML. 

Following receives output from comands that receive standard input:

(defun rcd-command-output-from-input (program input &rest args)
  "Returns output from PROGRAM INPUT with optional ARGS"
  (let* ((output (with-temp-buffer
                   (insert input)
                   (apply #'call-process-region nil nil program t t nil args)
                   (buffer-string))))
    output))

Following receives Markdown processed HTML:

(defun rcd-markdown (text)
  "Markdown processing"
  (if text
      (rcd-command-output-from-input "markdown" text)
    ""))

And this one returns HTML from Org string that is first exported to Markdown.

(defun rcd-org-to-markdown-to-html (text)
  "Transform Org string to HTML"
  (rcd-markdown 
   (with-temp-buffer
     (insert text)
     (org-export-to-buffer 'md (current-buffer) nil nil nil t)
     (buffer-string))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]