{"id":21344443,"url":"https://github.com/freshleafmedia/tiptap-parser","last_synced_at":"2026-02-07T02:02:29.207Z","repository":{"id":237292924,"uuid":"794219217","full_name":"freshleafmedia/tiptap-parser","owner":"freshleafmedia","description":"A PHP package for rendering Tiptap JSON to HTML","archived":false,"fork":false,"pushed_at":"2024-06-19T15:10:22.000Z","size":64,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T03:37:27.151Z","etag":null,"topics":["hacktoberfest","parser","render","tiptap","tiptap-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/freshleafmedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-04-30T17:26:07.000Z","updated_at":"2025-10-03T08:24:03.000Z","dependencies_parsed_at":"2024-06-20T02:02:04.586Z","dependency_job_id":"d5739ce4-b060-4049-9d7e-3fd4f9ce5fbd","html_url":"https://github.com/freshleafmedia/tiptap-parser","commit_stats":null,"previous_names":["freshleafmedia/tiptap-parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/freshleafmedia/tiptap-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Ftiptap-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Ftiptap-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Ftiptap-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Ftiptap-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freshleafmedia","download_url":"https://codeload.github.com/freshleafmedia/tiptap-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshleafmedia%2Ftiptap-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29184977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T00:44:15.062Z","status":"online","status_checked_at":"2026-02-07T02:00:07.217Z","response_time":63,"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":["hacktoberfest","parser","render","tiptap","tiptap-editor"],"created_at":"2024-11-22T01:19:05.230Z","updated_at":"2026-02-07T02:02:29.188Z","avatar_url":"https://github.com/freshleafmedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tiptap JSON Parser\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/freshleafmedia/tiptap-parser.svg?style=flat-square)](https://packagist.org/packages/freshleafmedia/tiptap-parser)\n[![Total Downloads](https://img.shields.io/packagist/dt/freshleafmedia/tiptap-parser.svg?style=flat-square)](https://packagist.org/packages/freshleafmedia/tiptap-parser)\n[![License](https://img.shields.io/packagist/l/freshleafmedia/tiptap-parser?style=flat-square)](https://packagist.org/packages/freshleafmedia/tiptap-parser)\n\n---\n\nThis package simply converts the JSON output from the [Tiptap editor](https://github.com/awcodes/filament-tiptap-editor) to HTML.\nIt differs from [other packages](https://github.com/ueberdosis/tiptap-php) by allowing you to easily customise and extend the HTML output.\n\n---\n\n## Installation\n\n```\ncomposer require freshleafmedia/tiptap-parser\n```\n\n## Basic Usage\n\n```php\nuse FreshleafMedia\\TiptapParser\\TiptapContent;\n\n$tiptapArray = [\n    'type' =\u003e 'paragraph',\n    'content' =\u003e [\n        [\n            'type' =\u003e 'text',\n            'text' =\u003e 'Hello world',\n        ],\n    ],\n];\n\nTiptapContent::make($tiptapArray)-\u003etoHtml(); // \u003cp\u003eHello world\u003c/p\u003e\n```\n\n\n## Customising A Node\n\n```php\nuse FreshleafMedia\\TiptapParser\\Nodes\\Paragraph;\n\nreadonly class CustomParagraph extends Paragraph\n{\n    public function render(): string\n    {\n        return \u003c\u003c\u003cHTML\n            \u003cp class=\"paragraph\"\u003e\n                {$this-\u003erenderInnerHtml()}\n            \u003c/p\u003e\n            HTML;\n    }\n}\n\n$html = Parser::fromArray($tiptapArray)\n    -\u003eregisterNode('paragraph', CustomParagraph::class)\n    -\u003etoHtml(); // \u003cp class=\"paragraph\"\u003eHello world\u003c/p\u003e\n```\n\n\n## Accessing Custom Attributes\n\nNodes are instantiated via the `fromArray` method, the method is passed all the data from the original array.\n\nFor example given this array:\n\n```php\n[\n    'type' =\u003e 'paragraph',\n    'attrs' =\u003e [\n        'lang' =\u003e 'en',\n    ]\n]\n```\n\nWe can easily add the `lang` attribute to the `p` element like this:\n\n```php\nuse FreshleafMedia\\TiptapParser\\Nodes\\Paragraph;\n\nreadonly class LocalisedParagraph extends Paragraph\n{\n    public function __construct(\n        public string $language,\n        public array $children = [],\n    )\n    {\n    }\n\n    public function render(): string\n    {\n        return \u003c\u003c\u003cHTML\n            \u003cp lang=\"{$this-\u003elanguage}\"\u003e\n                {$this-\u003erenderInnerHtml()}\n            \u003c/p\u003e\n            HTML;\n    }\n\n    public static function fromArray(array $array): self\n    {\n        return new self(\n            $array['attrs']['lang'] ?? 'en',\n            $array['children'] ?? [],\n        );\n    }\n}\n```\n\n\n## Plain Text\n\nPlain text can be extracted available via the `toText` method. This is useful for things like populating a search index.\n\n```php\nuse FreshleafMedia\\TiptapParser\\TiptapContent;\n\n$tiptapArray = [\n    'type' =\u003e 'paragraph',\n    'content' =\u003e [\n        [\n            'type' =\u003e 'text',\n            'text' =\u003e 'Hello world',\n            'marks' =\u003e [\n                ['type' =\u003e 'bold'],\n            ],\n        ],\n    ],\n];\n\nTiptapContent::make($tiptapArray)-\u003etoHtml(); // \u003cp\u003e\u003cstrong\u003eHello world\u003c/strong\u003e\u003c/p\u003e\nTiptapContent::make($tiptapArray)-\u003etoText(); // Hello world\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshleafmedia%2Ftiptap-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreshleafmedia%2Ftiptap-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshleafmedia%2Ftiptap-parser/lists"}