diff --git a/src/BBCode.php b/src/BBCode.php index 807ae7d..3153a8f 100644 --- a/src/BBCode.php +++ b/src/BBCode.php @@ -12,10 +12,10 @@ final class BBCode const CASE_SENSITIVE = 0; - public function __construct() + public function __construct($htmlParsers = null, $bbCodeParsers = null) { - $this->htmlParser = new HTMLParser(); - $this->bbCodeParser = new BBCodeParser(); + $this->htmlParser = new HTMLParser($htmlParsers); + $this->bbCodeParser = new BBCodeParser($bbCodeParsers); } public function only($only = null) diff --git a/src/Parser/Parser.php b/src/Parser/Parser.php index 808c845..468c011 100644 --- a/src/Parser/Parser.php +++ b/src/Parser/Parser.php @@ -12,6 +12,11 @@ class Parser protected $parsers = []; + public function __construct($parsers = null) + { + $this->parsers = $parsers === null ? $this->parsers : $parsers; + } + protected function searchAndReplace(string $pattern, string $replace, string $source): string { while (preg_match($pattern, $source)) {