Global replace for bbcode [code] with backticks

Dear all,

I’ve just tried to run the many examples for a global find-and-replace here in this forum but struggled with two things:

  1. How do I run these rake posts: ... commands? When I type the command at the command line I just end up with a new line showing a >. I’ve never done anything with Ruby so far.
  2. How can I replace the string “[code]” with “```” followed by a newline?
  3. Can I search also for a newline so that only replace “[code]” that follows a newline?

Sorry for all these noob questions but I’m new to Discourse and in the midde of a large website relaunch :confused:

Eric

I solved the problem (sleeping over it revealed the problem). I typed:

rake posts:remap["[code]","```"]

The three backticks where interpreted by the shell and so caused it to ask me to complete the command. Therefore the additional prompt that I confused for a rake prompt.

Replacing now.

Eric

I think you are also going to need to replace [/code] also maybe you need a newline.

Done exactly that. I replaced [code] with \n and three backticks, and [/code] with three backticks and \n. Looks fine now. In the end I used Postgres instead of remap because I couldn’t get it to insert the newlines correctly.

We do want to get that sorted in our remap somehow, for sure.

rake posts:remap의 정규식 치환을 사용해도 줄바꿈을 삽입할 수 없습니다. 이것이 아예 불가능한지 모르겠습니다.

Q: 데이터베이스를 통해 업데이트를 수행할 경우, 원본(raw)과 렌더링된(cooked) 버전 모두를 수정해야 하는지, 아니면 원본만 업데이트하면 렌더링된 버전이 자동으로 갱신되는지, 혹은 갱신을 위해 특정 작업을 수행해야 하는지 궁금합니다.

데이터 익스플로러 플러그인은 쿼리(Queries)만 수행하고 UPDATE를 수행하지 않는다고 가정하고 있습니다.