Takes ProseMirror JSON and renders HTML.
Branch: master
Clone or download
Hans Pagel
Latest commit a5555a8 Feb 6, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src add link mark support Feb 6, 2019
tests add link mark support Feb 6, 2019
.gitignore initial commit Jan 23, 2019
.travis.yml initial commit Jan 23, 2019
LICENSE.md add LICENSE Feb 6, 2019
README.md
composer.json initial commit Jan 23, 2019
composer.lock
phpunit.xml.dist

README.md

HTML to ProseMirror

Takes ProseMirror JSON and outputs HTML.

Installation

composer require scrumpy/prosemirror-to-html

Usage

(new \Scrumpy\ProseMirrorToHtml\Renderer)->render([
    'type' => 'doc',
    'content' => [
        [
            'type' => 'paragraph',
            'content' => [
                [
                    'type' => 'text',
                    'text' => 'Example Paragraph',
                ],
            ],
        ],
    ],
])

Output

<p>Example Text</p>

Custom Nodes

Define your custom nodes as PHP classes:

<?php

class CustomNode extends \Scrumpy\ProseMirrorToHtml\Nodes\Node
{
    public function matching()
    {
        return $this->node->type === 'custom';
    }

    public function tag()
    {
        return 'marquee';
    }
}

And register them:

$renderer->addNode(CustomNode::class);

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.