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.
Features
Apply a set of regexp-based transformations to each post, such as replacing BBCode tags with Markdown ones, e.g. [hr] with ---
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)
Can you tell me, how tailored is this to MYBB. I’m considering running it on PHPBB imported data. And i’m just wondering if there are any gotcha’s i should watch out for?
I’ve run my script in batches just to make sure it wouldn’t break too many posts at once, and without any rate limits added or disabled. I think the largest batch was 1000 posts or so, but I haven’t run into Discourse limits.