Copy-and-paste rendered version (no markdown) from the editor

I’m not sure if this is a real request for a feature that doesn’t exist, or a request for help figuring out how to use a feature that does exist, with or without a plugin, but what I want to be able to do is copy from Obsidian and paste to something else, without markdown.

Use case or problem

I do a lot of my writing in Obsidian, because it’s easy to break it into blocks that way. So I can make each book chapter, for instance, a note, and it’s easy to move things between them.

But eventually, I have to be able to copy the whole thing out and paste it into a word processor document – at which point, I find myself having to spend a ton of time going back through the text and manually converting all the text from markdown to its proper formatting.

Proposed solution

I’d like to have some option to “copy as” that will let me paste into a standard word processor with the target formatting. It seems like this should be doable, given that Obsidian can export to PDF and it can display in the reader view as the “final” formatted result. But as far as I can tell, there’s no way to get that reader-view or PDF-output in anything I can paste.

Current workaround (optional)

No known workaround; just a lot of manual reformatting.

2 Likes

Hello a2jc4life,

Even though I do not have a direct solution for converting markdown to its proper formatting as you suggest, I can point out that you can copy/paste without formatting using “Ctrl + C” to copy and then “Ctrl + Shift + V” to paste on your word processor, instead of the classic ‘Ctrl + V’.

This may potentially help you to format faster while waiting for a proper solution (e.g, instead of deleting the markdown format to put the text in bold, you can directly put the text in bold; instead of deleting the brackets of a link redirect, you can directly insert the hyperlink, etc.).

Note: Be aware that even though “Ctrl + Shift + V” is the most common shortcut for this feature, some processors like Word require a button to be used or have another shortcut set for this feature, as suggested on the link I provided earlier.

1 Like

That doesn’t strip the markdown, though, because the markdown doesn’t copy from Obsidian as formatting – it just copies as part of the text. So I end up with text in the word processor that’s full of extra hash marks, asterisks, etc.

(This isn’t a solution or anything, sorry.) Are you copying from live preview mode or reading mode?

If I copy/paste from reading mode, I get the formatting. Unfortunately, it doesn’t seem to be smart formatting, like headings, etc. At least in Pages in MacOS where I quickly tested. It just pastes it as “default” text with all the styling.

And unfortunately, it copies the background color too, from dark mode. It also pastes with double-spacing and adds extra bullets. But at least it doesn’t paste in the Markdown symbols, so it might be easier to then apply some of your document’s style templates.

2 Likes

thanks rigmarole, I was about to suggest that (and the relative known bug).
I think there is a plugin that does a similar thing from the editor/LP, it’s called “Copy as HTML”.

2 Likes

Ooooh; never mind. Last time I tried this, it was not possible to copy/paste from reading mode – only from editing mode (hence the issue). But it looks like now you can copy from reading mode, which makes this a non-issue.

2 Likes

I renamed this FR, let’s keep it open.

3 Likes

Hee-eey thanks @a2jc4life for bringing this up, and everyone else for chiming in. I just did a quick test, and saw the formatting issue @rigmarole mentioned. In Google Docs I was able to use the ‘Clear Formatting’ command after pasting my content, and it removes the black background while keeping the formatting largely intact! So for me, for now, this is a useable workaround that allows me to work in Obsidian and quickly print when I need to.

Yes, would love to see the export to specific target (like Google Docs) become a feature. Thank you!

Let me assure you that your desire to emancipate your text from the shackles of markdown is not merely a frivolous whim, but a pursuit of the highest aesthetic order. Obsidian, while a darling for organization, can leave one’s prose looking like a crumpled discount bin frock.

With a Sprinkle of Techno Dust,
Tanuki505

import pyperclip
import markdown
from bs4 import BeautifulSoup

def convert_clipboard_content_to_text():
    """
    This script converts the content from the clipboard, assumed to be markdown, to plain text and saves it to a file.
    
    Installation:
    1. Make sure Python is installed on your system. If not, download and install Python from https://www.python.org/downloads/
    2. Install the required Python packages by running the following command in your command prompt or terminal:
        pip install markdown beautifulsoup4 pyperclip
    
    Usage:
    1. Copy the markdown content you want to convert to your clipboard. You can do this by selecting the text and pressing Ctrl+C (or Command+C on a Mac). windows + v for clipboard history.
    2. Run this script by typing the following command in your command prompt or terminal and pressing Enter:
        python convert_clipboard_md_to_text.py
    3. The script will convert the markdown content from your clipboard to plain text and save it to the clipboard.
    """
    # Get markdown content from clipboard
    markdown_content = pyperclip.paste()
    
    # Convert markdown to HTML
    html_content = markdown.markdown(markdown_content)

    # Extract text from HTML
    text_content = ''.join(BeautifulSoup(html_content, "html.parser").findAll(string=True))

    # put the content on the clipboard
    pyperclip.copy(text_content)


if __name__ == "__main__":
    convert_clipboard_content_to_text()