==> Discourse-post-process <==
I’m happy to introduce this simple but powerful Node.js script that uses the Discourse API to mass-modify Discourse posts. It essentially performs a regexp-based search & replace across all posts in a forum.
After migrating a few thousand posts from MyBB to Discourse, there was various little tweaks that needed to be made (fix BBCode → Markdown conversion, re-attach attachments, fix @username mentions when the usernames have changed etc.) I’m not a Ruby coder, and writing a simple Ruby script to post-process posts was non-trivial. Using the Discourse API was much easier.
- Apply a set of regexp-based transformations to each post, such as replacing BBCode tags with Markdown ones, e.g.
- Mention as the edit reason all transformations that have been applied
- Warn about patterns that may cause rendering problems, such as unconverted
[list]s or newlines in nested quotes.
- Warn about potentially missing attachments
- Detect whether
[color=]tags have been used (install the bbcode-color plugin to support colors)
- Fix quotes that have been incorrectly imported from MyBB (or other forums)
I’ve tested the script manually on ~500+ posts in the Quantified Self Forum / Zeo thread and am quite satisfied with it.