Proposal for a new extension BBCode Parser

From: Date: Tue, 06 Feb 2007 16:12:11 +0000
Subject: Proposal for a new extension BBCode Parser
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-4476@lists.php.net to get a copy of this message
Hello Everybody, I've build a small C library for handling BBcode Parsing (no hard coded tags). I've build over this library a small extension which can handle definition of new tags and string parsing (+ init / destroy). This extension has been build for performances reasons and outperform preg-based parsing (with my tests). I've named this extension BBcode because i think it's a good name, i'm working on making it "pecl standard compliant" and preparing an Object Oriented interface for it but it's pretty stable and i'll be glad to release it to the community. Currently it runs on a 110.000 pages per day server and no problems where detected. Current Capabilities of the library: * Dynamic tag definition * One pass parsing * Automatically generate valid HTML (if tags definitions are valid) * Optional Arguments * User Function Callback for Arguments & Content Parsing * No-parsing capabilities for some tags * Capabilities to treat the tag argument as a BBCoded string - Exemple usage - <?php function validate_url($content, $param){ return (preg_replace("/^[\\W]*javascript:/i","",$param)); } $tag_list=array( 'b'=> array('can_nest'=>true, 'type'=>BBCODE_NOARG, 'open_tag'=>'<b>', 'close_tag'=>'</b>', ), 'url'=> array('can_nest'=>true, 'type'=>BBCODE_TYPE_OPTARG, 'open_tag'=>'<a href="{ARG}">', 'close_tag'=>'</a>', 'default_arg'=>'{CONTENT}', 'arg_handling'=>'validate_url' ), ); $BBHandler=bbcode_create($arrayBBCode); $message=file_get_contents("message.toparse"); echo bbcode_parse($BBHandler,$message); ?> Thanks for your reading. ---------------- Xavier De Cock PHP Developer http://www.bmco.be

« previous php.pecl.dev (#4476) next »