Replace tab character with rake task?

I’ve got a bunch of posts with lines that start with a tab character (	), and they look like this:

The first line of a paragraph 

is shown as preformatted text.

rake posts:remap["	","\ "] is not finding anything to remap. Is there a way to replace the tab character?

2 Likes

Try

rake posts:remap["\t","\ "]

Are you sure, Jay?

Are you sure you want to replace all string occurrences of 't' with ' '? (Y/n)

I migh end up wi h a lo of missing ee h! :grimacing:

1 Like

No. I’m not sure. But if that’s the message you got, you might try

rake posts:remap["\\t","\ "]

I get an identical confirmation message as with a single backslash.

1 Like

Hmm. Maybe

rake posts:remap['\t',"\ "]

Still the same message…

Perhaps the task needs to be told explicitly to use regex with a type argument?

https://github.com/discourse/discourse/blob/master/lib/tasks/posts.rake#L154-L155

Edit:

rake posts:remap["\t","\ ",regex]
Are you sure you want to replace all regex occurrences of 't' with ' '? (Y/n)

But, I am still not sure if this would remove all t characters.