Star Wars RP

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Formatting Recovery

LE-X1

Lexon
Writer
For those of you doing recovery, I wrote a short macro to convert HTML code to BBCode and regular line breaks. It can't do anything with images (too specialized a string for my know-how), but it handles bold, italics, underline, and line breaks.

It won't hit everything, depending on how you copy-paste the HTML code, but since Google and its cached archive can't edit or quote our posts, the best way to preserve formatting is to:

1. View the source of the page (right-click > View page source in Chrome, or right-click > View source in IE; using the Windows menu and going to View > Source also works in IE, as does Ctrl+U; I don't remember how to get there in Firefox, and I don't have it installed at the moment).

2. Copy the post. (Easiest way to do this is find a sentence in the post you want, copy it, then go to the source, hit Ctrl+F, paste the sentence in the find dialog, and it'll take you straight there. Chances are, the post will be in one giant block of text, separate from everything else, which will be on its own line.)

3. Paste the post, HTML code and all, into Microsoft Word. If you have 2007 or later, go to the View tab, and click the Macros button. Type in a name for your macro (doesn't matter what, just no spaces). Click Create. Copy-paste the following code into the macro editor, between the green apostrophes and "End Sub":

Code:
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "<strong>"
        .Replacement.Text = "[b]"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "</strong>"
        .Replacement.Text = "[/b]"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "<em>"
        .Replacement.Text = "[i]"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "</em>"
        .Replacement.Text = "[/i]"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ActiveWindow.ActivePane.VerticalPercentScrolled = 8
    ActiveWindow.ActivePane.VerticalPercentScrolled = 2
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "<u>"
        .Replacement.Text = "[u]"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "</u>"
        .Replacement.Text = "[/u]"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "&nbsp;"
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ActiveWindow.ActivePane.VerticalPercentScrolled = 0
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "<br>"
        .Replacement.Text = "^11"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ActiveWindow.ActivePane.VerticalPercentScrolled = 0
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
4. Close the macro editor.

5. Click the Macros button again. In the macro dialog box, select the macro you just created and click "Run."

6. For every post you want, repeat steps 1, 2, and 5.

The macro will set all HTML code for bold, italics, and underline to the corresponding BBCode, and it will insert line breaks everywhere there is a <br> code, which should restore your average post to the pretty format you created it in originally. It will also convert the HTML code for a space (&nbsp;) into a space.

Now, this is probably waaaay too much work for the average post, IC or OOC, but for any post in which you want to retain the original formatting, this is still less work than tediously going through the post and adding tags where they should go. It's probably most useful for tech submissions and character sheets.

I could probably add to the macro if people want alignment fixes, too. Doing this with text size and color, like images, is beyond my know-how.

Perhaps you won't find it useful, but I did, so I thought I'd post it.
 
Top