Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -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;}}}
93 changes: 46 additions & 47 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Parser/BBCodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ final class BBCodeParser extends Parser
'replace' => '<a href="$1">$1</a>',
'content' => '$1'
],
'color' => [
'pattern' => '/\[color\=(.*?)\](.*?)\[\/color\]/s',
'replace' => '<span style="color: $1">$2</span>',
'content' => '$2'
],
'namedlink' => [
'pattern' => '/\[url\=(.*?)\](.*?)\[\/url\]/s',
'replace' => '<a href="$1">$2</a>',
Expand Down
5 changes: 5 additions & 0 deletions src/Parser/HTMLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ final class HTMLParser extends Parser
'replace' => '[url=$1]$2[/url]',
'content' => '$1'
],
'color' => [
'pattern' => '/<span style="color: (.*?)">(.*?)<\/span>/s',
'replace' => '[color=$1]$2[/color]',
'content' => '$1'
],
'quote' => [
'pattern' => '/<blockquote>(.*?)<\/blockquote>/s',
'replace' => '[quote]$1[/quote]',
Expand Down
5 changes: 5 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function testBBCodeParsing()
['input' => '[code]Yolo[/code]', 'excepted' => '<code>Yolo</code>'],
['input' => '[list]Yolo[/list]', 'excepted' => '<ul>Yolo</ul>'],
['input' => '[img]Yolo[/img]', 'excepted' => '<img src="Yolo">'],
['input' => '[color=#fff]Yolo[/color]', 'excepted' => '<span style="color: #fff">Yolo</span>'],
['input' => '[table]Yolo[/table]', 'excepted' => '<table>Yolo</table>'],
['input' => '[tr]Yolo[/tr]', 'excepted' => '<tr>Yolo</tr>'],
['input' => '[td]Yolo[/td]', 'excepted' => '<td>Yolo</td>'],
Expand Down Expand Up @@ -59,6 +60,7 @@ public function testHtmlReturnsCorrectBBCode()
<h6>lorem ipsum</h6>
<a href="http://www.example.com">http://www.example.com</a>
<a href="http://www.example.com">example.com</a>
<span style="color: #fff">lorem ipsum</span>
<img src="http://example.com/logo.png">
<ol>
<li>Item 1</li>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -173,6 +177,7 @@ public function testBBCodeReturnsCorrectHtml()
<h6>lor<h6>em i</h6>psum</h6>
<a href="http://www.example.com">http://www.example.com</a>
<a href="http://www.example.com">example.com</a>
<span style="color: #fff">lorem ipsum</span>
<img src="http://example.com/logo.png">
<ol>
<li>Item 1</li>
Expand Down