<commit_before>[![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/)

# PHP Quill Renderer

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

## 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.

## v4.00.0 and continued development

I released version 4.00.0 to update dependencies to PHP 7.4 and PHP 8.0. After 
a hiatus, I'm back to use Quill in commercial projects, so I will be upgrading the 
library at some point this year.

Initially, the work will be towards supporting PHP 8 and 7.4 features and a
general cleanup, the code needs to be updated to be more modular and allow 
plugins, then you can pick and choose what functions to support.

No timeline, I'm working on this in my limited free time.

## 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
```
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

```
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

```
$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

```
$parser = new \DBlackborough\Quill\Parser\Html();
$renderer = new \DBlackborough\Quill\Renderer\Html();
<commit_msg>feat: update README, add syntaxe for exemples<commit_after>[![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/)

# PHP Quill Renderer

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

## 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.

## v4.00.0 and continued development

I released version 4.00.0 to update dependencies to PHP 7.4 and PHP 8.0. After 
a hiatus, I'm back to use Quill in commercial projects, so I will be upgrading the 
library at some point this year.

Initially, the work will be towards supporting PHP 8 and 7.4 features and a
general cleanup, the code needs to be updated to be more modular and allow 
plugins, then you can pick and choose what functions to support.

No timeline, I'm working on this in my limited free time.

## 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
```injectablephp
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

```injectablephp
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

```injectablephp
$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

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

{'fraction_non_alphanumeric': 0.13644460277876735, 'fraction_numerical': 0.010331314570716068, 'mean_word_length': 4.587064676616915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2287544', 'n_tokens_mistral': 1892, 'n_tokens_neox': 1826, 'n_words': 536}