3
votes

I'm looking for a BBCode library for Delphi, that can translate BBCode into HTML. And it would be nice to have an actual parser that understands the state of the input and is able to detect errors, not something cheap along the lines of:

text := StringReplace(text, '[i]', '<i>', [rfReplaceAll]);
text := StringReplace(text, '[/i]', '</i>', [rfReplaceAll]);
text := StringReplace(text, '[b]', '<b>', [rfReplaceAll]);
text := StringReplace(text, '[/b]', '</b>', [rfReplaceAll]);
...

Does any such library exist? I've run a few Google searches but I haven't found one yet...

1
Is the BBCode implementation in i18n package something you are looking for? Search for BBCode and BBCodes class. - LU RD
@LURD: Interesting, but that looks to be mroe geared towards populating a TRichEdit control than generating HTML. But I might be able to work with that, if there's no better alternative... - Mason Wheeler
What about code in another language? - David Heffernan

1 Answers

1
votes

I found some code here:

https://rtcsdk.svn.sourceforge.net/svnroot/rtcsdk/Demos/RTC_WebForum/uTrans.pas

It contains a function called BBCode2HTML().

Might be worth taking a look at.

FYI, I found it via code.ohloh.net. Searchterm "bbcode"; filter "delphi"