Nice work, does anyone know how to convert HTML code into BB code?
Menu, Tray, NoStandard
Menu, Tray, Add, Hide,ShowHide
Menu, Tray, default,Hide
Menu, Tray, Add, Exit
Gui, Add, Edit, x6 y30 w450 h340 vCode,
Gui, Add, Text, x6 y10 w450 h20, Enter HTML below. Only the HTML tags which have BBCode equivelents will be converted.
Gui, Add, Button, x356 y380 w100 h30 gSubmit, Convert to BBCode
Gui, Add, Radio, x6 y390 w60 h20 gIPBorPHPBB vPHPBBchecked, PHPBB
Gui, Add, Radio, x76 y390 w40 h20 Checked1 gIPBorPHPBB, IPB
Gui, Add, Text, x6 y370 w230 h20, What type of forum will you be posting to?
Gui, Show, h417 w463, HTML to BBCode Converter
k_IsVisible = y
board=IPB
Return
GuiClose:
ExitApp
IPBorPHPBB:
Gui, Submit, Nohide
if PHPBBchecked=1
board=PHPBB
else
board=IPB
return
ShowHide:
if k_IsVisible = y
{
Gui, Cancel
Menu, Tray, Rename, Hide, Show
k_IsVisible = n
}
else
{
Gui, Show
Menu, Tray, Rename, Show, Hide
k_IsVisible = y
}
return
Submit:
Gui, Submit, Nohide
string=%Code%
;-------------------------------------------------------------Other font options
if board=IPB
{
StringReplace, string, string, <strike>, [s], All
StringReplace, string, string, </strike>, [/s], All
}
else
{
StringReplace, string, string, <strike>,, All
StringReplace, string, string, </strike>,, All
}
StringReplace, string, string, <b>, [b], All
StringReplace, string, string, </b>, [/b], All
StringReplace, string, string, <strong>, [b], All
StringReplace, string, string, </strong>, [/b], All
StringReplace, string, string, <i>, [i], All
StringReplace, string, string, </i>, [/i], All
StringReplace, string, string, <u>, [u], All
StringReplace, string, string, </u>, [/u], All
StringReplace, string, string, <i>, [i], All
StringReplace, string, string, </i>, [/i], All
StringReplace, string, string, <em>, [i], All
StringReplace, string, string, </em>, [/i], All
StringReplace, string, string, ,`n, All
;-------------------------------------------------------------------blockquote
StringReplace, string, string, <blockquote>, [quote], All
ifinstring, string, <BLOCKQUOTE
{
url=%string%
StringSplit, url_array, url, <
Loop, %url_array0%
{
StringTrimLeft, this_url, url_array%a_index%, 0
this_url=<%this_url%
ifinstring, this_url, <BLOCKQUOTE%a_space%
{
stringreplace, string, string, %this_url%, [quote]
}
}
}
StringReplace, string, string, </blockquote>, [/quote], All
;-----------------------------------------------------------------------------------------------------------
if board=IPB
{
StringReplace, string, string, <center>, [center], All
StringReplace, string, string, </center>, [/center], All
}
else
{
StringReplace, string, string, <center>, , All
StringReplace, string, string, </center>, , All
}
;--------------------------------------------------------------------Changes URL's
ifinstring, string, href=
{
url=%string%
StringSplit, url_array, url, <
Loop, %url_array0%
{
StringTrimLeft, this_url, url_array%a_index%, 0
ifinstring, this_url, href=
{
url=%this_url%
oldurl=<%url%
;gets url name
StringLen, url_length, url
StringGetPos, namepos, url, >, R1
urlname:=url_length-namepos
urlname-=1
StringRight, urlname, url, %urlname%
;gets url
StringReplace, url, url,", , All
StringReplace, url, url, a href=, , All
autotrim, off
StringGetPos, urlpos, url, %a_space%, L1
autotrim, on
if urlpos=-1
StringGetPos, urlpos, url, >, L1
StringLeft, out_url, url, %urlpos%
stringreplace, out_url, out_url, ",,all
newurl=[url="%out_url%"]%urlname%
stringreplace, newurl, newurl, ",,all
stringgetpos, pos1,newurl, >
if pos1!=-1
{
stringgetpos, pos2,newurl, ]
if pos2 != -1
{
pos1+=1
pos2+=1
stringmid, replace, newurl, %pos1%, % pos2-pos1
stringreplace, newurl, newurl, %replace%,
}
}
stringreplace, string, string, %oldurl%, %newurl%
stringreplace, string, string, </a>,[/url], all
}
}
}
;---------------------------------------------------------------Converts images
ifinstring, string, <img
{
;StringReplace, string, string, src=, <[img], all
StringReplace, string, string, src=, [img], all
;StringReplace, string, string, <img, , all
url=%string%
StringSplit, url_array, url, <
Loop, %url_array0%
{
StringTrimLeft, this_url, url_array%a_index%, 0
ifinstring, this_url, [img]
{
url=<%this_url%
stringgetpos, pos1,url, <
if pos1!=-1
{
stringgetpos, pos2,url, [
if pos2 != -1
{
pos1+=1
pos2+=1
stringmid, replace, url, %pos1%, % pos2-pos1
stringreplace, url, url, %replace%,
}
}
;get old url
;StringGetPos, namepos, url, >, L1
;StringLeft, oldurl, url, %namepos%
oldurl=%replace%%url%
;gets url name
autotrim, off
StringGetPos, namepos, url,%a_space%, L1
autotrim, on
if namepos=-1
StringGetPos, namepos, url, >, L1
StringLeft, urlname, url, %namepos%
newurl=%urlname%[/img]
StringReplace, newurl, newurl,", , All
stringreplace, string, string, %oldurl%, %newurl%
}
}
}
;-----------------------------------------------------------------Font
ifinstring, string, <FONT
{
url=%string%
StringSplit, url_array, url, <
Loop, %url_array0%
{
StringTrimLeft, this_url, url_array%a_index%, 0
;autotrim, off
ifinstring, this_url, Font%a_space%
{
;autotrim, on
oldurl=%this_url%
StringReplace, this_url, this_url, color=, [color=, all
StringReplace, this_url, this_url, size=, [size=, all
StringReplace, this_url, this_url, face=, [font=, all
;----------------------------------------------------------------------------------color
ifinstring, this_url, [color=
{
StringGetPos, colorpos, this_url, [color=
StringGetPos, colorpos2, this_url,%a_space%, L, %colorpos%
if colorpos2=-1
StringGetPos, colorpos2, this_url,>, L, %colorpos%
colorpos2+=1
StringMid, colorBBCode, this_url, %colorpos%, % colorpos2-colorpos
ifinstring, colorBBCode,>
{
stringgetpos, GTPos, colorBBCode, >
StringLeft, colorBBCode, colorBBCode, %GTPos%
}
stringreplace, this_url, this_url, %colorBBCode%, %colorBBCode%]
this_url=%this_url%[/color]
}
;----------------------------------------------------------------------------------size
ifinstring, this_url, [size=
{
StringGetPos, sizepos, this_url, [size=
StringGetPos, sizepos2, this_url,%a_space%, L, %sizepos%
if sizepos2=-1
StringGetPos, sizepos2, this_url,>, L, %sizepos%
sizepos2+=1
StringMid, sizeBBCode, this_url, %sizepos%, % sizepos2-sizepos
ifinstring, sizeBBCode,>
{
stringgetpos, GTPos, sizeBBCode, >
StringLeft, sizeBBCode, sizeBBCode, %GTPos%
}
stringreplace, sizeBBCode, sizeBBCode, ",,all
StringRight, FontSize, sizeBBCode, 2
IfInString, FontSize, =
{
StringRight, FontSize, sizeBBCode, 1
StringTrimRight, sizeBBCode, sizeBBCode, 1
}
else
{
StringRight, FontSize, sizeBBCode, 2
StringTrimRight, sizeBBCode, sizeBBCode, 2
}
if board=IPB
{
if FontSize <=1
this_size = 1
if FontSize = 2
this_size = 3
if FontSize = 3
this_size = 5
if FontSize = 4
this_size = 7
if FontSize = 5
this_size =11
if FontSize = 6
this_size = 17
if FontSize >= 7
this_size = 23
}
if board=PHPBB
{
if FontSize <=1
this_size = 11
if FontSize = 2
this_size = 13
if FontSize = 3
this_size = 19
if FontSize = 4
this_size = 24
if FontSize = 5
this_size =24
if FontSize = 6
this_size = 29
if FontSize >= 7
this_size = 29
}
stringreplace, this_url, this_url, %FontSize%,
stringreplace, this_url, this_url, %sizeBBCode%, %sizeBBCode%%this_size%]
this_url=%this_url%[/size]
}
;---------------------------------------------------------------------------------font
ifinstring, this_url, [font=
{
StringGetPos, fontpos, this_url, [font=
StringGetPos, fontpos2, this_url,[, L2, %fontpos%
if fontpos2=-1
StringGetPos, fontpos2, this_url,>, L, %fontpos%
fontpos2+=1
StringMid, fontBBCode, this_url, %fontpos%, % fontpos2-fontpos
ifinstring, fontBBCode,>
{
stringgetpos, GTPos, fontBBCode, >
StringLeft, fontBBCode, fontBBCode, %GTPos%
}
if board=PHPBB
{
stringreplace, this_url, this_url, %fontBBCode%,
}
else
{
stringreplace, this_url, this_url, %fontBBCode%, %fontBBCode%]
this_url=%this_url%[/font]
}
}
;---------------------------------------------------------------------------------style
ifinstring, this_url, style=
{
StringGetPos, stylepos, this_url, style=
StringGetPos, stylepos2, this_url,%a_space%, L, %stylepos%
if stylepos2=-1
StringGetPos, stylepos2, this_url,>, L, %stylepos%
stylepos2+=1
StringMid, styleBBCode, this_url, %stylepos%, % stylepos2-stylepos
ifinstring, styleBBCode,>
{
stringgetpos, GTPos, styleBBCode, >
StringLeft, styleBBCode, styleBBCode, %GTPos%
}
stringreplace, this_url, this_url, %styleBBCode%,
}
;---------------------------------------------------------------------------------
StringReplace, this_url, this_url, >, ,All
newurl=%this_url%
StringReplace, newurl, newurl,", , All
stringreplace, string, string, %oldurl%, %newurl%
}
}
}
autotrim, off
stringreplace, string, string, <Font%a_space%, ,all
stringreplace, string, string, </Font>, ,all
autotrim, on
;------------------------------------------------------------------End Font
StringReplace, string, string,< <[img], [img], All
;-----------------------------------------------------------------Adds new lines
stringreplace, string, string,, `n ,All
stringreplace, string, string,<p>, `n ,All
stringreplace, string, string,</p>, `n ,All
;-------------------------------------------------------------Lists
StringReplace, string, string, <ul>, [list], All
StringReplace, string, string, <ol>, [list=1], All
StringReplace, string, string, <ol type="I">, [list=i], All
StringReplace, string, string, <ol type="a">, [list=a], All
StringReplace, string, string, </ul>, [/list], All
StringReplace, string, string, </ol>, [/list], All
ifinstring, string, <li>
{
StringReplace, string, string, <li>, [*], All
}
StringReplace, string, string, </li>, , All
StringReplace, string, string, </a>, [/url], All
StringReplace, string, string, <a href=, [url=, All
StringReplace, string, string, <hr>, ----------------------------------------, all
;-------------------------------------------------------------Code and Quotes with tables
StringReplace, string, string, <table bgcolor="#FAFCFE" align="center" width="95`%" border="1"><tr bgcolor="#FDDBCC"><td><b>Code], All
StringReplace, string, string, </font></td></tr></table>,
, All
StringReplace, string, string,
Quote: |
, , All StringReplace, string, string,
|
,, All
;------------------------------------------------------------------
;--------------------------------------------------------------------p
StringReplace, string, string,
, , All
ifinstring, string,
{
url=%string%
StringSplit, url_array, url, <
Loop, %url_array0%
{
StringTrimLeft, this_url, url_array%a_index%, 0
this_url=<%this_url%
ifinstring, this_url,
{
ifinstring, this_url, align=
{
oldurl=%this_url%
url=%this_url%
stringreplace, url, url, ",,all
ifinstring, url, align=center
{
if board=IPB
{
stringreplace, url, url, align=center,
, All
url=%url%
}
else
{
stringreplace, url, url, align=center,, All
url=%url%
}
}
ifinstring, url, align=left
{
if board=IPB
{
stringreplace, url, url, align=left,
, All
url=%url%
}
else
{
stringreplace, url, url, align=left,, All
url=%url%
}
}
ifinstring, url, align=right
{
if board=IPB
{
stringreplace, url, url, align=right,
, All
url=%url%
}
else
{
stringreplace, url, url, align=right,, All
url=%url%
}
}
stringgetpos, pos, url, [
stringtrimleft, url, url, %pos%
stringgetpos, pos1,url, ]
stringgetpos, pos2,url, >
pos1+=2
pos2+=2
stringmid, replace, url, %pos1%, % pos2-pos1
stringreplace, url, url, %replace%
stringreplace, string, string, %oldurl%, %url%
}
}
}
}
StringReplace, string, string, , `n, All
;--------------------------------------------------------------------div
StringReplace, string, string,
, , All
ifinstring, string,
{
url=%string%
StringSplit, url_array, url, <
Loop, %url_array0%
{
StringTrimLeft, this_url, url_array%a_index%, 0
this_url=<%this_url%
ifinstring, this_url,
{
ifinstring, this_url, align=
{
oldurl=%this_url%
url=%this_url%
stringreplace, url, url, ",,all
ifinstring, url, align=center
{
if board=IPB
{
stringreplace, url, url, align=center,
, All
url=%url%
}
else
{
stringreplace, url, url, align=center,, All
url=%url%
}
}
ifinstring, url, align=left
{
if board=IPB
{
stringreplace, url, url, align=left,
, All
url=%url%
}
else
{
stringreplace, url, url, align=left,, All
url=%url%
}
}
ifinstring, url, align=right
{
if board=IPB
{
stringreplace, url, url, align=right,
, All
url=%url%
}
else
{
stringreplace, url, url, align=right,, All
url=%url%
}
}
stringgetpos, pos, url, [
stringtrimleft, url, url, %pos%
stringgetpos, pos1,url, ]
stringgetpos, pos2,url, >
pos1+=2
pos2+=2
stringmid, replace, url, %pos1%, % pos2-pos1
stringreplace, url, url, %replace%
stringreplace, string, string, %oldurl%, %url%
}
}
}
}
StringReplace, string, string,
, , All
;----------------------------------------------------------------------------------------
StringReplace, string, string,
, , All
StringReplace, string, string, </code>,
, All
autotrim, off
stringreplace, string, string, `;, %a_space% ,All
StringReplace, string, string,"`;,, All
autotrim, on
Code=%string%
filedelete, code.txt
fileappend, %Code%, code.txt
filedelete, outputText.txt
;removes all other html tags
Loop, read, code.txt, outputText1.txt
{
string=%A_LoopReadLine%
loop
{
ifinstring,string,
head=1
ifinstring, string,
head=2
ifinstring,string, script=1
ifinstring,string,
script=2
if head=1
{
StringReplace, string, string, %string%,, All
break
}
if script=1
{
StringReplace, string, string, %string%,, All
break
}
StringGetPos, stringpos1, string, <, L1
StringGetPos, stringpos2, string, >, L1
if stringpos1 = -1
break
if stringpos2 = -1
break
stringpos1+=1
stringpos2+=2
removelength:=stringpos2-stringpos1
if removelength <= 0
break
StringMid, texttoremove, string, %stringpos1%, %removelength%
StringReplace, string, string, %texttoremove%,, All
}
StringReplace, string, string, &`;,&, All
StringReplace, string, string, >`;,>, All
StringReplace, string, string, <`;,<, All
autotrim, off
if string <>
{
if addspaces=0
{
FileAppend, %string%%a_space%
}
else
{
FileAppend, %string%`r`n
}
}
autotrim, on
}
autotrim, on
Loop, read, outputText1.txt, outputText.txt
{
string=%A_LoopReadLine%
FileAppend, %string%`n
}
filedelete, outputText1.txt
run, notepad.exe outputText.txt
return
Exit:
Exitapp
[/code]
edit:
Any left over HTML tags that do not have BBCode equivelents are now removed.