Converting HTML To BBCode
March 7, 2006 on 9:01 pm | In PHP |I am currently learning PHP, so I set out to write an application which would convert my HTML-coded tutorials into BBCode suitable for forums. That goes without saying that my code failed miserably.. I was not too far off though; I got the general gist of it. So, I decided to ask the wonderful guys and gals on the ‘General user’ PHP mailing list (which, by the way, means what it says about being of very high volume!), and they came up with a solution.
The solution involved regular expressions (or reg-exp, for the abbreviation fanatics out there) - which I am proud to say I understood none of.
Hopefully I’ll soon be onto regular expressions so that I can figure out what it means - I remember the days I thought HTML was cryptic! How naïve I was.. Reg-exp is impossible to understand in my opinion, although I’m sure the more advanced PHP coders among you will say the contrary.
Enough of my rambling - here’s the page you can use if you ever want to translate HTML code into forum-usable BBCode: HTML To BBCode.
Note: Only the following tags (and their closing ones) are currently supported -
- <strong>
- <b>
- <em>
- <i>
- <ul>
- <ol>
- <li>
- <a>
- <img>
It works surprisingly well - although note: outputted BBCode may be different to the BBCode used on some forums. BBCode which is returned by this script is proven to work on vBulletin forums.
26 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress with Pool theme.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
0.482 seconds.
Loan - Mortgage Calculator - Homeowner Loans - United Specialties
Excellent app. I occasionally get sent submissions in HTML that need converting so I may well use and abuse this!
Comment by ray — March 9, 2006 #
Mozilla Firefox 1.5.0.1 on
Windows XP
Using
A great app to have. I thought of creating a BBCode parser myself for my CMS although I think HTML is better for a CMS because you’re building a site and you shouldn’t limit yourself to BBCode.
Comment by hari — March 10, 2006 #
Mozilla Firefox 1.0.7 on
Debian GNU/Linux
Using
Ray - Hehe, no problem!
Hari - Thanks
You’re right, HTML is probably a better choice for the CMS - it gives the user much more freedom than sticking to BBCode tags. Plus, with HTML there’s always room to expand the CMS with new tricks - with BBCode, any new implementations would be a bit more complex. At least that’s MHO 
Comment by J_K9 — March 10, 2006 #
Internet Explorer 6.0 on
Windows XP
Using
If you want a visual regular expression editor you can use KRegExpEditor. It’s very easy to build regular expressions if you understand the logic behind what you want. You needn’t worry about the syntax. This tool will generate it for you.
Comment by hari — March 11, 2006 #
Mozilla Firefox 1.0.7 on
Debian GNU/Linux
Using
Hm do you know where i can find a translator that works the other way aka bbcode to html
Comment by 2rzn — May 15, 2006 #
Mozilla Firefox 1.5.0.3 on
Windows XP
Using
Forget it i found one myself at :http://hometown.aol.co.uk/JRMC137/BBCode2HTML/index.htm
Comment by 2rzn — May 15, 2006 #
Mozilla Firefox 1.5.0.3 on
Windows XP
Using
Thanks for sharing it
Comment by J_K9 — May 15, 2006 #
Internet Explorer 6.0 on
Windows XP
Using
Very nice, but why dont u remove the html tags that can’t be converted? such as table and td? Just leave the bbcode with the working ones.
Comment by R2 — June 16, 2006 #
Opera 8.54 on
Windows XP
Using
Thank you.
That is a good point.. I think the original idea was that, because there are so many different variations of BBCode, those HTML tags which were not converted were left in the code so that the user could then convert those themself if their forum’s BBCode allowed it.
But, I do see your point - once I’ve furthered my knowledge of reg-exp (or, rather, get to the holidays so I can refresh my memory!), I will add the option to do that.
Thanks for the input!
Comment by J_K9 — June 16, 2006 #
Internet Explorer 6.0 on
Windows XP
Using
How do i download this code to try it myself?
I dont see no link around here to download the code
Comment by xac — May 10, 2007 #
Mozilla Firefox 2.0.0.3 on
Windows XP
Using
That’s a good point - I haven’t put a link to a downloadable file
I’ll do it this afternoon and email you a link
Comment by J_K9 — May 10, 2007 #
Mozilla Firefox 2.0.0.3 on
Windows Vista
Using
Hello! Help solve the problem.
Very often try to enter the forum, but says that the password is not correct.
Regrettably use of remembering. Give like to be?
Thank you!
Comment by AltaGid — August 8, 2007 #
Opera 7.54 on
Windows XP
Using
Oh that is such a nice app.! It works perfectly and it’s very usefull for uploading very much images or stuff like that on a forum!
Thank you very much for sharing it.
Comment by Levina — August 11, 2007 #
Internet Explorer 7.0 on
Windows XP
Using
juego de azar póquer juego…
?…
Trackback by juego de azar póquer juego — February 10, 2008 #
Internet Explorer 6.0 on
Windows Server 2003
Using
foreclosure home loan…
playboy teaspoon palming?Brighton expeditions.manpower,…
Trackback by foreclosure home loan — February 15, 2008 #
Internet Explorer 6.0 on
Windows XP
Using
bingo games in chicago illinois…
deemphasizing secretariat?prudential Socratic eleventh …
Trackback by bingo games in chicago illinois — February 15, 2008 #
Opera 5.11 on
Windows ME
Using
nebraska national life insurance company…
tattoos,plodding,Galilean,Russo Timonize abstractionism …
Trackback by nebraska national life insurance company — February 17, 2008 #
Internet Explorer 6.0 on
Windows Server 2003
Using
sport book betting guide…
airlift!Kruse aerodynamic logic embryos!ballplayers …
Trackback by sport book betting guide — February 17, 2008 #
Internet Explorer 5.0 on
Mac OS
Using
ultimate bet download…
royalty absolving:eventfully!…
Trackback by ultimate bet download — February 22, 2008 #
Internet Explorer 6.0 on
Windows XP
Using
Excelent app!
where i can download sourse code?
Comment by crond — February 28, 2008 #
Mozilla Firefox 2.0.0.12 on
Windows XP
Using
b4c3b5ff8465…
b4c3b5ff84657beecbae…
Trackback by b4c3b5ff8465 — May 12, 2008 #
Using Unknown browser
Oxycontin….
Oxycontin withdrawal home remedies. Oxycontin lawyer columbus. Can not stop oxycontin. Oxycontin. Oxycontin no prescription….
Trackback by Oxycontin overseas pharmacy. — May 30, 2008 #
Using Unknown browser
car insurance orange county…
beefing Lyra,diet.brownies …
Trackback by car insurance orange county — May 31, 2008 #
Internet Explorer 6.0 on
Windows Server 2003
Using
slotsvillage…
humiliations!maced Hesse!Fafnir:fortuitously …
Trackback by slotsvillage — July 20, 2008 #
Opera 5.11 on
Windows ME
Using
Fat tits cumshot….
Fat tits cumshot….
Trackback by Fat tits cumshot. — July 20, 2008 #
Using Unknown browser
grattis poker kort spel…
muddled encircles phoenix:Datsun barks …
Trackback by grattis poker kort spel — July 20, 2008 #
Internet Explorer 6.0 on
Windows XP
Using