Skip to content

Instantly share code, notes, and snippets.

@mxpiotrowski
Created June 2, 2021 20:30
Show Gist options
  • Save mxpiotrowski/96a531c3e3aabd648ac773f0586387f4 to your computer and use it in GitHub Desktop.
Save mxpiotrowski/96a531c3e3aabd648ac773f0586387f4 to your computer and use it in GitHub Desktop.
Convert region to RTF (using pandoc) and copy to macOS clipboard.
(defun mxp-copy-as-rich-text (start end)
"Convert region to RTF (using pandoc) and copy to macOS clipboard.
Input format is “org” or “markdown” depending on the buffer's major mode."
(interactive "r")
(let ((coding-system-for-read 'utf-8)
(coding-system-for-write 'utf-8)
(src (cond ((eq major-mode 'org-mode) "org")
(t "markdown"))))
(shell-command-on-region start end
(concat "pandoc -s -f " src
" -t rtf -o - - | pbcopy" ))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment