{"id":13535672,"url":"https://github.com/nadar/quill-delta-parser","last_synced_at":"2025-10-07T19:42:55.884Z","repository":{"id":33011168,"uuid":"148434477","full_name":"nadar/quill-delta-parser","owner":"nadar","description":"A PHP library to parse and render Quill WYSIWYG Deltas into HTML - Flexibel and extendible for custom elements.","archived":false,"fork":false,"pushed_at":"2025-03-27T13:11:04.000Z","size":403,"stargazers_count":126,"open_issues_count":6,"forks_count":23,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-04T02:29:25.383Z","etag":null,"topics":["delta","hacktoberfest","html","parser","php","quill","quill-delta","quill-editor"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nadar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"nadar"}},"created_at":"2018-09-12T06:44:45.000Z","updated_at":"2025-07-31T13:51:02.000Z","dependencies_parsed_at":"2024-01-14T02:37:01.823Z","dependency_job_id":"e2c1970f-ee00-4fb4-b899-b8d303b29517","html_url":"https://github.com/nadar/quill-delta-parser","commit_stats":{"total_commits":208,"total_committers":13,"mean_commits":16.0,"dds":"0.22115384615384615","last_synced_commit":"40e21fd139ee29b48f3931cf00507879473bc1c3"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/nadar/quill-delta-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadar%2Fquill-delta-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadar%2Fquill-delta-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadar%2Fquill-delta-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadar%2Fquill-delta-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nadar","download_url":"https://codeload.github.com/nadar/quill-delta-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nadar%2Fquill-delta-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278734416,"owners_count":26036404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["delta","hacktoberfest","html","parser","php","quill","quill-delta","quill-editor"],"created_at":"2024-08-01T09:00:20.624Z","updated_at":"2025-10-07T19:42:55.855Z","avatar_url":"https://github.com/nadar.png","language":"PHP","funding_links":["https://github.com/sponsors/nadar"],"categories":["PHP","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# Quill Delta to HTML Parser\n\nA PHP library to parse [Quill WYSIWYG](https://quilljs.com/) editor [deltas](https://github.com/quilljs/delta) into HTML - flexible and extendable for custom elements. Every element is parsed by the same mechanism, making it easy to extend and understand. It also sanitizes the output value, making it more secure, especially when using user-generated text.\n\n![Tests](https://github.com/nadar/quill-delta-parser/workflows/Tests/badge.svg)\n[![Maintainability](https://api.codeclimate.com/v1/badges/fdf80e7b61e4505bc421/maintainability)](https://codeclimate.com/github/nadar/quill-delta-parser/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/fdf80e7b61e4505bc421/test_coverage)](https://codeclimate.com/github/nadar/quill-delta-parser/test_coverage)\n[![Latest Stable Version](https://poser.pugx.org/nadar/quill-delta-parser/v/stable)](https://packagist.org/packages/nadar/quill-delta-parser)\n[![Total Downloads](https://poser.pugx.org/nadar/quill-delta-parser/downloads)](https://packagist.org/packages/nadar/quill-delta-parser)\n[![License](https://poser.pugx.org/nadar/quill-delta-parser/license)](https://packagist.org/packages/nadar/quill-delta-parser)\n\nWhat is Quill? Quill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need.\n\n## Installation\n\nThe package is available only through Composer:\n\n```sh\ncomposer require nadar/quill-delta-parser\n```\n\n## Usage\n\n```php\n// Ensure to load the autoload file from Composer somewhere in your application.\nrequire __DIR__ . '/vendor/autoload.php';\n\n// Create the lexer object with your given Quill JSON delta code (either PHP array or JSON string).\n$lexer = new \\nadar\\quill\\Lexer($json);\n\n// Echo the HTML for the given JSON ops.\necho $lexer-\u003erender();\n```\n\nWhere `$json` is the ops JSON array from Quill, for example:\n\n```json\n{\n  \"ops\": [\n    {\n      \"insert\": \"Hello\"\n    },\n    {\n      \"attributes\": {\n        \"header\": 1\n      },\n      \"insert\": \"\\n\"\n    },\n    {\n      \"insert\": \"\\nThis is the PHP Quill \"\n    },\n    {\n      \"attributes\": {\n        \"bold\": true\n      },\n      \"insert\": \"parser\"\n    },\n    {\n      \"insert\": \"!\\n\"\n    }\n  ]\n}\n```\n\nThis would render the following HTML:\n\n```html\n\u003ch1\u003eHello\u003c/h1\u003e\n\u003cp\u003e\u003cbr\u003e\u003c/p\u003e\n\u003cp\u003eThis is the PHP Quill \u003cstrong\u003eparser\u003c/strong\u003e!\u003c/p\u003e\n```\n\n## Extend the Parser\n\nTo extend the Parser by adding your own listeners (this can be the case if you are using Quill plugins which generate custom delta code), you have to decide whether it's an:\n\n+ Inline element: Replaces content with new parsed content, mostly the case when working with Quill extensions.\n+ Block element: Encloses the whole input with a tag, for example, a heading.\n\nAn example for a mention plugin that generates the following delta `{\"insert\":{\"mention\":{\"id\":\"1\",\"value\":\"Basil\",\"denotationChar\":\"@\"}}}`; an inline plugin could look like this:\n\n```php\nclass Mention extends InlineListener\n{\n    /**\n     * {@inheritDoc}\n     */\n    public function process(Line $line)\n    {\n        // Check if input is JSON, decodes to an array, and checks if the key \"mention\" \n        // exists. If yes, return the value for this key.\n        $mention = $line-\u003einsertJsonKey('mention');\n        if ($mention) {\n            // Apply the inline behavior, updates the content and append to the next \"block\" element.\n            // The value in this example would be \"\u003cstrong\u003eBasil\u003c/strong\u003e\".\n            $this-\u003eupdateInput($line, '\u003cstrong\u003e'.$mention['value'].'\u003c/strong\u003e');\n        }\n    }\n}\n```\n\nNow register the listener:\n\n```php\n$lexer = new Lexer($json);\n$lexer-\u003eregisterListener(new Mention());\necho $lexer-\u003erender();\n```\n\n## Override Built-in Listeners\n\nCertain listeners (image, video, color) produce an HTML output which may not suit your use case, so you have the option to override the properties of those plugins and re-register the Listener. Here's an example with the image tag:\n\n```php\n$image = new Image();\n\n\n$image-\u003ewrapper = '\u003cimg src=\"{src}\" class=\"my-image\" /\u003e';\n\n// Override the default listener behavior for image color:\n$lexer = new Lexer($json);\n$lexer-\u003eregisterListener($image);\necho $lexer-\u003erender();\n```\n\nIf you want to replace a class with your own image class, use `overwriteListener` to achieve the same result, but with your totally custom class. The reason is that listeners are registered by their class names.\n\n```php\n$mySuperClass = new class() extends Image {\n  // Here is the custom class code ...\n};\n\n$lexer-\u003eoverwriteListener(new Image(), $mySuperClass);\n```\n\nOr, of course, when you have a separate file for your class:\n\n```php\nclass MySuperDuperImageClass extends Image\n{\n    // Here is the custom class code ...\n}\n\n$lexer-\u003eoverwriteListener(new Image(), new MySuperDuperImageClass());\n```\n\n## Debugging\n\nSometimes, understanding how delta is handled and parsed can be challenging to debug. Therefore, you can use the debugger class, which will print a table with information about how the data is parsed.\n\n```php\n$lexer = new Lexer($json);\n$lexer-\u003erender(); // Make sure to run the render before calling debugPrint().\n \n$debug = new Debug($lexer);\necho $debug-\u003edebugPrint();\n```\n\nThere is also a built-in Docker Compose file which provides access to the `output.php` file. The `output.php` helps to directly write content with the Quill editor while displaying what is rendered, including all debug information. To run this Docker webserver, execute the following command in the root directory of your Git repository clone:\n\n```sh\ndocker-compose up\n```\n\nand visit `http://localhost:5555/` in your browser.\n\n#### Credits\n\n+ [Lode Claassen](https://github.com/lode)\n+ [Dean Blackborough](https://github.com/deanblackborough)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnadar%2Fquill-delta-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnadar%2Fquill-delta-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnadar%2Fquill-delta-parser/lists"}