Search code examples
htmlemacsmarkdownclipboardorg-mode

paste HTML into org-mode as org-mode markup?


Is there a tool that will allow me to copy content from a web site (images, headings, links, and paragraph text) and paste that content into org-mode in proper org-mode markup (e.g. with the links and image URLs denoted in org-mode syntax) without going through the extra step of converting the HTML file separately?


Solution

  • This works for me:

    (defun kdm/html2org-clipboard ()
      "Convert clipboard contents from HTML to Org and then paste (yank)."
      (interactive)
      (setq cmd "osascript -e 'the clipboard as \"HTML\"' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))' | pandoc -f html -t json | pandoc -f json -t org")
      (kill-new (shell-command-to-string cmd))
      (yank))
    

    Source: https://emacs.stackexchange.com/questions/12121/org-mode-parsing-rich-html-directly-when-pasting