Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9 from jasonvarga/blockquote
Browse files Browse the repository at this point in the history
Support blockquotes
  • Loading branch information
philippkuehn authored Jun 23, 2020
2 parents 0504234 + 57e0a84 commit 0e3d753
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Nodes/Blockquote.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Scrumpy\HtmlToProseMirror\Nodes;

class Blockquote extends Node
{
public function matching()
{
return $this->DOMNode->nodeName === 'blockquote';
}

public function data()
{
return [
'type' => 'blockquote',
];
}
}
1 change: 1 addition & 0 deletions src/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Renderer
];

protected $nodes = [
Nodes\Blockquote::class,
Nodes\BulletList::class,
Nodes\CodeBlock::class,
Nodes\CodeBlockWrapper::class,
Expand Down
37 changes: 37 additions & 0 deletions tests/Nodes/BlockquoteTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Scrumpy\HtmlToProseMirror\Test\Nodes;

use Scrumpy\HtmlToProseMirror\Renderer;
use Scrumpy\HtmlToProseMirror\Test\TestCase;

class BlockquoteTest extends TestCase
{
/** @test */
public function blockquote_gets_rendered_correctly()
{
$html = '<blockquote><p>Paragraph</p></blockquote>';

$json = [
'type' => 'doc',
'content' => [
[
'type' => 'blockquote',
'content' => [
[
'type' => 'paragraph',
'content' => [
[
'type' => 'text',
'text' => 'Paragraph',
],
],
],
],
],
],
];

$this->assertEquals($json, (new Renderer)->render($html));
}
}

0 comments on commit 0e3d753

Please sign in to comment.