# WP Discourse HTML Format not carried over

**URL:** https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939
**Category:** WordPress
**Created:** [7월 27, 2017, 4:09오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939 "2017-07-27T16:09:27Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![dgrant](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dgrant/32/75557_2.png) [@dgrant](https://meta.discourse.org/u/dgrant)
#### Post date: [7월 27, 2017, 4:09오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/1 "2017-07-27T16:09:27Z")

</div>

I’m not sure if it is the plugin or a limitation somewhere in Discourse that is preventing the formatting of a Wordpress post from being carried over into discourse properly.

For example this Wordpress post has a table and a link to a YouTube video.  
[http://electronorama.com/all-about-solder/](http://electronorama.com/all-about-solder/)

However these are not rendered in the forum post  
[https://forum.electronorama.com/t/all-about-solder/32](https://forum.electronorama.com/t/all-about-solder/32)

BTW the link to the original article is link in the forum is surrounded in ‘small’ tags. I would suggest it would be better to have a css class to make styling it easier.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [7월 27, 2017, 5:37오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/2 "2017-07-27T17:37:28Z")

</div>

The issue with formatting is happening on the Discourse end. It is stripping out the `table` and `iframe` tags from the WordPress post. You can see how it works by creating a topic through the Discourse composer with `table` and `iframe` tags. The tags and the content inside of them will be removed.

It looks like you are using an iframe for displaying Youtube videos on your WordPress site. You can get videos to display on both WordPress and Discourse by just adding a link to the video on it’s own line in your WordPress post. If the video link is the first item in the post, you need to add a blank line above it.

```plaintext
This is a post with a Youtube video.

https://www.youtube.com/watch?v=sg209CadVQM&list=PL41PZuZMej3etzs5aj6R0EQ5S528otfec

```

I don’t see a good simple solution for displaying a table from a WordPress post in a Discourse topic. I’ll look at it a bit more and see if I can come up with something.

> [@dgrant](#):
>
> BTW the link to the original article is link in the forum is surrounded in ‘small’ tags. I would suggest it would be better to have a css class to make styling it easier.

The problem with this is the same as with `iframe` and `table` tags. If a class is added on the WordPress end it is stripped out when the post is parsed by Discourse. Discourse styles the `small` tag with `font-size: 9px`. To my eyes this is too small for any text. You can add a custom style to your forum to change that. If you only want it to effect `small` tags in posts, `.cooked small { font-size: 80%; }` should work.

---

<div class="post-metadata">

### Author: ![dgrant](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dgrant/32/75557_2.png) [@dgrant](https://meta.discourse.org/u/dgrant)
#### Post date: [7월 27, 2017, 6:12오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/3 "2017-07-27T18:12:40Z")

</div>

Thanks for replying

> [@simon](#):
>
> It looks like you are using an iframe for displaying Youtube videos on your WordPress site. You can get videos to display on both WordPress and Discourse by just adding a link to the video on it’s own line in your WordPress post. If the video link is the first item in the post, you need to add a blank line above it.

The peculiar thing is that I pasted the link into the Wordpress post (in Text mode) so the iframe seems to have been added by Wordpress or something. I’ll have to see if I can find out why that is happening.

> [@simon](#):
>
> I don’t see a good simple solution for displaying a table from a WordPress post in a Discourse topic. I’ll look at it a bit more and see if I can come up with something.

It would seem to be a useful thing to be able to insert tables into Discourse, I wonder why they strip them out and if they might change that?

> [@simon](#):
>
> The problem with this is the same as with `iframe` and `table` tags. If a class is added on the WordPress end it is stripped out when the post is parsed by Discourse. Discourse styles the `small` tag with `font-size: 9px`. To my eyes this is too small for any text. You can add a custom style to your forum to change that. If you only want it to effect `small` tags in posts, `.cooked small { font-size: 80%; }` should work.

I agree 9px is way too small and the css override will work for now. It seems however that by placing small tags on the link it is breaking the separation of content and style. I can see that the limitations all seem to be from the way Discourse strips html, has this been discussed with the DIscourse developers about perhaps changing it even if it is only for people with admin accounts if security is a concern?

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [7월 27, 2017, 6:15오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/4 "2017-07-27T18:15:48Z")

</div>

> [@dgrant](#):
>
> It would seem to be a useful thing to be able to insert tables into Discourse, I wonder why they strip them out and if they might change that?

The onebox is supposed to be a teaser for the content, not the content itself. I expect that tables are troublesome because they are much harder to summarize into a fixed height area, and Discourse relies very heavily on known content sizes for layout.

---

<div class="post-metadata">

### Author: ![dgrant](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dgrant/32/75557_2.png) [@dgrant](https://meta.discourse.org/u/dgrant)
#### Post date: [7월 27, 2017, 6:19오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/5 "2017-07-27T18:19:56Z")

</div>

I have found the problem with the iFrame. Since Wordpress 4.4, they merged the oEmbed feature into the core and this is inserting an iFrame. Perhaps there is some way for the plugin to parse the iframe tag and strip it down to the link only before importing into a Discorse post?

---

<div class="post-metadata">

### Author: ![dgrant](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dgrant/32/75557_2.png) [@dgrant](https://meta.discourse.org/u/dgrant)
#### Post date: [7월 27, 2017, 6:24오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/6 "2017-07-27T18:24:07Z")

</div>

In a way I would prefer it if the ‘Show Full Post..’ button took you to the Wordpress page instead of expanding the post to show the full content. But the full post is there and most people will click that so having the table would be useful. But when I said tables would be useful in discourse, I meant in an ordinary post, there must be times people would like to show a table of some sort in their post, other more antiquated forums have support for tables.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [7월 27, 2017, 6:30오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/7 "2017-07-27T18:30:00Z")

</div>

Previously Discourse did not support tables in posts without a plugin. With the new markdown engine that has changed, and tables can be added without a plugin. Maybe the next version of this plugin will be able to import tables for that “Show Full Post…” feature.

---

<div class="post-metadata">

### Author: ![dgrant](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dgrant/32/75557_2.png) [@dgrant](https://meta.discourse.org/u/dgrant)
#### Post date: [7월 27, 2017, 6:40오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/8 "2017-07-27T18:40:05Z")

</div>

If the new the new markdown engine supports tables then in theory it should just be a case of whitelisting the table tags on imported content?

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [7월 27, 2017, 7:24오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/9 "2017-07-27T19:24:31Z")

</div>

The markdown engine supports _markdown_ tables. Inside the engine those get coverted to HTML, but I’m not sure all tables would be easily converted so markdown. I’m not familiar with the syntax, and off-hand don’t know if row or column spans are available, fore example. As markdown tries to be a super simple syntax that looks good as plain ASCII, I can imagine a lot of the configurability of the HTML version is simplified away.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [7월 27, 2017, 7:25오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/10 "2017-07-27T19:25:01Z")

</div>

> [@dgrant](#):
>
> I have found the problem with the iFrame. Since Wordpress 4.4, they merged the oEmbed feature into the core and this is inserting an iFrame.

I’ve tried this out. WordPress is inserting the iframe when it displays the post. It doesn’t save it to the database. You can get a Youtube video to display on both WordPress and Discourse if you select the [WP Discourse](https://github.com/discourse/wp-discourse) Publishing option ‘Use Full Post Content’. If you are publishing the full post to Discourse, you can remove the Show Full Post button by deselecting the Discourse ‘embed truncate’ option. (Go to your Discourse settings and search for ‘truncate’.)

To display a Youtube video in a truncated post, you need to whitelist iframes for the Youtube URL in a Discourse plugin. The downside of doing this is that it will allow all your users to embed Youtube iframes in posts.

There is an issue with Youtube videos, or any content that should be oneboxed, when it appears on the first line of a post that’s published from WordPress to Discourse. This should be fixed.

> [@dgrant](#):
>
> I can see that the limitations all seem to be from the way Discourse strips html, has this been discussed with the DIscourse developers about perhaps changing it even if it is only for people with admin accounts if security is a concern?

I think there has been some discussion about it. I don’t think it’s something they are interested in changing, but I could be wrong about that. You can whitelist HTML tags and classes through a Discourse plugin. This is probably the best approach for getting tables to display on Discourse from WordPress published posts.

---

<div class="post-metadata">

### Author: ![dgrant](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dgrant/32/75557_2.png) [@dgrant](https://meta.discourse.org/u/dgrant)
#### Post date: [7월 28, 2017, 1:06오전 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/11 "2017-07-28T01:06:12Z")

</div>

> [@simon](#):
>
> option ‘Use Full Post Content’

Having switched to ‘Use Full Post Content’ and turned off truncate, both the Table and YouTube video show up in the post. Any ideas why there is a difference between the truncated and non-truncated versions?

---

<div class="post-metadata">

### Author: ![carbonrich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carbonrich/32/274219_2.png) [@carbonrich](https://meta.discourse.org/u/carbonrich)
#### Post date: [10월 6, 2022, 5:38오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/13 "2022-10-06T17:38:45Z")

</div>

특정 출력을 스타일링하는 데 사용할 수 있는 HTML을 포함하는 방법을 아시는 분이 계신가요?

Discourse는 태그와 같은 요소조차 제거하는 것 같습니다.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [10월 7, 2022, 1:53오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/14 "2022-10-07T13:53:11Z")

</div>

Discourse에서 게시물의 HTML 출력을 제어할 수 있는 유일한 방법은 Discourse 자체의 플러그인이나 테마를 사용하는 것입니다. 보안 및 사용자 경험(UX)상의 이유로 허용되는 HTML 태그와 속성은 엄격하게 관리됩니다.

---

<div class="post-metadata">

### Author: ![carbonrich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carbonrich/32/274219_2.png) [@carbonrich](https://meta.discourse.org/u/carbonrich)
#### Post date: [10월 8, 2022, 9:12오전 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/15 "2022-10-08T09:12:04Z")

</div>

Angus 씨, 감사합니다. 허용된 태그에 대한 참고 자료가 있는지 알고 계신가요?

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [10월 10, 2022, 1:43오후 UTC](https://meta.discourse.org/t/wp-discourse-html-format-not-carried-over/66939/16 "2022-10-10T13:43:21Z")

</div>

기본 목록은 여기에 있습니다

[https://github.com/discourse/discourse/blob/main/app/assets/javascripts/pretty-text/addon/allow-lister.js#L115](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/pretty-text/addon/allow-lister.js#L115)
