# Extra spaces added to markdown with rich text pasted

**URL:** https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769
**Category:** Bug
**Created:** [3월 28, 2019, 2:02오전 UTC](https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769 "2019-03-28T02:02:09Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![bts](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bts/32/184556_2.png) [@bts](https://meta.discourse.org/u/bts)
#### Post date: [3월 28, 2019, 2:02오전 UTC](https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769/1 "2019-03-28T02:02:09Z")

</div>

Not sure if this is intentional / necessary for Markdown related reasons, but just noticed when I pasted some rich text into the composer, strings with formatting (bold / italic) seem to have extra spaces inserted before and after the `*` or `**` tags.

See example here e.g. the URL in the quoted text or the bolded ` **SPRING2019** ` near the bottom.

 ![13%20PM](https://global.discourse-cdn.com/meta/original/3X/f/6/f6a678b77a013bcb5744d24fe8df0e1ffc1b8e16.png)

The quoted text above was copied from a web page; the below “sale” text copied from an email. Not sure if this always happens but at least two sources where I’m seeing it.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [3월 28, 2019, 2:02오전 UTC](https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769/2 "2019-03-28T02:02:58Z")

</div>

> [@bts](#):
>
> strings with formatting (bold / italic) seem to have extra spaces inserted before and after the `*` or `**` tags.

This bug has existed for quite a while @vinothkannans I’ve noticed it many times.

---

<div class="post-metadata">

### Author: ![StevenTammen](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@StevenTammen](https://meta.discourse.org/u/StevenTammen)
#### Post date: [9월 22, 2019, 9:15오후 UTC](https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769/4 "2019-09-22T21:15:22Z")

</div>

I’ve tested this issue pasting text copied from email (Gmail), Google Docs, Microsoft Word, and ordinary HTML webpages – all these content sources lead to extra spaces being added around bold and italic text. Inline code blocks also have extra spaces added, but strike-through text does not. For example, if I paste text off of my website into the editor, here’s what happens:

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/2/7225580fe1b822f9317f7606b7a0252c7cdc5e48.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/9/7991d90bfd98e6ef227448caca78bfc164649143.png)

Since the automatic conversion into WYSIWYG Markdown is so handy, I’ve found myself pasting into the editor and then using a regular expression in a different program (e.g., Vim, Notepad++) to remove the extra spaces, and then pasting back. It’s a bit hackish, but still easier than saving a file and using Pandoc to get the Markdown.

So long as adding the spaces isn’t somehow required for RTF/HTML pasting, it would be a good thing _not_ to add them, right?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [11월 6, 2020, 4:36오전 UTC](https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769/7 "2020-11-06T04:36:36Z")

</div>

다음과 같이 이제 수정되었습니다:

> <https://github.com/discourse/discourse/pull/11130>
>
> No-break spaces were the reason for double spaces when pasting text to the compo…ser.
> 
> !\[swlVqJAEAN\](https://user-images.githubusercontent.com/72780/98202722-b0f72e00-1f86-11eb-8ca1-8cf406b2bcea.gif)
> 
> https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769

🎊

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [11월 6, 2020, 4:36오전 UTC](https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769/8 "2020-11-06T04:36:39Z")

</div>


