PHP code example of becklyn / mobiledoc

1. Go to this page and download the library: Download becklyn/mobiledoc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

becklyn / mobiledoc example snippets


use Becklyn\Mobiledoc\Extension\ExtensionRegistry;
use Becklyn\Mobiledoc\Renderer\MobiledocRenderer;

$extensions = new ExtensionRegistry();
$renderer = new MobiledocRenderer($extensions);

// returns the rendered document
$document = $renderer->render([
    "version" => "0.3.1",
    // ... rest of the mobiledoc document
]);


// returns the mobiledoc
$document->getMobiledoc();

// returns the HTML
$document->getHtml();
(string) $document:

use Becklyn\Mobiledoc\Extension\ExtensionRegistry;
use Becklyn\Mobiledoc\Extension\RichTextExtensionInterface;


class IframeCard implements RichTextExtensionInterface
{
    /**
     * @inheritDoc
     */
    public function getName () : string
    {
        return "iframe";
    }


    /**
     * @inheritDoc
     */
    public function render (?string $content, array $payload) : string
    {
        return '<iframe src="' . $payload["src"] . '"></iframe>';
    }
}


$extensions = new ExtensionRegistry();
$extensions->registerExtension(new IframeCard());