Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #66 from deanblackborough/v3.10.1
Browse files Browse the repository at this point in the history
V3.10.1
  • Loading branch information
deanblackborough authored May 20, 2018
2 parents 2ed0a07 + 0f8c770 commit b4b143f
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

Full changelog for PHP Quill Renderer

## v3.10.1 - 2018-05-21

* Fixed bugs #64 and #65, empty deltas being created by the preg_match on \n

## v3.10.0 - 2018-05-16

* Added support for passing multiple deltas into the API/parser, limited to multiple of the same type.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ the goal is to eventually support every Quill feature.

## Planned features

Over the next few weeks/months I want to continue adding support for additional Quill features and add additional
parsers and renderers, I expect Markdown will be next.
Over the next few weeks/months I want to continue adding support for additional [Quill](https://github.com/quilljs/quill)
features and add additional parsers and renderers, I expect Markdown will be next.

## PHP < 7.2

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"DBlackborough\\Quill\\" : "src/"
}
},
"homepage": "http://www.transmute-coffee.com/",
"keywords": [ "quill", "quilljs", "renderer", "delta", "parse", "html", "php"],
"homepage": "http://www.transmute-coffee.com/php-quill-renderer.php",
"keywords": [ "quill", "quilljs", "renderer", "delta", "parse", "html", "php", "markdown"],
"authors": [
{
"name": "Dean Blackborough",
Expand Down
4 changes: 3 additions & 1 deletion src/Parser/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ public function parse(): bool
} else {
if (preg_match("/[\n]{1}/", $quill['insert']) !== 0) {
foreach (preg_split("/[\n]{1}/", $quill['insert']) as $match) {
$this->deltas[] = new Insert(str_replace("\n", '', $match));
if (strlen(trim($match)) > 0) {
$this->deltas[] = new Insert(str_replace("\n", '', $match));
}
}
} else {
$this->deltas[] = new Insert($quill['insert']);
Expand Down
118 changes: 118 additions & 0 deletions tests/composite/html/MixTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php

namespace DBlackborough\Quill\Tests\Composite\Html;

require __DIR__ . '../../../../vendor/autoload.php';

use DBlackborough\Quill\Render as QuillRender;

/**
* Testing mixing different types of data
*/
final class MixTest extends \PHPUnit\Framework\TestCase
{
private $delta_paragraph_after_two_headers = '{
"ops":[
{
"insert":"Primary Header"
},
{
"attributes":{
"header":1
},
"insert":"\n"
},
{
"insert":"\nSecondary header"
},
{
"attributes":{
"header":2
},
"insert":"\n"
},
{
"insert":"\nA paragraph.\n"
}
]
}';
private $delta_list_and_header = '{
"ops":[
{
"insert":"Another list"
},
{
"attributes":{
"list":"bullet"
},
"insert":"\n"
},
{
"insert":"List item two entry two"
},
{
"attributes":{
"list":"bullet"
},
"insert":"\n"
},
{
"insert":"\nAnd now a HEADER"
},
{
"attributes":{
"header":4
},
"insert":"\n"
}
]
}';

private $expected_paragraph_after_two_headers = '<h1>Primary Header</h1><h2>Secondary header</h2><p>A paragraph.</p>';
private $expected_list_and_header = '<ul><li>Another list</li><li>List item two entry two</li></ul><h4>And now a HEADER</h4>';

/**
* Test for issue #64, opening p tag between two opening headers
*
* @return void
* @throws \Exception
*/
public function testParagraphAfterMultipleHeaders()
{
$result = null;

try {
$quill = new QuillRender($this->delta_paragraph_after_two_headers);
$result = $quill->render();
} catch (\Exception $e) {
$this->fail(__METHOD__ . 'failure, ' . $e->getMessage());
}

$this->assertEquals(
$this->expected_paragraph_after_two_headers,
$result,
__METHOD__ . ' - paragraph after two headers failure');
}

/**
* Test for issue #64, header after list at end of content
*
* @return void
* @throws \Exception
*/
public function testListAfterHeader()
{
$result = null;

try {
$quill = new QuillRender($this->delta_list_and_header);
$result = $quill->render();
} catch (\Exception $e) {
$this->fail(__METHOD__ . 'failure, ' . $e->getMessage());
}

$this->assertEquals($this->expected_list_and_header,
$result,
__METHOD__ . ' - header after list at end of content failure');
}
}

0 comments on commit b4b143f

Please sign in to comment.