Post by lucyolsen on May 31, 2012 22:52:33 GMT -5
Ok, so I saw that people were manually inserting the code to bold the sections of the story to repost here, and I thought there had to be a better way.
Before you begin: adding white space to your documents. In most word processors, you can set paragraph spacing so blank space will appears between paragraphs in your document with only one carriage return. If you only have one carriage return between paragraphs, you need to add another, because that space will not translate in BBCode. I've added a guide on doing this directly below.
Adding a carriage return between paragraphs:
In Word, Find "^p" and Replace With "^p^p" (remove quotes)
In OpenOffice and LibreOffice, click "more options" and check off "Regular Expressions." Then Find "$" and Replace with "\n\n" (remove quotes)
Now on to the coding!
This post is laid out like this:
1) Word manual solution
2) Word macro
3) OpenOffice manual solution (DO NOT USE)
4) OpenOffice macro
5) Adjustments to make to OpenOffice solutions for use in LibreOffice
6) Guide to using macros for all softwares mentioned
7) Standalone editor that converts formatted text to BBCode (NEW)
8) For those with a Mac: An online editor (NEW)
I first started with a solution for Word and then recorded a Macro for it. The manual solution is listed first, then the Macro code. The manual solution describes how to automatically bold the text; you will need to adjust to do italics and underline also (if needed). If you have all three formatting types, you will need to do this three times. If something is both bold and italic, or bold and underline, you will still just need to do this the three times - you do not need to get the formatting exact, you just need some aspect of it in your search. Searching for bold will find something that is both bold and italic.
I have also included a guide to using the macros at the bottom.
In Word, the macro solution covers bold, italic, underline, strikethrough, superscript, subscript, and text alignment
The OpenOffice and LibreOffice solution only covers bold, italic, and underline
You would still need to do section line breaks manually in all softwares.
In Word:
Manual Solution
1) Ctrl+H
2) Click on More >>
3) Click on the find text box and choose Format -> Font
4) Choose Bold. Click ok.
5) In the Replace text box, put [ b ]^&[ / b ] (remove spaces). The "^&" is from choosing Special -> Find What Text.
6) click Replace All
Macro Solution
Here is Macro code in case anyone know how to use it. You can assign it to a button or keyboard shortcut, but I won't detail this because every version of Word is different. Use google. The macro will code for bold, italics, and underlines all at once, so you don't have to do three different find/replaces manually.
OPEN OFFICE SOLUTION HERE!
See below for adjustments to make to make it work in LibreOffice
I've typed up the manual solution first just to follow the format of the Word solution, but I would suggest not using that and just using the macro. The find/replace solution is likely to crash your computer and isn't as neat as Word's find/replace because of the way find/replace works.
Again, this is how to do the bolding. For italics and underline, you'll have to adjust the instructions.
STEP 1
1) Ctrl+F. Click "More Options." Check off "Regular Expressions"
2) Search for: "." (no quotes). Click "Format" and choose BOLD. Click OK.
3) Replace with:[ b ]&[ /b ] (remove spaces)
4) Replace All
This will take a long time and might crash your software. Basically it is bolding each character with separate code.
STEP 2
1) Search For: [ /b ][ b ] (no spaces). Click "no format"
2) Replace with: (null text)
3) Uncheck "Regular Expressions"
4) Replace All
This is now removing the extra code so it is one bold code per paragraph.
The better solution is this Macro. I did not write it but I edited it. It was originally meant for adding HTML tags and then it would unbold or unitalicize the original text. I removed the bit which removed formatting and a bit which converted links and added code for underlines, because the original only did bold and italics.
The end result is not quite as clean as the find/replace solution, but it works a lot faster and won't crash your PC.
It is written in OpenOffice Basic
The original code is here: user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=20324#p118639
LibreOffice Solution
Here are the adjustments you need to make for this to work in LibreOffice
The Macro can be used as is, which I suggest doing anyway.
Adjustments to manual solution
1) You need to use Ctrl+H instead of Ctrl+F
2) Instead of doing it three times, once for bold, italic, and underline, you would also need to do it for bold italic. When you choose bold as the format for the search, it displays as "bold" (in both softwares. In OO, when you choose italic, it shows simply "italic." But in LibreOffice, when you choose italic, it shows "italic, normal" for some reason. So you need to do bold, italic, bold italic, and underline.
Guide to using the macros:
Usually when you copy something from the Proboards forum, you end up with extra text at the bottom which says "Read More:" and has a link to the post. You need to delete that when you paste the code.[/i]
Word
1) Alt+F11
2) If it's blank, just paste the code. If there's something there, go to the bottom and paste the code after "end sub"
OpenOffice and LibreOffice
1) Alt+F11
2) Drill down into My Macros -> Standard -> Module1.
3) Click on Module1 and then click on "Main" in the window on the right. Click "Edit"
4) go to the bottom and paste the code after "end sub"
To run the macro:
Word 2007 and later
1) Click View tab and click "Macros"
2) Either doubleclick on the Macro "ProBoardsFormatCode" or click once and click "run."
Word 2003 and earlier
1) Tools -> Macros -> Macros, and then from there it is the same as in Word 2007.
OpenOffice and LibreOffice
1) Alt+F11
2) Drill down into My Macros -> Standard -> Module1.
3) Either doubleclick on the Macro "textformattoHTML" or click once and click "run."
Standalone application:
WYSIWYG BBCode Editor
This is a installable wysiwyg text editor. All the other other solutions that I've found require a browser and a javascript implementation.
Download from the autohotkey link - it's the most official:
www.shajul.net/111/wysiwyg-bbcode-editor-post/
1) Install and run program
2) Copy the text from your word processor and paste in the upper window. You can paste as much as you want to in the upper window, but it won't generate code if you paste too much. I am not sure what the limit is, but it seems to be able to handle more than a single proboards post can take (60000 characters)
3) In the area between the two windows, there is a pulldown menu. Select "proboards" from it.
4) Check "Ignore font" and "Ignore color"
5) Click "Generate Code" or BBCode -> Generate Code or Ctrl+Down
6) After the code appears, click "copy BBCode"
OPTIONAL: Stripping out the SIZE tags
This software inserts size tags and there is no option to to turn that off. If you pasted the code as is into the proboards window, I believe that the text would turn out larger than you would really want it. And also, since you can only put 60000 characters in a post, you might need to remove these tags for the space.
If the code uses size=4, you would do the following. Adjust if your code says something different.
1) Paste the code in a new document of your word processor.
2) Find "[ size=4 ]" (remove spaces) and replace with "" (null text)
3) Find "[ size=" (remove space) just to check if there were any different sizes other than the one you just replaced, other than the "size=1" that mentions the program (mentioned below). If there are, replace those with null text also.
4) Find "[ / size ]" (remove spaces) and replace with "" (null text)
This program will also insert the following at the bottom:
_________________________
Composed/Posted with WYSIWYG BBCode Editor
You can leave this in or delete it if you want.
Online Editor
For those that can't use the above program
www.ecardmax.com/hoteditor/
HotEditor V.4.4 works with
IE, FireFox, NetScape, Opera 9x, Chrome and Safari 1.3.2 or higher
This editor is really only meant to be a demo of what can be implemented at a board, so please only use this as a last resort. I put this in only for Mac users who won't try the macros, and also because macros are not supported by all versions of Word for mac (but OpenOffice and LibreOffice, and perhaps Word for Windows running on BootCamp or Parallels should be fine, and if you have Parallels or BootCamp, you could just use the standalone editor).
Initial Coding
1) Copy the text from your word processor and paste in the bottom window. Do not paste in too much at a time, as your browser will freeze up. But it can definitely handle the 60000 characters that a proboards post can take.
2) Click "Submit/Preview"
3) The code will appear in the BBCode Output window. Select that and copy and paste back in a new document in your word processor.
Cleaning up the code
1) Clean the SIZE beginning and end tags using the method described in the section for the standalone program
2) Clean up the FONT beginning and end tags using the same method.
3) Find "<o:p>" (no quotes) and replaces with "" (null text)
4) Find "</o:p>" (no quotes) and replaces with "" (null text)
I do not understand why the editor added these in. They seem to do with paragraphs, but I have never seen any code like this.
Things to know about the editor
1) It seems to do weird things with manual line breaks in MS Word (when you hit shift+enter). It handles them fine from OpenOffice If you have any of those you need to replace them with carriage returns. In Word, a manual line break is "^l" (lower case L) and you can replace it with "^p" (paragraph mark).
2) All the extra font tags and size tags take up a lot of space. You might be ok with leaving them in even though the story might look odd, but you also might not be able to fit a single chapter in a post if you leave them.
Before you begin: adding white space to your documents. In most word processors, you can set paragraph spacing so blank space will appears between paragraphs in your document with only one carriage return. If you only have one carriage return between paragraphs, you need to add another, because that space will not translate in BBCode. I've added a guide on doing this directly below.
Adding a carriage return between paragraphs:
In Word, Find "^p" and Replace With "^p^p" (remove quotes)
In OpenOffice and LibreOffice, click "more options" and check off "Regular Expressions." Then Find "$" and Replace with "\n\n" (remove quotes)
Now on to the coding!
This post is laid out like this:
1) Word manual solution
2) Word macro
3) OpenOffice manual solution (DO NOT USE)
4) OpenOffice macro
5) Adjustments to make to OpenOffice solutions for use in LibreOffice
6) Guide to using macros for all softwares mentioned
7) Standalone editor that converts formatted text to BBCode (NEW)
8) For those with a Mac: An online editor (NEW)
I first started with a solution for Word and then recorded a Macro for it. The manual solution is listed first, then the Macro code. The manual solution describes how to automatically bold the text; you will need to adjust to do italics and underline also (if needed). If you have all three formatting types, you will need to do this three times. If something is both bold and italic, or bold and underline, you will still just need to do this the three times - you do not need to get the formatting exact, you just need some aspect of it in your search. Searching for bold will find something that is both bold and italic.
I have also included a guide to using the macros at the bottom.
In Word, the macro solution covers bold, italic, underline, strikethrough, superscript, subscript, and text alignment
The OpenOffice and LibreOffice solution only covers bold, italic, and underline
You would still need to do section line breaks manually in all softwares.
In Word:
Manual Solution
1) Ctrl+H
2) Click on More >>
3) Click on the find text box and choose Format -> Font
4) Choose Bold. Click ok.
5) In the Replace text box, put [ b ]^&[ / b ] (remove spaces). The "^&" is from choosing Special -> Find What Text.
6) click Replace All
Macro Solution
Here is Macro code in case anyone know how to use it. You can assign it to a button or keyboard shortcut, but I won't detail this because every version of Word is different. Use google. The macro will code for bold, italics, and underlines all at once, so you don't have to do three different find/replaces manually.
Sub ProBoardsFormatCode()
'
' ProBoardsFormatCode Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[b]^&[/b]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Italic = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[i]^&[/i]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Underline = wdUnderlineSingle
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[u]^&[/u]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.Alignment = wdAlignParagraphCenter
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[center]^&[/center]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.Alignment = wdAlignParagraphLeft
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[left]^&[/left]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.Alignment = wdAlignParagraphRight
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[right]^&[/right]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.Font
.StrikeThrough = True
.DoubleStrikeThrough = False
End With
With Selection.Find.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[s]^&[/s]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = True
.Subscript = False
End With
With Selection.Find.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[sup]^&[/sup]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = False
.Subscript = True
End With
With Selection.Find.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = "[sub]^&[/sub]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
OPEN OFFICE SOLUTION HERE!
See below for adjustments to make to make it work in LibreOffice
I've typed up the manual solution first just to follow the format of the Word solution, but I would suggest not using that and just using the macro. The find/replace solution is likely to crash your computer and isn't as neat as Word's find/replace because of the way find/replace works.
Again, this is how to do the bolding. For italics and underline, you'll have to adjust the instructions.
STEP 1
1) Ctrl+F. Click "More Options." Check off "Regular Expressions"
2) Search for: "." (no quotes). Click "Format" and choose BOLD. Click OK.
3) Replace with:[ b ]&[ /b ] (remove spaces)
4) Replace All
This will take a long time and might crash your software. Basically it is bolding each character with separate code.
STEP 2
1) Search For: [ /b ][ b ] (no spaces). Click "no format"
2) Replace with: (null text)
3) Uncheck "Regular Expressions"
4) Replace All
This is now removing the extra code so it is one bold code per paragraph.
The better solution is this Macro. I did not write it but I edited it. It was originally meant for adding HTML tags and then it would unbold or unitalicize the original text. I removed the bit which removed formatting and a bit which converted links and added code for underlines, because the original only did bold and italics.
The end result is not quite as clean as the find/replace solution, but it works a lot faster and won't crash your PC.
It is written in OpenOffice Basic
The original code is here: user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=20324#p118639
sub textformattoHTML
rem Thanks to sqykly for markHyperlink @ http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=14896
dim oParaEnum as object
dim oPortEnum as object
dim oPara as object
dim oPort as object
oParaEnum = thisComponent.text.createEnumeration()
do while oParaEnum.hasMoreElements()
oPara = oParaEnum.nextElement
if oPara.supportsService("com.sun.star.text.Paragraph") then
rem if you're sure you'll never use a table for whatever reason, you can get rid of this if clause
oPortEnum = oPara.createEnumeration
do while oPortEnum.hasMoreElements()
oPort = oPortEnum.nextElement()
if isBold(oPort) then
rem do bold tags
thisComponent.text.insertString(oPort.getStart(), "[b]", false)
thisComponent.text.insertString(oPort.getEnd(), "[/b]", false)
'rem unbold
'oPort.charWeight =com.sun.star.awt.FontWeight.NORMAL
endif
if isItalic(oPort) then
rem do bold tags
thisComponent.text.insertString(oPort.getStart(), "[i]", false)
thisComponent.text.insertString(oPort.getEnd(), "[/i]", false)
'rem unitalic
'oPort.charPosture =com.sun.star.awt.FontSlant.NONE
endif
if isUnderline(oPort) then
rem do bold tags
thisComponent.text.insertString(oPort.getStart(), "[u]", false)
thisComponent.text.insertString(oPort.getEnd(), "[/u]", false)
endif
loop
end if
loop
end sub
function isBold(oTextPortion as object) as boolean
with oTextPortion
if .charWeight =com.sun.star.awt.FontWeight.BOLD then
isBold = true
else
isBold = false
endif
end with
end function
function isItalic(oTextPortion as object) as boolean
with oTextPortion
if .charPosture =com.sun.star.awt.FontSlant.ITALIC then
isItalic = true
else
isItalic = false
endif
end with
end function
function isUnderline(oTextPortion as object) as boolean
with oTextPortion
if .charUnderline =com.sun.star.awt.FontUnderline.SINGLE then
isUnderline = true
else
isUnderline = false
endif
end with
end function
LibreOffice Solution
Here are the adjustments you need to make for this to work in LibreOffice
The Macro can be used as is, which I suggest doing anyway.
Adjustments to manual solution
1) You need to use Ctrl+H instead of Ctrl+F
2) Instead of doing it three times, once for bold, italic, and underline, you would also need to do it for bold italic. When you choose bold as the format for the search, it displays as "bold" (in both softwares. In OO, when you choose italic, it shows simply "italic." But in LibreOffice, when you choose italic, it shows "italic, normal" for some reason. So you need to do bold, italic, bold italic, and underline.
Guide to using the macros:
Usually when you copy something from the Proboards forum, you end up with extra text at the bottom which says "Read More:" and has a link to the post. You need to delete that when you paste the code.[/i]
Word
1) Alt+F11
2) If it's blank, just paste the code. If there's something there, go to the bottom and paste the code after "end sub"
OpenOffice and LibreOffice
1) Alt+F11
2) Drill down into My Macros -> Standard -> Module1.
3) Click on Module1 and then click on "Main" in the window on the right. Click "Edit"
4) go to the bottom and paste the code after "end sub"
To run the macro:
Word 2007 and later
1) Click View tab and click "Macros"
2) Either doubleclick on the Macro "ProBoardsFormatCode" or click once and click "run."
Word 2003 and earlier
1) Tools -> Macros -> Macros, and then from there it is the same as in Word 2007.
OpenOffice and LibreOffice
1) Alt+F11
2) Drill down into My Macros -> Standard -> Module1.
3) Either doubleclick on the Macro "textformattoHTML" or click once and click "run."
Standalone application:
WYSIWYG BBCode Editor
This is a installable wysiwyg text editor. All the other other solutions that I've found require a browser and a javascript implementation.
Download from the autohotkey link - it's the most official:
www.shajul.net/111/wysiwyg-bbcode-editor-post/
1) Install and run program
2) Copy the text from your word processor and paste in the upper window. You can paste as much as you want to in the upper window, but it won't generate code if you paste too much. I am not sure what the limit is, but it seems to be able to handle more than a single proboards post can take (60000 characters)
3) In the area between the two windows, there is a pulldown menu. Select "proboards" from it.
4) Check "Ignore font" and "Ignore color"
5) Click "Generate Code" or BBCode -> Generate Code or Ctrl+Down
6) After the code appears, click "copy BBCode"
OPTIONAL: Stripping out the SIZE tags
This software inserts size tags and there is no option to to turn that off. If you pasted the code as is into the proboards window, I believe that the text would turn out larger than you would really want it. And also, since you can only put 60000 characters in a post, you might need to remove these tags for the space.
If the code uses size=4, you would do the following. Adjust if your code says something different.
1) Paste the code in a new document of your word processor.
2) Find "[ size=4 ]" (remove spaces) and replace with "" (null text)
3) Find "[ size=" (remove space) just to check if there were any different sizes other than the one you just replaced, other than the "size=1" that mentions the program (mentioned below). If there are, replace those with null text also.
4) Find "[ / size ]" (remove spaces) and replace with "" (null text)
This program will also insert the following at the bottom:
_________________________
Composed/Posted with WYSIWYG BBCode Editor
You can leave this in or delete it if you want.
Online Editor
For those that can't use the above program
www.ecardmax.com/hoteditor/
HotEditor V.4.4 works with
IE, FireFox, NetScape, Opera 9x, Chrome and Safari 1.3.2 or higher
This editor is really only meant to be a demo of what can be implemented at a board, so please only use this as a last resort. I put this in only for Mac users who won't try the macros, and also because macros are not supported by all versions of Word for mac (but OpenOffice and LibreOffice, and perhaps Word for Windows running on BootCamp or Parallels should be fine, and if you have Parallels or BootCamp, you could just use the standalone editor).
Initial Coding
1) Copy the text from your word processor and paste in the bottom window. Do not paste in too much at a time, as your browser will freeze up. But it can definitely handle the 60000 characters that a proboards post can take.
2) Click "Submit/Preview"
3) The code will appear in the BBCode Output window. Select that and copy and paste back in a new document in your word processor.
Cleaning up the code
1) Clean the SIZE beginning and end tags using the method described in the section for the standalone program
2) Clean up the FONT beginning and end tags using the same method.
3) Find "<o:p>" (no quotes) and replaces with "" (null text)
4) Find "</o:p>" (no quotes) and replaces with "" (null text)
I do not understand why the editor added these in. They seem to do with paragraphs, but I have never seen any code like this.
Things to know about the editor
1) It seems to do weird things with manual line breaks in MS Word (when you hit shift+enter). It handles them fine from OpenOffice If you have any of those you need to replace them with carriage returns. In Word, a manual line break is "^l" (lower case L) and you can replace it with "^p" (paragraph mark).
2) All the extra font tags and size tags take up a lot of space. You might be ok with leaving them in even though the story might look odd, but you also might not be able to fit a single chapter in a post if you leave them.