AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert BBCode to HTML
Goto page Previous  1, 2
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Sun Dec 31, 2006 9:22 am    Post subject: Re: Convert BBCode to HTML Reply with quote

dori wrote:
I understood most of your code but i wonder if you have something ready that i can use on a ASP page.

I am looking for a function that i can send her a bbcode text (the post from the forum) and get HTML back
So you need some VB code instead.
Real BBCode to HTML is slightly more complex than what is shown above.
I compiled a list of rules to make a more thorough converter (to be done), I can put them here, you will then have to write the corresponding code in VB, which shouldn't be so hard.
Does the VB used in ASP (not ASP.NET, I suppose) have access to regular expressions?
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Dori
Guest





PostPosted: Sun Dec 31, 2006 4:19 pm    Post subject: VB Script Reply with quote

Hi all and thank you....

I think regular expressions is a subset of VB Script 5 or higher.
So i have access to it.
I read a bit about it but i need to read it more in order to start using it.....

here is an short article abou it
http://authors.aspalliance.com/brettb/SubstitutionsInVBScriptRegularExpressions.asp

Confused
Back to top
dori
Guest





PostPosted: Sun Dec 31, 2006 5:00 pm    Post subject: CreatePreview Reply with quote

AGU wrote:
Quote:
I am looking for a function that i can send her a bbcode text (the post from the forum) and get HTML back
Don't know if it's of help, but maybe you can take my CreatePreview subroutine from my BBCodeWriter Script and make a function out of it. Smile
________________________
Cheers
AGU


Hi Agu
thanks a lot.

Is this C++ ???
i am not sure i can run this whitin an ASP page
Back to top
AGU
Guest





PostPosted: Mon Jan 01, 2007 12:33 am    Post subject: Reply with quote

Quote:
Is this C++ ???
i am not sure i can run this whitin an ASP page

Sorry it's no C++, it's AHK syntax. As you were asking within this forum I assumed you were looking for an AHK solution.

After reading your first posting I'm asking myself why you were posting your request in this place instead of an ASP or VB forum. Don't you think this might yield better solutions than asking here in AHK forum?
_______________________
Cheers
AGU
Back to top
WickedSmile
Guest





PostPosted: Sat Jan 10, 2009 5:15 am    Post subject: Reply with quote

I've been trying to convert this video gam embedding code to BBcode and I just can't get it right. Help?

<div align="center"><a href="http://www.freehobo.com/games/super-mario-bros-flash">Play Super Mario Bros. Flash</a><br /><a href="http://www.freehobo.com/games/super-mario-bros-flash"><img src="http://www.freehobo.com/m_games/thumbs/super-mario-remake.gif" border="1" width="100" height="100"></a><br />More <a href="http://www.freehobo.com" style="font-weight:bold">free games</a> at freehobo.com</div>
Back to top
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Sat Jan 10, 2009 6:36 am    Post subject: Reply with quote

