incandescentman / chatgpt2org

ChatGPT2Org: Emacs package to copy-paste HTML content into org-mode, specifically optimized for pasting conversations from OpenAI's ChatGPT. Copy-paste browser-copied content directly into Emacs in clean, parsed org-mode format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chatgpt2org: convert from ChatGPT to org-mode

ChatGPT2Org is an Emacs package that allows you to copy HTML content from a browser and paste it directly into an Emacs org-mode buffer in the form of… correctly parsed org-mode content. 🤯 It’s designed to work with any HTML content, but it includes additional cleanup functions are specifically optimized for content generated by OpenAI’s ChatGPT 4. This README and the majority of the cleanup functions’ code were generated by ChatGPT 4, then further refined by moi as needed. 🥹

Motivation

ChatGPT offers a “copy” button that allows you to copy its answers in Markdown format. But you gotta do this separately for each response, which is hella time-consuming if you want to copy-paste a whole entire conversation into org-mode. I (helped to) create ChatGPT2Org to enable ya to copy an entire ChatGPT conversation at once and paste it directly into Emacs in nice, nicely-formatted org-mode syntax.

Features

  • HTML to Org Conversion: The function converts HTML content from your clipboard into org-mode format, allowing you to paste the content directly into an org-mode document.
  • Removal of Base64-Encoded Images: ChatGPT2Org removes base64-encoded images from the converted text, hopefully resulting in clean text-focused output.
  • Link Removal: Links beginning with “https://chat.openai.com” or “https://lh3.googleusercontent.com” are removed to declutter the output.
  • Excessive Newlines Reduction: The function identifies and reduces instances of excessive newlines in the converted text, enhancing readability.
  • Unnecessary Characters Removal: Various unnecessary symbols and strings are removed from the converted text, further improving readability.
  • Org-mode Properties Removal: All org-mode properties are removed from the converted text, keeping the output focused on the main content.
  • Code Blocks Formatting: The function correctly formats both source code and example blocks for org-mode.
  • Correct Inline Code Enclosure: Inline code enclosed with “~” is replaced with “~”, following org-mode syntax.
  • Unfill Paragraphs: If you use the optional html2org-clipboard-and-unfill-paragraph function, it will “unfill” the paragraphs in the converted text, removing unwanted line breaks. This function relies on Steve Purcell’s awesome unfill package, which you’d need to install.

Installation

To install ChatGPT2Org, download the chatgpt2org.el file to your local system. Then, add the directory containing this file to your load-path and use use-package to load the ChatGPT2Org package:

(add-to-list 'load-path "/path/to/chatgpt2org/")
(use-package chatgpt2org)

Replace ~”path/to/chatgpt2org”~ with the actual path to the directory containing chatgpt2org.el.

If you do not have use-package installed, you can load the file directly:

(load "/path/to/chatgpt2org.el")

Usage

After installing the package, you can invoke the chatgpt2org function in any buffer by using M-x chatgpt2org. This command retrieves the content from your clipboard, processes it, and pastes the resulting formatted content at your cursor position.

Dependencies

ChatGPT2Org may require Emacs 24.3 or later. The optional html2org-clipboard-and-unfill-paragraph function requires unfill-paragraph, provided in Steve Purcell’s unfill.

License

ChatGPT2Org is distributed under the MIT License. See the LICENSE file for more details.

Acknowledgments

The initial core functionality of this package is based on a solution provided in an answer on the StackExchange Emacs site (link). The code evolved over time to eliminate unwanted characters. Once ChatGPT was released, I used it to add cleanup functions specifically optimized for parsing HTML copied from ChatGPT.

About

ChatGPT2Org: Emacs package to copy-paste HTML content into org-mode, specifically optimized for pasting conversations from OpenAI's ChatGPT. Copy-paste browser-copied content directly into Emacs in clean, parsed org-mode format.


Languages

Language:Emacs Lisp 100.0%