19

Is there any easy way to copy/paste text from a browser window into an org file, automatically converting links into [[][]] org-mode links? thanks!

4
  • 2
    You could save HTML and convert to org with pandoc.
    – abo-abo
    Commented Jan 8, 2015 at 18:11
  • Isn't there some type of insert link command, with a minibuffer read prompt, where you can simply yank the link from kill-ring and paste it into the minibuffer and then hit return?
    – lawlist
    Commented Jan 8, 2015 at 19:21
  • 1
    @lawlist: there is; but the question is about the case where there is a large piece of text with multiple links... I'll check out pandoc, thanks!
    – laxxy
    Commented Jan 8, 2015 at 21:46
  • 1
    Similar emacs.stackexchange.com/questions/12121/… Commented Jun 22, 2020 at 17:26

3 Answers 3

10

Copying html in org format from eww

This requires emacs 24.4 or later.

  1. Configure the org-eww module. It's not part of org, you'll have to pull the repo into some folder (git clone https://orgmode.org/org-mode.git) or manually copy the file into some package folder, although git is recommended as it helps you keep things up to date.

  2. Then add the contribute folder into your path and say that org-eww is required. If you cloned from git, the org-eww.el file will be in /path/where/you/cloned/org-mode/contrib/lisp/.

    (add-to-list 'load-path "/dir/path/containing/org-eww.el/")

    (require 'org-eww)

  3. Open a web-page in eww (eww is a browser in emacs, M-x eww). You can get emacs to open links in eww via: (setq browse-url-browser-function 'eww-browse-url). This is useful in combination with helm-google + eww).

  4. Select the region you want to copy from the html page and do M-x org-eww-copy-for-org-mode. If no region is selected, the whole webpage is copied (including links to images). As of now the o key is not bound to the eww-mode-map. For convenience, this command can be bound to that key in that mode map:

    (define-key eww-mode-map (kbd "o") #'org-eww-copy-for-org-mode)

  5. Then use C-y to paste into your org mode file/buffer. With iimage-mode you can even see the images from the website and links are converted to the org-mode format.

3
  • Thanks! The pandoc tool suggested in comments is another solution -- for me it would be a bit easier to implement, but it is nice to have a method that does not rely upon tools outside of Emacs...
    – laxxy
    Commented Feb 13, 2015 at 15:12
  • That seems promising. However the text formatting is still lost... For example italics, bold and code. Sometimes I just want to copy a part of the text instead of the whole web page, preserving the format. Is there any alternative to pandoc approach.
    – xji
    Commented Apr 21, 2015 at 5:36
  • I might still prefer to use some external tools such as Evernote or Quiver if that's not possible.
    – xji
    Commented Apr 21, 2015 at 6:02
5

I wrote an add-on Copy as Org-Mode for Firefox which can do this in browser directly, it even can convert HTML tables into Org-mode format.

4

late to the party, but as @xji said, org-eww-copy-for-org-mode doesn't preserve formatting, it only does links.

if you want to actually end up with org headings and preserved formatting, try https://github.com/alphapapa/org-web-tools.

From eww, hit w to copy URL of current page (or copy from another browser), then run org-web-tools-read-url-as-org.

further details are in the readme.

1
  • IIRC, they delegate to pandoc, which is one of the best pieces of software out there.
    – HappyFace
    Commented Oct 3, 2021 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.