HTML/RTF pasting

There is a built in browser feature which already does what you want. Has nothing to do with Discourse.

Press Ctrl+Shift+V to Paste Text Without Formatting in Google Chrome. Text pasted into your browser, when using a rich text editor like the one found in Gmail, automatically takes on the formatting of the source text.

Source: Google Chrome Blog: Tip: Just the text, please!

6 Likes

18 posts were split to a new topic: Help us to test the HTML pasting

Thank you for working on this cool feature!
I’ve noticed that when you copy and paste some content from a web page that has text and images, the following happens:

  • the text formatting works well
  • however images show as a broken image icons
  • some time after saving such post, the “System” user makes an edit to re-upload the images and those images show up well.

It was pretty confusing to see that the images don’t show up and I tried several times, which is bad for UX.
Would it be possible to trigger image uploads immediately after pasting the text into Composer?

1 Like

Sure. Can you share a example web content (URL) where you facing this problem?

4 Likes

Yep. Here’s an example:
I copied the header and the first image and below you can see how it looks like when pasted (image doesn’t show up, only icon). Source.

Swiss Government Excellence Scholarships for Foreign Scholars and Artists for the 2018–2019 Academic Year

Preview:
image

I am unable to reproduce it both here in meta and in my development environment. Also checked in Chrome, Firefox and IE. May I know which browser and OS you are using.

4 Likes

I see… I’m on MX Linux and using latest Chromium and Firefox, and I can reproduce repeatedly (here on meta too). Thanks for checking, and let me know if I can help test this otherwise. :thinking:

So is HTML-to-Markdown copy-paste a built-in feature now?
No plugins or shortcut keys needed?

It doesn’t seem to be working on my site.

it’s a beta feature so needs to be enabled in the admin settings.

12 Likes

@vinothkannans we got to look at improving internal usage, cause it really can muck stuff up when you cut and paste between posts :boom:


@vinothkannans we got to look at improving internal usage, cause it really can muck stuff up when you cut and paste between posts :boom:

[@vinothkannans](https://meta.discourse.org/u/vinothkannans) we got to look at improving internal usage, cause it really can muck stuff up when you cut and paste between posts ![:boom:](https://d11a6trkgmumsb.cloudfront.net/images/emoji/twitter/boom.png?v=5)

9 Likes

Internal use should be prioritized, for sure… we don’t want to make Discourse-to-Discourse copying and pasting worse.

4 Likes

Using the test document for HTML/RTF paste on Discourse.

I feel like this part used to work and no longer does:

Italicised text with some random bold words.

(instead of)

Italicised text with some random bold words.

Google Doc’s way of styling is changed I guess. Let me check.

2 Likes

It’s fixed. Emojis are now displaying properly. And the click counts are removed from links.

9 Likes

Now they using style attributes instead of em and strong tags :frowning:.

7 Likes

@vinothkannans I’ve noticed what I think is a bug in the HTML copy/paste. When I copy less than (<) and greater than (>) symbols, it pastes them as &lt; and &gt;. Other characters like single quote (’) and double quote (") aren’t escaped, so I found it odd that these were.

From writing this post I also realized that ampersand (&) has the same problem.

1 Like

I just composed and pasted a post from Google Docs into this forum elsewhere and while it strips anything not markdown translatable, bold, italics, and links are delivered flawlessly.

Not a bug, you need to escape those otherwise you’re posting HTML. Which is valid. I can type

This is bold

And it is

> This is <b>bold</b>

2 Likes

Yeah, I see what you mean, for the general case. However, I have a specific case where I think it’s not ideal. When people put HTML inside of formatted text, I think it’s often so that it can be used as a template and copied and pasted unescaped. We recently had a case like this, where we were showing off the new ruby tag support. For example:

<ruby>漢<rt>かん</rt></ruby><ruby>字<rt>じ</rt></ruby>

In such a case, I think it would be appropriate to not escape it.

Current behavior on paste:
<ruby>漢<rt>かん</rt></ruby><ruby>字<rt>じ</rt></ruby>

Desired behavior on paste:
かん

Basically, I would argue that anything in an inline code block like this or multiline code block

like this

should not be escaped when pasted. I think the average user doesn’t know about the paste as plain text option, so I don’t think it’s an acceptable workaround.

What do you think?

use ctrl+shift+v or the other standard built in browser “paste as plain text” keyboard shortcuts in that special case.

4 Likes