# Unformatted Code Detector

**URL:** https://meta.discourse.org/t/unformatted-code-detector/112773
**Category:** Theme component
**Tags:** official, unformatted-code-detector
**Created:** [March 28, 2019, 4:21am UTC](https://meta.discourse.org/t/unformatted-code-detector/112773 "2019-03-28T04:21:55Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [March 28, 2019, 4:21am UTC](https://meta.discourse.org/t/unformatted-code-detector/112773/1 "2019-03-28T04:21:55Z")

</div>

| | | |
| --- | --- | --- |
| :discourse2: | **Summary** | **Unformatted Code Detector** detects unformatted code and gives a warning before posting. |
| :eyeglasses: | **Preview** | [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/unformatted-code-detector) |
| :hammer_and_wrench: | **Repository Link** | [https://github.com/discourse/unformatted-code-detector](https://github.com/discourse/unformatted-code-detector) |
| :open_book: | **New to Discourse Themes?** | [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) |

Install this theme component

> [@](#):
>
> :discourse2: As this is an #official theme component maintained by the Discourse team, #Support, #Contribute > Bug, #Contribute > UX, and #Contribute > Feature requests can be made in the respective categories here on Meta, and tagged with the appropriate theme component tag. Click on a link below to get one started. :+1:
> 
> [:question:&nbsp; **Support**](https://meta.discourse.org/new-topic?category_id=6&tags=unformatted-code-detector "Ask for support on configuring and using Unformatted Code Detector") [:bug:&nbsp; **Bug**](https://meta.discourse.org/new-topic?category_id=1&tags=unformatted-code-detector "A bug report means something is broken, preventing normal/typical use of the theme component") [:eyes:&nbsp; **UX**](https://meta.discourse.org/new-topic?category_id=9&tags=unformatted-code-detector "Discussion about the user interface of Unformatted Code Detector, and how features are presented (including language and UI elements)") [:bulb:&nbsp; **Feature**](https://meta.discourse.org/new-topic?category_id=2&tags=unformatted-code-detector "Discussion about how existing Unformatted Code Detector features can be improved or enhanced, and how proposed new features could work")

### Features

Users posting unformatted code will see a warning message instructing them how to format it correctly.

 ![Unformatted Code Detector](https://global.discourse-cdn.com/meta/original/3X/6/2/624f9c962a946aaca83e69be73a30f3346e08a09.gif)

Sensitivity and whether it detects HTML are configurable via theme settings.

### Settings

| Name | Description |
| --- | --- |
| emoji icon | The emoji icon to be displayed next to the title in the unformatted warning modal. |
| disable at trust level | Disable warning for users with a trust level of N or higher. -1 = enabled for all users. |
| sensitivity | Sensitivity of the detection algorithm. 0 = plugin disabled; 1 = warn for anything that looks even slightly like code. |
| min post length to check | Minimum post length to check (number of characters) |
| max post length to check | Maximum post length to check (number of characters). -1 = no maximum. |
| include html | Check for HTML tags as well as other types of code. Recommended to disable if users frequently need to render custom HTML in their posts. |

| Translation | Default |
| --- | --- |
| warning\_modal.title | Are you posting code? |
| warning\_modal.content | It looks like your post may contain code or logs. To keep your post readable, please remember to **format your code** using the _Preformatted text_ toolbar button \</\>, or the backtick ` key on your keyboard, like so: [examples] |
| warning\_modal.do\_not\_show\_again | do not show this message again |
| warning\_modal.fix\_post | Edit Post |
| warning\_modal.ignore\_and\_post\_anyway | Post Anyway |

### Debugging

If you receive a warning for a post which doesn’t include any text, you can print debug information by opening the browser JS console, and typing `debugUnformattedCodeDetector()` Enter. This will print some information about which lines were considered ‘code’, and what the sensitivity settings are.

> :information_source: “Do not show this message again” only works per device, not per user. This is a known issue and will be fixed once Discourse gains the functionality to attach user info from themes.

  

> :discourse2: **Hosted by us?** Theme components are available to use on our Standard, Business, and Enterprise plans.

> Last edited by @JammyDodger 2024-06-16T11:48:08Z
> 
> > **Check document**
> >
> > Perform check on document:

---

_[View the full topic](https://meta.discourse.org/t/unformatted-code-detector/112773)._
