diff --git a/.phpunit.result.cache b/.phpunit.result.cache
new file mode 100644
index 0000000..297bd05
--- /dev/null
+++ b/.phpunit.result.cache
@@ -0,0 +1 @@
+C:37:"PHPUnit\Runner\DefaultTestResultCache":815:{a:2:{s:7:"defects";a:3:{s:40:"ParserTest::testHtmlReturnsCorrectBBCode";i:3;s:40:"ParserTest::testBBCodeReturnsCorrectHtml";i:3;s:42:"ParserTest::testAddNewLineBBCodeConversion";i:3;}s:5:"times";a:13:{s:22:"ParserTest::testParser";d:0.002;s:29:"ParserTest::testBBCodeParsing";d:0.001;s:40:"ParserTest::testHtmlReturnsCorrectBBCode";d:0.001;s:40:"ParserTest::testBBCodeReturnsCorrectHtml";d:0;s:49:"ParserTest::testCustomBulletsListBBCodeConversion";d:0;s:42:"ParserTest::testAddNewLineBBCodeConversion";d:0;s:31:"ParserTest::testCaseSensitivity";d:0;s:35:"ParserTest::testRemovalOfBBCodeTags";d:0;s:33:"ParserTest::testOnlyFunctionality";d:0;s:35:"ParserTest::testExceptFunctionality";d:0;s:25:"ParserTest::testAddParser";d:0;s:25:"ParserTest::testEdgeCases";d:0;s:38:"ParserTest::testExistingParserOverride";d:0;}}}
\ No newline at end of file
diff --git a/composer.lock b/composer.lock
index f0487af..64f65cc 100644
--- a/composer.lock
+++ b/composer.lock
@@ -267,16 +267,16 @@
},
{
"name": "phpdocumentor/reflection-docblock",
- "version": "5.0.0",
+ "version": "5.1.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f"
+ "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/a48807183a4b819072f26e347bbd0b5199a9d15f",
- "reference": "a48807183a4b819072f26e347bbd0b5199a9d15f",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
+ "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
"shasum": ""
},
"require": {
@@ -316,30 +316,29 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
- "time": "2020-02-09T09:16:15+00:00"
+ "time": "2020-02-22T12:28:44+00:00"
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.0.1",
+ "version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9"
+ "reference": "7462d5f123dfc080dfdf26897032a6513644fc95"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9",
- "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95",
+ "reference": "7462d5f123dfc080dfdf26897032a6513644fc95",
"shasum": ""
},
"require": {
- "php": "^7.1",
+ "php": "^7.2",
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
- "ext-tokenizer": "^7.1",
- "mockery/mockery": "~1",
- "phpunit/phpunit": "^7.0"
+ "ext-tokenizer": "^7.2",
+ "mockery/mockery": "~1"
},
"type": "library",
"extra": {
@@ -363,20 +362,20 @@
}
],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
- "time": "2019-08-22T18:11:29+00:00"
+ "time": "2020-02-18T18:59:58+00:00"
},
{
"name": "phpspec/prophecy",
- "version": "v1.10.2",
+ "version": "v1.10.3",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
- "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9"
+ "reference": "451c3cd1418cf640de218914901e51b064abb093"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
- "reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093",
+ "reference": "451c3cd1418cf640de218914901e51b064abb093",
"shasum": ""
},
"require": {
@@ -426,7 +425,7 @@
"spy",
"stub"
],
- "time": "2020-01-20T15:57:02+00:00"
+ "time": "2020-03-05T15:02:03+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -494,16 +493,16 @@
},
{
"name": "phpunit/php-file-iterator",
- "version": "3.0.0",
+ "version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "354d4a5faa7449a377a18b94a2026ca3415e3d7a"
+ "reference": "4ac5b3e13df14829daa60a2eb4fdd2f2b7d33cf4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/354d4a5faa7449a377a18b94a2026ca3415e3d7a",
- "reference": "354d4a5faa7449a377a18b94a2026ca3415e3d7a",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4ac5b3e13df14829daa60a2eb4fdd2f2b7d33cf4",
+ "reference": "4ac5b3e13df14829daa60a2eb4fdd2f2b7d33cf4",
"shasum": ""
},
"require": {
@@ -540,7 +539,7 @@
"filesystem",
"iterator"
],
- "time": "2020-02-07T06:05:22+00:00"
+ "time": "2020-04-18T05:02:12+00:00"
},
{
"name": "phpunit/php-invoker",
@@ -643,16 +642,16 @@
},
{
"name": "phpunit/php-timer",
- "version": "3.0.0",
+ "version": "3.1.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "4118013a4d0f97356eae8e7fb2f6c6472575d1df"
+ "reference": "dc9368fae6ef2ffa57eba80a7410bcef81df6258"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/4118013a4d0f97356eae8e7fb2f6c6472575d1df",
- "reference": "4118013a4d0f97356eae8e7fb2f6c6472575d1df",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/dc9368fae6ef2ffa57eba80a7410bcef81df6258",
+ "reference": "dc9368fae6ef2ffa57eba80a7410bcef81df6258",
"shasum": ""
},
"require": {
@@ -664,7 +663,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -688,7 +687,7 @@
"keywords": [
"timer"
],
- "time": "2020-02-07T06:08:11+00:00"
+ "time": "2020-04-20T06:00:37+00:00"
},
{
"name": "phpunit/php-token-stream",
@@ -992,16 +991,16 @@
},
{
"name": "sebastian/environment",
- "version": "5.0.1",
+ "version": "5.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "9bffdefa7810031a165ddd6275da6a2c1f6f2dfb"
+ "reference": "c753f04d68cd489b6973cf9b4e505e191af3b05c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/9bffdefa7810031a165ddd6275da6a2c1f6f2dfb",
- "reference": "9bffdefa7810031a165ddd6275da6a2c1f6f2dfb",
+ "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/c753f04d68cd489b6973cf9b4e505e191af3b05c",
+ "reference": "c753f04d68cd489b6973cf9b4e505e191af3b05c",
"shasum": ""
},
"require": {
@@ -1041,7 +1040,7 @@
"environment",
"hhvm"
],
- "time": "2020-02-19T13:40:20+00:00"
+ "time": "2020-04-14T13:36:52+00:00"
},
{
"name": "sebastian/exporter",
@@ -1445,16 +1444,16 @@
},
{
"name": "symfony/polyfill-ctype",
- "version": "v1.14.0",
+ "version": "v1.15.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38"
+ "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
- "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/4719fa9c18b0464d399f1a63bf624b42b6fa8d14",
+ "reference": "4719fa9c18b0464d399f1a63bf624b42b6fa8d14",
"shasum": ""
},
"require": {
@@ -1466,7 +1465,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.14-dev"
+ "dev-master": "1.15-dev"
}
},
"autoload": {
@@ -1499,7 +1498,7 @@
"polyfill",
"portable"
],
- "time": "2020-01-13T11:15:53+00:00"
+ "time": "2020-02-27T09:26:54+00:00"
},
{
"name": "theseer/tokenizer",
@@ -1543,16 +1542,16 @@
},
{
"name": "webmozart/assert",
- "version": "1.7.0",
+ "version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
- "reference": "aed98a490f9a8f78468232db345ab9cf606cf598"
+ "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598",
- "reference": "aed98a490f9a8f78468232db345ab9cf606cf598",
+ "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
+ "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
"shasum": ""
},
"require": {
@@ -1560,7 +1559,7 @@
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
- "vimeo/psalm": "<3.6.0"
+ "vimeo/psalm": "<3.9.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
@@ -1587,7 +1586,7 @@
"check",
"validate"
],
- "time": "2020-02-14T12:15:55+00:00"
+ "time": "2020-04-18T12:12:48+00:00"
}
],
"aliases": [],
diff --git a/src/Parser/BBCodeParser.php b/src/Parser/BBCodeParser.php
index 787728a..5368d9d 100644
--- a/src/Parser/BBCodeParser.php
+++ b/src/Parser/BBCodeParser.php
@@ -65,6 +65,11 @@ final class BBCodeParser extends Parser
'replace' => '$1',
'content' => '$1'
],
+ 'color' => [
+ 'pattern' => '/\[color\=(.*?)\](.*?)\[\/color\]/s',
+ 'replace' => '$2',
+ 'content' => '$2'
+ ],
'namedlink' => [
'pattern' => '/\[url\=(.*?)\](.*?)\[\/url\]/s',
'replace' => '$2',
diff --git a/src/Parser/HTMLParser.php b/src/Parser/HTMLParser.php
index c20537b..9007934 100644
--- a/src/Parser/HTMLParser.php
+++ b/src/Parser/HTMLParser.php
@@ -95,6 +95,11 @@ final class HTMLParser extends Parser
'replace' => '[url=$1]$2[/url]',
'content' => '$1'
],
+ 'color' => [
+ 'pattern' => '/(.*?)<\/span>/s',
+ 'replace' => '[color=$1]$2[/color]',
+ 'content' => '$1'
+ ],
'quote' => [
'pattern' => '/(.*?)<\/blockquote>/s',
'replace' => '[quote]$1[/quote]',
diff --git a/tests/ParserTest.php b/tests/ParserTest.php
index 5429505..09eedf1 100644
--- a/tests/ParserTest.php
+++ b/tests/ParserTest.php
@@ -32,6 +32,7 @@ public function testBBCodeParsing()
['input' => '[code]Yolo[/code]', 'excepted' => 'Yolo
'],
['input' => '[list]Yolo[/list]', 'excepted' => ''],
['input' => '[img]Yolo[/img]', 'excepted' => ''],
+ ['input' => '[color=#fff]Yolo[/color]', 'excepted' => 'Yolo'],
['input' => '[table]Yolo[/table]', 'excepted' => ''],
['input' => '[tr]Yolo[/tr]', 'excepted' => 'Yolo
'],
['input' => '[td]Yolo[/td]', 'excepted' => 'Yolo | '],
@@ -59,6 +60,7 @@ public function testHtmlReturnsCorrectBBCode()
lorem ipsum
http://www.example.com
example.com
+ lorem ipsum
- Item 1
@@ -98,6 +100,7 @@ public function testHtmlReturnsCorrectBBCode()
[h6]lorem ipsum[/h6]
[url=http://www.example.com]http://www.example.com[/url]
[url=http://www.example.com]example.com[/url]
+ [color=#fff]lorem ipsum[/color]
[img]http://example.com/logo.png[/img]
[list=1]
[*]Item 1
@@ -144,6 +147,7 @@ public function testBBCodeReturnsCorrectHtml()
[h6]lor[h6]em i[/h6]psum[/h6]
[url=http://www.example.com]http://www.example.com[/url]
[url=http://www.example.com]example.com[/url]
+ [color=#fff]lorem ipsum[/color]
[img]http://example.com/logo.png[/img]
[list=1]
[*]Item 1
@@ -173,6 +177,7 @@ public function testBBCodeReturnsCorrectHtml()
lorem i
psum
http://www.example.com
example.com
+ lorem ipsum
- Item 1