Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igorakaamigo/php5-tiny-bbcode
A tiny BBCode implementation for PHP5.4+
https://github.com/igorakaamigo/php5-tiny-bbcode
bbcode bbcode-parser php php5 phpunit tdd tdd-kata
Last synced: 6 days ago
JSON representation
A tiny BBCode implementation for PHP5.4+
- Host: GitHub
- URL: https://github.com/igorakaamigo/php5-tiny-bbcode
- Owner: igorakaamigo
- License: mit
- Created: 2017-12-27T20:34:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T14:23:31.000Z (about 2 years ago)
- Last Synced: 2024-11-28T23:23:45.728Z (2 months ago)
- Topics: bbcode, bbcode-parser, php, php5, phpunit, tdd, tdd-kata
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny BBCode implementation for PHP 5.4+ and HHVM
This library includes a lightweight implementation of a BBCode subset to HTML translator.
[![License](https://img.shields.io/github/license/igorakaamigo/php5-tiny-bbcode.svg)](https://github.com/igorakaamigo/php5-tiny-bbcode/blob/master/LICENSE)
[![Packagist Version](https://img.shields.io/packagist/v/igorakaamigo/php5-tiny-bbcode.svg)](https://packagist.org/packages/igorakaamigo/php5-tiny-bbcode)
[![Minimal PHP Version](https://img.shields.io/packagist/php-v/igorakaamigo/php5-tiny-bbcode.svg)](http://php.net/downloads.php)## Features
* It's tiny, yep.
* PSR-4 autoloading compliant structure
* Unit-Testing with PHPUnit
* Easy to use to any framework or even a plain php file## Installation
The suggested installation method is via [composer](https://getcomposer.org/):
```sh
php composer.phar require "igorakaamigo/php5-tiny-bbcode"
```## Usage
```php
use \Igorakaamigo\Utils\BBCode;echo BBCode::convert('[b]A bold string[/b]');
// Outputs: A bold stringecho BBCode::convert('A text');
// Outputs: <span>A text</span>echo BBCode::convert('[i]Hi there![/i]');
// Outputs: Hi there!echo BBCode::convert('[i]Hi there
!!![/i]', [' ', '
']);
// Outputs: Hi there
!!!echo BBCode::convert('Magic links: email me at [email protected]');
// Outputs: Magic links: email me at [email protected]echo BBCode::convert('Magic links: http://www.domain.tld/path/to/resource');
// Outputs: Magic links: http://www.domain.tld/path/to/resource
```### Supported BBCodes
* [b]Bold string[/b]
* [i]Italic string[/i]
* [u]Underline string[/u]
* [s]Strikethrough string[/s]
* [email][email protected][/email]
* [url]http://www.domain.tld[/url]
* [url="http://www.domain.tld"]Another way to render a link[/url] (quotes inside url tag are not necessary)
* [img]http://www.domain.tld/upload/image.png[/img]
* [quote]A quotation[/quote]
* [quote="Quote author"]A quotation[/quote] (quotes inside quote tag are not necessary)
* [code]A program code sample[/code]
* [size="12"]A text written using a 12px-sized font[/size] (quotes inside size tag are not necessary)
* [size="10pt"]A text written using a 10pt-sized font[/size] (quotes inside size tag are not necessary)
* [color="#33FF33"]A green text line[/color] (quotes inside color tag are not necessary)
* [table], [tr], [td] – table-related tags
* [ul], [ol], [li], [*], [list], [list=1|a|A|i|I], [list="1|a|A|i|I"] – list-related tags[attachment] tag is not supported yet.
## Contributing
Just a kata project. Anyway – if one is interested –
Fork --> modify --> pull-request