PHP code example of xen3r0 / adf-converter

1. Go to this page and download the library: Download xen3r0/adf-converter 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/ */

    

xen3r0 / adf-converter example snippets


use Xen3r0\Adf\Parser\Adf\AdfParser;
use Xen3r0\Adf\Exporter\Html\HtmlExporter;

$adf = '{"version":1,"type":"doc","content":[
    {"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Hello"}]},
    {"type":"paragraph","content":[{"type":"text","text":"world"}]}
]}';

$document = (new AdfParser())->parse($adf);
echo (new HtmlExporter())->export($document);
// <h1>Hello</h1><p>world</p>

use Xen3r0\Adf\Parser\Markdown\MarkdownParser;

$document = (new MarkdownParser())->parse("# Title\n\nsome **bold** text");

echo json_encode($document); // valid ADF JSON