Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deanblackborough/php-quill-renderer

Render quill insert deltas to HTML, Markdown and GitHub flavoured Markdown (150k installs on Packagist)
https://github.com/deanblackborough/php-quill-renderer

deltas-renderer html markdown mit-license php-quill-renderer php7 quill renderer

Last synced: about 1 month ago
JSON representation

Render quill insert deltas to HTML, Markdown and GitHub flavoured Markdown (150k installs on Packagist)

Awesome Lists containing this project

README

        

[![Latest Stable Version](https://img.shields.io/packagist/v/deanblackborough/php-quill-renderer.svg?style=flat-square)](https://packagist.org/packages/deanblackborough/php-quill-renderer)
![Packagist](https://img.shields.io/packagist/dt/deanblackborough/php-quill-renderer.svg)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/deanblackborough/php-quill-renderer/blob/master/LICENSE)
[![Minimum PHP Version](https://img.shields.io/badge/php->=7.4-8892BF.svg)](https://php.net/)
[![Supported PHP Version](https://img.shields.io/badge/php-^8.0-8892BF.svg)](https://php.net/)
[![Supported PHP Version](https://img.shields.io/badge/php-^8.1-8892BF.svg)](https://php.net/)
[![Validate dependencies and run tests](https://github.com/deanblackborough/php-quill-renderer/actions/workflows/php.yml/badge.svg)](https://github.com/deanblackborough/php-quill-renderer/actions/workflows/php.yml)

# PHP Quill Renderer

Render quill insert deltas to HTML, Markdown and GitHub flavoured Markdown.

## Read-only
It doesn't look like there will be new version of Quill, I've decided to make the repo read-only, I'm not going to dedicate anymore time to this package.

## Description

[Quill](https://github.com/quilljs/quill) deltas renderer, converts deltas to HTML and Markdown, the [Quill](https://github.com/quilljs/quill) attributes
supported are listed in the table below, the goal is to eventually support every Quill feature.

[Quill](https://github.com/quilljs/quill) is a modern WYSIWYG editor built for compatibility and extensibility.

## Installation

The easiest way to use the `PHP Quill Renderer` is via composer.
```composer require deanblackborough/php-quill-renderer```,
alternatively you can include the classes in my src/ directory directly in your
library or app.

## Usage

### Via API, single $quill_json
```php
try {
$quill = new \DBlackborough\Quill\Render($quill_json);
$result = $quill->render();
} catch (\Exception $e) {
echo $e->getMessage();
}

echo $result;
```

### Via API, multiple $quill_json, passed in via array

```php
try {
$quill = new RenderMultiple($quill_json, 'HTML');

$result_one = $quill->render('one');
$result_two = $quill->render('two');
} catch (\Exception $e) {
echo $e->getMessage();
}

echo $result_one;
echo $result_two;
```

### Direct, parse and then render, single $quill_json - updated in v3.10.0

```php
$parser = new \DBlackborough\Quill\Parser\Html();
$renderer = new \DBlackborough\Quill\Renderer\Html();

$parser->load($quill_json)->parse();

echo $renderer->load($parser->deltas())->render();
```

### Direct, parse and then render, multiple $quill_json - updated in v3.10.0

```php
$parser = new \DBlackborough\Quill\Parser\Html();
$renderer = new \DBlackborough\Quill\Renderer\Html();

$parser->loadMultiple(['one'=> $quill_json_1, 'two' => $quill_json_2)->parseMultiple();

echo $renderer->load($parser->deltasByIndex('one'))->render();
echo $renderer->load($parser->deltasByIndex('two'))->render();
```

## Quill attributes and text flow support

| Attribute | v1+ | v2+ | v3 HTML | v3 Markdown
| :---: | :---: | :---: | :---: | :---:
| Bold | Yes | Yes | Yes | Yes
| Italic | Yes | Yes | Yes | Yes
| Link | Yes | Yes | Yes | Yes
| Strike | Yes | Yes | Yes | N/A
| Script:Sub | Yes | Yes | Yes | N/A
| Script:Super | Yes | Yes | Yes | N/A
| Underline | Yes | Yes | Yes | N/A
| Header | Yes | Yes | Yes | Yes
| Image | Yes | Yes | Yes | Yes
| Video | No | No | Yes | Yes
| List | Yes | Yes | Yes | Yes
| Child lists | No | No | No | No
| Indent/Outdent | No| No | No | No
| Text direction | No | No | No | N/A
| Color | No | No | No | N/K
| Font | No | No | No | N/K
| Text align | No | No | No | N/A
| Block quote | No | No | No | No
| Code block | No | No | No | No
| Custom attributes | No | No | Yes | N/A
| Line breaks | No | No | Yes | Yes
| Paragraphs | Yes | Yes | Yes | Yes

| Attribute | HTML Tag | Markdown Token
| :---: | :---: | :---:
| Bold | `` | `**`
| Italic | `` | `*`
| Link | `` | `[Text](Link)`
| Strike | `` |
| Script:Sub | `` |
| Script:Super | `` |
| Underline | `` |
| Header | `` | `#[n]`
| Image | `` | `![Image](\path\to\image)`
| Video | `` | `![Video](\path\to\video)`
| List | `