After searching around the forum here, I think I might be looking for rake posts:remap, but it wasn’t clear whether it works with regex. This is what I’m trying to do:
During an import, a couple of things in the raw post content needs updating:
The [quote] tags aren’t always in the format that Discourse expects, so I want to change things like this:
[quote=username]lorem
ipsum[/quote]
to this:
[quote=username]
lorem
ipsum
[/quote]
by inserting \n characters, probably something like \[quote(.*?)\] to \[quote$1\]\n and \[/quote\] to \n\[/quote\] whenever needed. (I still need to look up Ruby regex syntax.)
The images also broke because we moved to a subdomain, so tags like this:
<img src="/files/some/path/image.jpg" alt="some alt text">
have to be updated to
<img src="https://example.com/files/some/path/image.jpg" alt="some alt text">
Is rake posts:remap what I’m looking for, and is this general syntax correct?
rake posts:remap["\[quote(.*?)\]","\[quote$1\]\n"]
(I know my regex is wrong, but I’m going to figure that out later tonight.)
Would I run something like that once for each change, or is there a way to do both in one pass?