Posts on-save processing with regex/replace configurable in admin panel

If often fix minor issues in posts manually going through all of the posts on my forum on a daily basis. It turns out that most of the issues are typical and I could write a regex/rewrite rule to force the fix as soon as the message is posted or edited.

It would be nice to have such a section in admin panel with a set of rules, 2 inputs each:

  1. Regex (optionally introduces regex references)
  2. Replace with (optionally uses regex references)

Examples

  • Make empty lines between paragraphs
  • Place space after comma if not inside a number (this rule is specific to Russian / Ukrainian locale)
  • Remove links to websites from which smile embed codes were copied, i.e. [url=...][img...][/url]
  • Place large images on their own lines and enforce an empty line before and after

Have you tried doing any of this with a plugin utilizing “Dialect”?

Nope, may you please clarify what you mean.

Something like the Pirate Speak plugin. eg.
post text is passed into an anonymous function

Discourse.Dialect.postProcessText(function (text)

and a custom function “parses and manipulates” the text

3 Likes

I see. No, my proposition is actually about a different thing. It may be a plugin, but configurable by admin, not hardcoded per-forum.