Well, the <div align="center"></div> can't be converted, and neither can the border/width/height of the image, but the rest should simply be this...
Code:
[url=http://www.freehobo.com/games/super-mario-bros-flash]Play Super Mario Bros. Flash[/url]
[url=http://www.freehobo.com/games/super-mario-bros-flash][img]http://www.freehobo.com/m_games/thumbs/super-mario-remake.gif[/img][/url]
More [url=http://www.freehobo.com][b]free games[/b][/url] at freehobo.com

_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
CMJavaGirl
Guest





PostPosted: Mon Jul 04, 2011 5:49 pm    Post subject: Re: Convert BBCode to HTML --- NEED HELP ASAP! PLEASE! Reply with quote

Hi -- I found this code here. If this code works it would be fantastic!

I am not a coder. I recently had to move my board from ProBoards to InvisionFree. IF does not read the [center][/center] BBCode and this is a problem for me. I publish fiction on my board and I would have to manually change the 'centering' code for hundreds of threads.

I'm pretty good at getting code to work if someone can tell be where this code needs to be placed.

I would really appreciate the help.

Thanks!



Jon wrote:
This will convert BBCode (Bulletin Board Code) to HTML

For Example:

Code:
[b]bold text[/b]
[url]http://www.google.co.uk[/url]
[url=http://www.aol.com]AOL[/url]


will be converted to

Code:
<b>bold text</b>
<a href="http://www.google.com">http://www.google.co.uk</a>
<a href="http://www.aol.com">AOL</a>


I have also made a version that used a GUI made in VB to display the results instead of internet explorer which you can get here-
http://hometown.aol.co.uk/JRMC137/BBCode2HTML/BBCode2HTML.zip

Code:
Gui -theme

addcontrols:

Gui, Add, Button, x446 y145 w64 h24 gPaste, Paste
Gui, Add, Button, x446 y175 w64 h24 gSubmit, Submit
Gui, Add, Button, x446 y205 w64 h24 gExit, Exit
Gui, Add, Edit, x16 y30 w420 h200 vcanned,
Gui, Add, Text, x16 y10 w170 h20, Enter or Paste the BBCode Below:

Gui, Show, h241 w522, BBCode to HTML Converter
Return

Exit:
GuiClose:
ExitApp

Paste:

ControlSetText, Edit1,, BBCode to HTML Converter
Control, EditPaste, %clipboard%, Edit1, BBCode to HTML Converter
return

Submit:
gui, submit

if canned=
{
filedelete, canned.txt
fileappend,No text Found,canned.txt
Exitapp
}

filedelete, canned.txt
fileappend,%canned%,canned.txt

filedelete, html.htm
autotrim, off
Loop, read, canned.txt, html.htm
{

bbcode=%A_LoopReadLine%

ifinstring, bbcode,[code]
addspaces=1

ifinstring, bbcode,[/code]
addspaces=2

if addspaces=1
{
stringReplace, bbcode, bbcode, %a_tab%, &nbsp`;&nbsp`;&nbsp`;, All


ifinstring,bbcode ,%a_space%%a_space%%a_space%
StringReplace, bbcode, bbcode, %a_space%%a_space%%a_space%, &nbsp`;&nbsp`;&nbsp`;, All
else
ifinstring,bbcode ,%a_space%%a_space%
StringReplace, bbcode, bbcode, %a_space%%a_space%, &nbsp`;&nbsp`;, All
}


StringReplace, bbcode, bbcode, [img], <img src=, All
StringReplace, bbcode, bbcode, [/img], >, All


;-------------------------------------------------------------Changes Font sizes

ifinstring, bbcode, [size=
{
StringSplit, size_array, bbcode, ]

Loop, %size_array0%
{
StringTrimLeft, this_size, size_array%a_index%, 0

ifinstring, this_size, [size
{
stringreplace, this_size, this_size, [size=,

StringRight, this_size, this_size, 2

this_size=%this_size%

stringreplace, bbcode, bbcode, %this_size%],

if this_size between 0 and 8
this_size = 1
if this_size between 9 and 10
this_size = 2
if this_size between 11 and 12
this_size = 3
if this_size between 13 and 14
this_size = 4
if this_size between 15 and 18
this_size = 5
if this_size between 19 and 24
this_size = 6
if this_size >= 25
this_size = 7

stringreplace, bbcode, bbcode, [size=,<font size = "%this_size%">
}
}
}

;-------------------------------------------------------------Changes e-mail

ifinstring, bbcode, [email]
{
StringSplit, email_array, bbcode, ]

Loop, %email_array0%
{
StringTrimLeft, this_email, email_array%a_index%, 0

ifinstring, this_email, [/email
{
stringreplace, this_email, this_email, [/email,
stringreplace, bbcode, bbcode, [email],<a href="mailto:%this_email%">
}
}
}

StringReplace, bbcode, bbcode, [email=, <a href=, All
stringreplace, bbcode, bbcode,[/email], </a>, all

;-------------------------------------------------------------Aligns text

StringReplace, bbcode, bbcode, [center], <div align="center">, All
StringReplace, bbcode, bbcode, [/center], </div>, All

StringReplace, bbcode, bbcode, [left], <div align="left">, All
StringReplace, bbcode, bbcode, [/left], </div>, All

StringReplace, bbcode, bbcode, [right], <div align="right">, All
StringReplace, bbcode, bbcode, [/right], </div>, All

;Change table font colours


;-------------------------------------------------------------Changes URL with and without =


ifinstring, bbcode, [url]
{
StringSplit, word_array, bbcode, ]

Loop, %word_array0%
{
StringTrimLeft, this_word, word_array%a_index%, 0

ifinstring, this_word, [/url
{
stringreplace, this_word, this_word, [/url,
stringreplace, bbcode, bbcode, [url],<a href="%this_word%">
}
}
}

StringReplace, bbcode, bbcode, [url=, <a href=, All
StringReplace, bbcode, bbcode, [/url], </a>, All

;-------------------------------------------------------------Other font options

StringReplace, bbcode, bbcode, [s], <strike>, All
StringReplace, bbcode, bbcode, [/s], </strike>, All

StringReplace, bbcode, bbcode, [font=, <font face=, All
StringReplace, bbcode, bbcode, [size=, <font size=, All
StringReplace, bbcode, bbcode, [/size], </font>, All

StringReplace, bbcode, bbcode, [color=, <font color=, All
StringReplace, bbcode, bbcode, [/color], </font>, All

StringReplace, bbcode, bbcode, [b], <b>, All
StringReplace, bbcode, bbcode, [/b], </b>, All

StringReplace, bbcode, bbcode, [i], <i>, All
StringReplace, bbcode, bbcode, [/i], </i>, All

StringReplace, bbcode, bbcode, [u], <u>, All
StringReplace, bbcode, bbcode, [/u], </u>, All

StringReplace, bbcode, bbcode, [i], <i>, All
StringReplace, bbcode, bbcode, [/i], </i>, All

;-------------------------------------------------------------Lists


StringReplace, bbcode, bbcode, [list], <ul>, All
StringReplace, bbcode, bbcode, [list=1], <ol>, All
StringReplace, bbcode, bbcode, [list=i], <ol type="I">, All
StringReplace, bbcode, bbcode, [list=a], <ol type="a">, All
StringReplace, bbcode, bbcode, [/list], </ul>, All

ifinstring, bbcode, [*]
{
StringReplace, bbcode, bbcode, [*], <li>, All
bbcode=%bbcode%</li>
}

;-------------------------------------------------------------Code and Quotes with tables

StringReplace, bbcode, bbcode, [code], <table bgcolor="#FAFCFE" align="center" width="95`%" border="1"><tr

bgcolor="#FDDBCC"><td><b>Code:</b></td></tr><tr><td><font color="#008000">, All
StringReplace, bbcode, bbcode, [/code], </font></td></tr></table>, All

StringReplace, bbcode, bbcode, [quote], <table bgcolor="#FAFCFE" align="center" width="95`%" border="1"><tr

bgcolor="#E8EFF7"><td><b>Quote:</b></td></tr><tr><td>, All
StringReplace, bbcode, bbcode, [/quote], </td></tr></table>, All

;needs to be last item

ifinstring, bbcode, [quote`=
{
StringReplace, bbcode, bbcode, [quote`=, <table bgcolor="#FAFCFE" align="center" width="95`%" border="1"><tr

bgcolor="#E8EFF7"><td><b>Quote:%a_space%</b>
StringReplace, bbcode, bbcode, [/quote], </td></tr></table>, All
StringReplace, bbcode, bbcode, ], </td></tr><tr><td>
}

;-------------------------------------------------------------Replace brackets and append to file

StringReplace, bbcode, bbcode, [, <, All
StringReplace, bbcode, bbcode, ], >, All

ifinstring, bbcode, <li>
FileAppend,%bbcode%
else
ifinstring, bbcode, </li>
FileAppend,%bbcode%
else
ifinstring, bbcode, <ul>
FileAppend,%bbcode%
else
ifinstring, bbcode, </ul>
FileAppend,%bbcode%
else
FileAppend,%bbcode%<br>

}

run, iexplore.exe %a_workingdir%\html.htm

Exitapp
Back to top
sumon



Joined: 18 May 2010
Posts: 1011
Location: Sweden

PostPosted: Mon Jul 04, 2011 5:57 pm    Post subject: Reply with quote

CMJavaGirl, if you are the owner of your board, it would probably be easier to do the scripting serverside.
Back to top
View user's profile Send private message Visit poster's website
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Mon Jul 04, 2011 7:33 pm    Post subject: Reply with quote

Just in case you still need this add this to the script before the fileappend command anyway
Code:
ifinstring, bbcode, [center]
   {
      stringreplace, bbcode, bbcode, [center], <center>, all
      stringreplace, bbcode, bbcode, [/center], </center>, all
   }

_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
cyllaz



Joined: 25 Nov 2011
Posts: 1

PostPosted: Fri Nov 25, 2011 3:24 am    Post subject: Re: Convert BBCode to HTML Reply with quote

Jon wrote:
This will convert BBCode (Bulletin Board Code) to HTML

For Example:

Code:
[b]bold text[/b]
[url]http://www.google.co.uk[/url]
[url=http://www.aol.com]AOL[/url]


will be converted to

Code:
<b>bold text</b>
<a href="http://www.google.com">http://www.google.co.uk</a>
<a href="http://www.aol.com">AOL</a>


I have also made a version that used a GUI made in VB to display the results instead of internet explorer which you can get here-
http://hometown.aol.co.uk/JRMC137/BBCode2HTML/BBCode2HTML.zip

Code:
Gui -theme

addcontrols:

Gui, Add, Button, x446 y145 w64 h24 gPaste, Paste
Gui, Add, Button, x446 y175 w64 h24 gSubmit, Submit
Gui, Add, Button, x446 y205 w64 h24 gExit, Exit
Gui, Add, Edit, x16 y30 w420 h200 vcanned,
Gui, Add, Text, x16 y10 w170 h20, Enter or Paste the BBCode Below:

Gui, Show, h241 w522, BBCode to HTML Converter
Return

Exit:
GuiClose:
ExitApp

Paste:

ControlSetText, Edit1,, BBCode to HTML Converter
Control, EditPaste, %clipboard%, Edit1, BBCode to HTML Converter
return

Submit:
gui, submit

if canned=
{
filedelete, canned.txt
fileappend,No text Found,canned.txt
Exitapp
}

filedelete, canned.txt
fileappend,%canned%,canned.txt

filedelete, html.htm
autotrim, off
Loop, read, canned.txt, html.htm
{

bbcode=%A_LoopReadLine%

ifinstring, bbcode,[code]
addspaces=1

ifinstring, bbcode,[/code]
addspaces=2

if addspaces=1
{
stringReplace, bbcode, bbcode, %a_tab%, &nbsp`;&nbsp`;&nbsp`;, All


ifinstring,bbcode ,%a_space%%a_space%%a_space%
StringReplace, bbcode, bbcode, %a_space%%a_space%%a_space%, &nbsp`;&nbsp`;&nbsp`;, All
else
ifinstring,bbcode ,%a_space%%a_space%
StringReplace, bbcode, bbcode, %a_space%%a_space%, &nbsp`;&nbsp`;, All
}


StringReplace, bbcode, bbcode, [img], <img src=, All
StringReplace, bbcode, bbcode, [/img], >, All


;-------------------------------------------------------------Changes Font sizes

ifinstring, bbcode, [size=
{
StringSplit, size_array, bbcode, ]

Loop, %size_array0%
{
StringTrimLeft, this_size, size_array%a_index%, 0

ifinstring, this_size, [size
{
stringreplace, this_size, this_size, [size=,

StringRight, this_size, this_size, 2

this_size=%this_size%

stringreplace, bbcode, bbcode, %this_size%],

if this_size between 0 and 8
this_size = 1
if this_size between 9 and 10
this_size = 2
if this_size between 11 and 12
this_size = 3
if this_size between 13 and 14
this_size = 4
if this_size between 15 and 18
this_size = 5
if this_size between 19 and 24
this_size = 6
if this_size >= 25
this_size = 7

stringreplace, bbcode, bbcode, [size=,<font size = "%this_size%">
}
}
}

;-------------------------------------------------------------Changes e-mail

ifinstring, bbcode, [email]
{
StringSplit, email_array, bbcode, ]

Loop, %email_array0%
{
StringTrimLeft, this_email, email_array%a_index%, 0

ifinstring, this_email, [/email
{
stringreplace, this_email, this_email, [/email,
stringreplace, bbcode, bbcode, [email],<a href="mailto:%this_email%">
}
}
}

StringReplace, bbcode, bbcode, [email=, <a href=, All
stringreplace, bbcode, bbcode,[/email], </a>, all

;-------------------------------------------------------------Aligns text

StringReplace, bbcode, bbcode, [center], <div align="center">, All
StringReplace, bbcode, bbcode, [/center], </div>, All

StringReplace, bbcode, bbcode, [left], <div align="left">, All
StringReplace, bbcode, bbcode, [/left], </div>, All

StringReplace, bbcode, bbcode, [right], <div align="right">, All
StringReplace, bbcode, bbcode, [/right], </div>, All

;Change table font colours


;-------------------------------------------------------------Changes URL with and without =


ifinstring, bbcode, [url]
{
StringSplit, word_array, bbcode, ]

Loop, %word_array0%
{
StringTrimLeft, this_word, word_array%a_index%, 0

ifinstring, this_word, [/url
{
stringreplace, this_word, this_word, [/url,
stringreplace, bbcode, bbcode, [url],<a href="%this_word%">
}
}
}

StringReplace, bbcode, bbcode, [url=, <a href=, All
StringReplace, bbcode, bbcode, [/url], </a>, All

;-------------------------------------------------------------Other font options

StringReplace, bbcode, bbcode, [s], <strike>, All
StringReplace, bbcode, bbcode, [/s], </strike>, All

StringReplace, bbcode, bbcode, [font=, <font face=, All
StringReplace, bbcode, bbcode, [size=, <font size=, All
StringReplace, bbcode, bbcode, [/size], </font>, All

StringReplace, bbcode, bbcode, [color=, <font color=, All
StringReplace, bbcode, bbcode, [/color], </font>, All

StringReplace, bbcode, bbcode, [b], <b>, All
StringReplace, bbcode, bbcode, [/b], </b>, All

StringReplace, bbcode, bbcode, [i], <i>, All
StringReplace, bbcode, bbcode, [/i], </i>, All

StringReplace, bbcode, bbcode, [u], <u>, All
StringReplace, bbcode, bbcode, [/u], </u>, All

StringReplace, bbcode, bbcode, [i], <i>, All
StringReplace, bbcode, bbcode, [/i], </i>, All

;-------------------------------------------------------------Lists


StringReplace, bbcode, bbcode, [list], <ul>, All
StringReplace, bbcode, bbcode, [list=1], <ol>, All
StringReplace, bbcode, bbcode, [list=i], <ol type="I">, All
StringReplace, bbcode, bbcode, [list=a], <ol type="a">, All
StringReplace, bbcode, bbcode, [/list], </ul>, All

ifinstring, bbcode, [*]
{
StringReplace, bbcode, bbcode, [*], <li>, All
bbcode=%bbcode%</li>
}

;-------------------------------------------------------------Code and Quotes with tables

StringReplace, bbcode, bbcode, [code], <table bgcolor="#FAFCFE" align="center" width="95`%" border="1"><tr

bgcolor="#FDDBCC"><td><b>Code:</b></td></tr><tr><td><font color="#008000">, All
StringReplace, bbcode, bbcode, [/code], </font></td></tr></table>, All

StringReplace, bbcode, bbcode, [quote], <table bgcolor="#FAFCFE" align="center" width="95`%" border="1"><tr

bgcolor="#E8EFF7"><td><b>Quote:</b></td></tr><tr><td>, All
StringReplace, bbcode, bbcode, [/quote], </td></tr></table>, All

;needs to be last item

ifinstring, bbcode, [quote`=
{
StringReplace, bbcode, bbcode, [quote`=, <table bgcolor="#FAFCFE" align="center" width="95`%" border="1"><tr

bgcolor="#E8EFF7"><td><b>Quote:%a_space%</b>
StringReplace, bbcode, bbcode, [/quote], </td></tr></table>, All
StringReplace, bbcode, bbcode, ], </td></tr><tr><td>
}

;-------------------------------------------------------------Replace brackets and append to file

StringReplace, bbcode, bbcode, [, <, All
StringReplace, bbcode, bbcode, ], >, All

ifinstring, bbcode, <li>
FileAppend,%bbcode%
else
ifinstring, bbcode, </li>
FileAppend,%bbcode%
else
ifinstring, bbcode, <ul>
FileAppend,%bbcode%
else
ifinstring, bbcode, </ul>
FileAppend,%bbcode%
else
FileAppend,%bbcode%<br>

}

run, iexplore.exe %a_workingdir%\html.htm

Exitapp


ola, gostaria de saber se existe algum codigo para fazer com que meu site reconheça bbcode ??
e o que ezatamente faz esse codigo acima ?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group