Summary | Unformatted Code Detector detects unformatted code and gives a warning before posting. | |
Preview | Preview on Discourse Theme Creator | |
Repository Link | https://github.com/discourse/unformatted-code-detector | |
New to Discourse Themes? | Beginnerās guide to using Discourse Themes |
Install this theme component
Features
Users posting unformatted code will see a warning message instructing them how to format it correctly.
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.
ā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.
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: