# Disabling HTML entities in posts

**URL:** https://meta.discourse.org/t/disabling-html-entities-in-posts/65860
**Category:** Support
**Created:** [July 8, 2017, 2:37pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860 "2017-07-08T14:37:22Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![farmdawgnation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/farmdawgnation/32/74924_2.png) [@farmdawgnation](https://meta.discourse.org/u/farmdawgnation)
#### Post date: [July 8, 2017, 2:37pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/1 "2017-07-08T14:37:22Z")

</div>

Hi there,

I’m working on trying to migrate a google group to a Discourse forum and am having some issues with HTML being posted in emails. The mailing list is for a web framework, so folks posting HTML back and forth is pretty common. Since the emails we’re trying to import were coming from a system that didn’t support markdown, these HTML segments wouldn’t include code fences around them and there are too many to manually edit.

As a compromise, I’d like to disable HTML entities in posts completely. While searching the forum for this I saw @codinghorror mention that @eviltrout added a mode where this was possible, but I couldn’t find the magic setting in my admin panel.

Does anyone know how to flip Discourse into this mode?

Thanks!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 8, 2017, 3:22pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/2 "2017-07-08T15:22:43Z")

</div>

Without thinking about it too hard, I think that the thing to do might be to encode the HTML tags before the import. It sounds like it might be safe enough to just convert all of the `<`s and `>`s into `&lt;`s and `&gt;`s.

---

<div class="post-metadata">

### Author: ![farmdawgnation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/farmdawgnation/32/74924_2.png) [@farmdawgnation](https://meta.discourse.org/u/farmdawgnation)
#### Post date: [July 8, 2017, 3:45pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/3 "2017-07-08T15:45:11Z")

</div>

The problem is these are mbox files so that transformation would have to try and distinguish between parts of the mbox and HTML. 😕

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 8, 2017, 3:52pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/4 "2017-07-08T15:52:37Z")

</div>

You could also modify the import script to pass the body through a filter at that point.

---

<div class="post-metadata">

### Author: ![farmdawgnation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/farmdawgnation/32/74924_2.png) [@farmdawgnation](https://meta.discourse.org/u/farmdawgnation)
#### Post date: [July 8, 2017, 4:00pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/5 "2017-07-08T16:00:51Z")

</div>

That’s true. Although I’ll admit I’m also concerned about folks interacting with our community via email. Including HTML without a fence should, ideally, only render uncolored HTML. Anything else will likely cause frustration.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 8, 2017, 4:07pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/6 "2017-07-08T16:07:38Z")

</div>

Oh. That’s a bigger problem. I have a BS in computer science and a PhD in education. I have learned that programming people is lots harder than programming computers.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [July 9, 2017, 10:13pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/7 "2017-07-09T22:13:30Z")

</div>

There’s no mode to disable HTML entities that I recall. There is a type of post you can mark as HTML (see the mbox importer for an example) and no cooking or processing will be done.

---

<div class="post-metadata">

### Author: ![farmdawgnation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/farmdawgnation/32/74924_2.png) [@farmdawgnation](https://meta.discourse.org/u/farmdawgnation)
#### Post date: [July 9, 2017, 10:34pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/8 "2017-07-09T22:34:52Z")

</div>

Got it. I don’t think that would be desirable either.

What I really need is something that, upon seeing raw HTML in a post, will escape the HTML _before_ the Markdown processor converts Markdown to HTML. In poking around the code I noticed that there’s a tags whitelist of sorts, so I could see just disabling that as a possibility. Or, potentially, preprocessing the text before the markdown processor runs.

Are either of these doable in the form of a plugin?

Thanks!

---

<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: [July 9, 2017, 10:52pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/9 "2017-07-09T22:52:12Z")

</div>

Yeah the new markdown engine has a rule for dealing with HTML tags it could be replaced in a plugin, but what you would have at the end of the process is not CommonMark, it is some sort of mister hydra

---

<div class="post-metadata">

### Author: ![farmdawgnation](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/farmdawgnation/32/74924_2.png) [@farmdawgnation](https://meta.discourse.org/u/farmdawgnation)
#### Post date: [July 9, 2017, 10:54pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/10 "2017-07-09T22:54:53Z")

</div>

Yeah, that’s unfortunate but for certain communities I think the trade off would be worth it. Thanks!

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:44pm UTC](https://meta.discourse.org/t/disabling-html-entities-in-posts/65860/11 "2024-06-08T12:44:27Z")

</div>

This topic was automatically closed after 2526 days. New replies are no longer allowed.
