Skip to content

Instantly share code, notes, and snippets.

@saevarb
Created September 3, 2015 14:34
Show Gist options
  • Save saevarb/e3c560c2f3c57c1acaad to your computer and use it in GitHub Desktop.
Save saevarb/e3c560c2f3c57c1acaad to your computer and use it in GitHub Desktop.
(defun sbrg:export-subtree-to-markdown (args)
(interactive "P")
(save-excursion
(let ((cur-heading (org-get-heading t t)))
(setq filename (downcase (replace-regexp-in-string " " "" cur-heading)))
(setq full-path (format "~/sbrg/teaching/classes/%s/exercises/%s.md" (car (org-property-values "CLASS_SUBDIR")) filename))
(org-md-export-as-markdown nil t)
(switch-to-buffer "*Org MD Export*")
(insert "---\n")
(insert (format "title: %s\n" cur-heading))
(insert (format-time-string "date: %Y-%m-%d\n"))
(insert "---\n")
(write-file full-path t)
(kill-buffer-and-window)
))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment