Convert OpenOffice.org Writer Rich Text to BB Code

I’m part of a little writing group forum. It’s been a good experience to push myself to put down my ideas and also receive valuable feedback from other (more skilled) writers. I have so many ideas but I don’t like to start writing something unless I’m committeed to getting it done, so this group has been a good challenge for me.

Anyway, I usually write in OpenOffice.org Writer and then share my piece as a PDF. But this session we’re sharing on a forum. So if I copied and pasted my italics and any other formatting are lost. I looked for a Firefox add-on or Greasemonkey script to convert rich text to forum BB code but no dice. Sure, one could just write the [i] [/i] tags around italic text but that wouldn’t require any slick conversion and thus wouldn’t garner any style points.

Just now I discovered a way to use Writer’s Find & Replace dialog with regular expressions to grab all italic text and wrap it in the BB tags. Like so:

  • In the Find & Replace dialog, click More Options and check Regular expressions.
  • Click Format, and select ‘Italic’ typeface under the Font tab. Click OK.
  • In Search for enter .+ (find one or more characters).
  • In Replace with enter [i]$0[/i] (wrap found string in tags).
  • Click Replace All to make the changes. Note that the italicized text will still be in italics.

Sweet! RegExp ftw!

Leave a Reply