Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

html to semantic text converter? (PHP)

Hi, I'm upgrading the backend of a dynamic site, and all the comments, pages etc are saved as html in a mysql database. Which means that no content can be edited if you do not know html. Is there a PHP script that can convert a string of html into markdown or textile or some other semantic text thingamajig


  • Do you mean replacing things like, [list] [*] [*] [/list] to an unordered list and [b] to <strong> and whatnot? Just create your own. Use a stack and figure out if stuff is closed/open, fix it and preg_replace() it.
  • edited February 2006
    No, he wants it to go the other way, so it reads in HTML and spits out BBCode or Markdown.

    There may be something somewhere, but it's not going to be very full-featured.

    And *do not* write your own BBCode->HTML extension; instead put a wrapper around the pear BBCode library.
  • " instead put a wrapper around the pear BBCode library." run that last bit by me again?
  • lechlech Chicagoland
    Pear is like an extension for PHP, it utilizes classes you can call upon to handle just about everything. Visit for more info.
  • >And *do not* write your own BBCode->HTML extension; instead put a wrapper around the pear BBCode library.
    Why not?
  • u can get the modded phpbb BBcode parser... its speedy, and works perfectly.
  • I can parse it one way, i just want it back again. I have data stored in my database as html, and i want it stored as markdown. How do i acomplish this?
  • edited February 2006
    Why not?
    The PEAR library is much more resistant to script injection, and will fix most improper tag closing/nesting. It's also free and GPLed.

    mattisfrommars: try this?
  • There's still nothing wrong with writing your own BB-code parser. Have you seen punbb's, for instance? It fixes improper tags and I don't think there's a single way around it in terms of js injection.
  • I guess it was just a recommendation to avoid working too hard since someones already done all the tough stuff for you?
  • edited February 2006
    In the wiki, the BBCode Extension is labeled in big bold text with "NOTE: It has been discovered that the BBcode extension has some security flaws", and I've seen nothing to suggest that this has been fixed. Even if it has been addressed, the current BBCode extension is just a dozen regex replacements; it isn't a real code parser. The PEAR BBCode library is (as far as I can tell) a stable, mature, well-tested module that actually parses BBCode and outputs valid XHTML. I'm currently trying to modify the library to stand alone in an extension folder, rather than needing the whole PEAR framework installed.
This discussion has been closed.