3

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...

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
  • Is the BBCode implementation in [i18n package](http://www.delphiarea.com/products/delphi-packages/i18n/) something you are looking for? Search for BBCode and BBCodes class. – LU RD Dec 20 '12 at 22:39
  • @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 Dec 20 '12 at 22:49
  • What about code in another language? – David Heffernan Dec 20 '12 at 23:13

1 Answers1

1

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"

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122
  • Oh, after a closer inspection it looks like bbcode2html() is not a full implementation. I don't see support for `[color=xxx]` for example. Maybe it can still save some time. Let me know when you find something, or when you create your own implementation. – Wouter van Nifterick Dec 21 '12 at 06:16