Skip to content

Commit

Permalink
New feature and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Genert Org committed Jul 17, 2017
1 parent 5810a34 commit 55f892a
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 110 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ $bbCode->except('bold')->convertToHtml('[b]Bold[/b] [i]italic[/i]');
$bbCode->except(['bold'])->convertToHtml('[b]Bold[/b] [i]italic[/i]');
```

### `addParser(string $name, string $pattern, string $replace)`
Add regex based BBCode parser to translate found pattern to desired one.

Example:
```php
use Genert\BBCode\BBCode;

$bbCode = new BBCode();

// Add "[link target=http://example.com]Example[/link]" parser.
$bbCode->addParser(
'custom-link',
'/\[link target\=(.*?)\](.*?)\[\/link\]/s',
'<a href="$1">$2</a>'
);

// Output: '<a href="www.yourlinkhere.com">Text to be displayed</a>.'
$bbCode->convertToHtml('[link target=www.yourlinkhere.com]Text to be displayed[/link].');
```


## Laravel installation

Once BBCode is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key.
Expand Down
Loading

0 comments on commit 55f892a

Please sign in to comment.