Skip to content

wiebkevogel/prosemirror-to-html

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProseMirror to HTML

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>

Supported Nodes

  • Blockquote
  • BulletList
  • CodeBlock
  • HardBreak
  • Heading
  • ListItem
  • OrderedList
  • Paragraph
  • Table
  • TableRow
  • TableHeader
  • TableCell

Supported Marks

  • Bold
  • Code
  • Italic
  • Link

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

Pull Requests are welcome.

Credits

License

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

About

Takes ProseMirror JSON and renders HTML.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%