PHP code example of everyday / html-to-quill

1. Go to this page and download the library: Download everyday/html-to-quill 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/ */

    

everyday / html-to-quill example snippets


use Everyday\HtmlToQuill\HtmlConverter;

$converter = new HtmlConverter();
echo json_encode($converter->convert("<h1>Hello World!</h1>"));

// {"ops":[{"insert":"Hello World!"},{"insert":"\n","attributes":{"header":1}}]}

class StyleConverter extends CodeConverter {
	public function getSupportedTags(): array {
		return ['style'];
	}
}

class CDataConverter extends TextConverter {
	public function getSupportedTags(): array {
		return ['#cdata-section'];
	}
}

class StyleCodeBlockEnabledHtmlConverter extends HtmlConverter {
	public function __construct(){
		parent::__construct(); // We want our default converters.
		$this->converters[] = new StyleConverter();
		$this->converters[] = new CDataConverter();
	}
}

$converter = new StyleCodeBlockEnabledHtmlConverter();
echo json_encode($converter->convert("<style>.warning {background-color: red;}</style>"));

// {"ops":[{"insert":".warning {background-color: red;}","attributes":{"code":true}},{"insert":"\n"}]}