Skip to content

Instantly share code, notes, and snippets.

@benley
Last active May 1, 2019 00:13
Show Gist options
  • Save benley/b6c9d37f40501caf74107276f4c39d14 to your computer and use it in GitHub Desktop.
Save benley/b6c9d37f40501caf74107276f4c39d14 to your computer and use it in GitHub Desktop.
org-to-gfm.el
;;; org-to-gfm --- Export a org-mode file to Github-flavored Markdown
;;;
;;; Commentary:
;;; To convert INPUT_FILE.org and produce OUTPUT_FILE.md, run something like:
;;;
;;; emacs -q --no-splash --no-x-resources --batch --script org-to-gfm.el INPUT_FILE.org OUTPUT_FILE.md
;;;
;;; Code:
(unless (require 'use-package nil t) (package-install 'use-package))
(require 'use-package)
(package-initialize)
(use-package ox-gfm :ensure t)
(setq-default indent-tabs-mode nil)
(setq-default require-final-newline 't)
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(let ((input-file (car command-line-args-left))
(output-file (cadr command-line-args-left)))
(with-current-buffer (find-file-noselect input-file)
(org-gfm-export-as-markdown)
;; write output-file relative to startup dir, not input-file location
(cd command-line-default-directory)
(write-file output-file)))
;;; org-to-gfm.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment