diff --git a/src/Nodes/HorizontalRule.php b/src/Nodes/HorizontalRule.php new file mode 100644 index 0000000..27e6041 --- /dev/null +++ b/src/Nodes/HorizontalRule.php @@ -0,0 +1,18 @@ +DOMNode->nodeName === 'hr'; + } + + public function data() + { + return [ + 'type' => 'horizontal_rule', + ]; + } +} diff --git a/src/Renderer.php b/src/Renderer.php index f699bda..cf08cbd 100644 --- a/src/Renderer.php +++ b/src/Renderer.php @@ -29,6 +29,7 @@ class Renderer Nodes\CodeBlockWrapper::class, Nodes\HardBreak::class, Nodes\Heading::class, + Nodes\HorizontalRule::class, Nodes\Image::class, Nodes\ListItem::class, Nodes\OrderedList::class, diff --git a/tests/Nodes/HorizontalRuleTest.php b/tests/Nodes/HorizontalRuleTest.php new file mode 100644 index 0000000..970cfce --- /dev/null +++ b/tests/Nodes/HorizontalRuleTest.php @@ -0,0 +1,44 @@ +Horizontal


Rule

'; + + $json = [ + 'type' => 'doc', + 'content' => [ + [ + 'type' => 'paragraph', + 'content' => [ + [ + 'type' => 'text', + 'text' => 'Horizontal', + ], + ], + ], + [ + 'type' => 'horizontal_rule', + ], + [ + 'type' => 'paragraph', + 'content' => [ + [ + 'type' => 'text', + 'text' => 'Rule', + ], + ], + ], + ], + ]; + + $this->assertEquals($json, (new Renderer)->render($html)); + } +}