You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-166Lines changed: 9 additions & 166 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
A recursive regexp [BBCode](http://en.wikipedia.org/wiki/BBCode) parser for PHP 7+ using [preg_replace_callback()](http://php.net/preg_replace_callback),
4
4
based on an example by [MrNiceGuy](http://www.developers-guide.net/forums/member/69,mrniceguy) on
For an [implementation example](https://github.com/codemasher/gw1-database/blob/master/public/gwbbcode.php) see the over here: [gw1-database/GWBBCode](https://github.com/codemasher/gw1-database/tree/master/src/GWBBCode).
'mybbcode', 'somebbcode', 'whatever', // your own tags
183
-
];
184
-
185
-
}
186
-
```
187
-
188
-
### Parser extension
189
-
The parser features an extension which allows you to alter the bbcode during the parsing process,
190
-
namely before and after the main parser unit runs. If you want to create your own parser extension,
191
-
just implement `\chillerlan\bbcode\ParserExtensionInterface`, set it in the parser options and you're done.
192
-
```php
193
-
namespace Example;
194
-
195
-
use chillerlan\bbcode\ParserExtensionInterface;
196
-
197
-
class MyAwesomeParserExtension implements ParserExtensionInterface{
198
-
199
-
public function pre($bbcode){
200
-
201
-
$search = [
202
-
"\t", // lets convert all tabs into 4 spaces
203
-
'{__BASE_URL__}', // assume we use a special token for our base url
204
-
];
205
-
206
-
$replace = [
207
-
' ',
208
-
'https://your.base/url/'
209
-
];
210
-
211
-
return str_replace($search, $replace, $bbcode);
212
-
}
213
-
214
-
public function post($bbcode){
215
-
return $bbcode;
216
-
}
217
-
218
-
}
219
-
```
220
63
### Language
221
64
-@todo
222
-
65
+
223
66
## Notes
224
67
The parser may cause some high CPU load, depending on the input. You should never consider to use it somewhere
225
-
in your output subsystem - not even with strong caching. Encode on input - you'll want a preview anyway. ;)
68
+
in your output subsystem - encode on input - you'll want a preview anyway. ;)
226
69
227
70
You may also run into several bugs. In fact, the BBCoder is essentially a tool to squeeze out any PCRE related bug in PHP known to man (and perhaps unknown). Have fun! ;)
228
71
[It is highly recommended to use these php.ini settings](https://github.com/chillerlan/php-bbcode/blob/master/travis-php.ini), especially to disable the PCRE JIT in PHP7 which is a troublemaker.
0 commit comments