Skip to content

Instantly share code, notes, and snippets.

@harizvi
Created July 13, 2021 17:42
Show Gist options
  • Save harizvi/b59bf7f7c3e258ca7b0e01ad863d9480 to your computer and use it in GitHub Desktop.
Save harizvi/b59bf7f7c3e258ca7b0e01ad863d9480 to your computer and use it in GitHub Desktop.
;; discussion in reddit about clipping from browser.
(defun hr/paste-html-to-org ()
"Takes the contents of the system clip/paste-board, and uses
`pandoc' to convert it to the org-mode format."
(interactive)
(let* ((clip (if (eq system-type 'darwin)
"pbv public.html"
"xclip -out -selection 'clipboard' -t text/html"))
(format (if (eq major-mode 'org-mode) "org" "markdown"))
(pandoc (concat "pandoc -f html -t " format))
(cmd (concat clip " | " pandoc))
(text (shell-command-to-string cmd)))
(kill-new text)
(yank)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment