PHP Classes

PHP Convert BBCode to HTML: Parse BBCode and render it on a HTML Web page

Recommend this page to a friend!

  Author Author  
Picture of Win Aung Cho
Name: Win Aung Cho <contact>
Classes: 8 packages by
Country: Myanmar Myanmar
Innovation award
Innovation award
Nominee: 3x


  Detailed description   Download Download .zip .tar.gz  
This class can parse BBCode and render it on an HTML Web page.

It can take as an argument a string with text formatted using BBCode tags.

The class can parse the BBCode tags and convert them into equivalent HTML tags to return as a result.

Details

BBCode-to-HTML-Converter

A class to render BBCode string and convert to HTML string.

BBCode-to-HTML-Converter

Demo Version

Visit following link and check demo in forum. Demo

Usage

First include the BBCode2HTML.php class in your file, and use the class as following to generate the HTML for the BBCode expressions:

$pist = <<<EOD
[ol/]
[ol]
[li c="blue"]Main[/li]
[li]Heading 1[/li]
[ol]
[li]item 1[/li]
[li]item 2
[ul][li][a ref='http://edu.structsoftlab.com/forum']link 1[/a][/li]
[li][a ref='http://www.structsoftlab.com']link 2[/a] [/li]
[/ul][/li]
[/ol]
[li]item 3[/li]
[/ol]
EOD;

$bb2html = new BBCode2HTML();
echo $bb2html->parse($post);

Features

Algorythm is very simple.

  • String is recursively tokenized using `preg_match` into array of matches,
  • Matches types are tag, attributes and inner-html.
  • Tag ommitting can be detected.
  • Data base classes are formed for each tags.
  • Tags data are then converted to html while filtering allowed tags and allowed attributes.
  • Value names of attributes are converted through short-cut name list.
  • `allowattr` flag control to allow native attributes of html. ## Contact Contact me for comercial use via mail winaungcho@gmail.com.

  Classes of Win Aung Cho  >  PHP Convert BBCode to HTML  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Convert BBCode to HTML
Base name: bbcode-to-html-conve
Description: Parse BBCode and render it on a HTML Web page
Version: 1.0
PHP version: 5
License: Custom (specified in a license file)
 
  Groups   Applications   Files Files  

  Groups  
Group folder image HTML HTML generation and processing View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Text processing Manipulating and validating text data View top rated classes
Group folder image Parsers Programming language interpreters and format parsers View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Accessible without login Image file bbcode2html.jpg Data Auxiliary data
Plain text file BBCode2HTML.php Class Class source
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

Download Download all files: bbcode-to-html-conve.tar.gz bbcode-to-html-conve.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Accessible without login Image file bbcode2html.jpg Data Auxiliary data
Plain text file BBCode2HTML.php Class Class source
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

Download Download all files: bbcode-to-html-conve.tar.gz bbcode-to-html-conve.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.