{"id":16981113,"url":"https://github.com/masroore/php-html2text","last_synced_at":"2025-03-21T23:26:47.965Z","repository":{"id":57703147,"uuid":"502768867","full_name":"masroore/php-html2text","owner":"masroore","description":"A PHP package to convert HTML into a plain text format","archived":false,"fork":false,"pushed_at":"2022-06-13T02:07:08.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T23:50:44.564Z","etag":null,"topics":["html","html-parser","html2text"],"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/masroore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-13T01:26:39.000Z","updated_at":"2023-12-03T14:32:12.000Z","dependencies_parsed_at":"2022-09-26T21:11:34.643Z","dependency_job_id":null,"html_url":"https://github.com/masroore/php-html2text","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masroore%2Fphp-html2text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masroore%2Fphp-html2text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masroore%2Fphp-html2text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masroore%2Fphp-html2text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masroore","download_url":"https://codeload.github.com/masroore/php-html2text/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244882366,"owners_count":20525840,"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","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":["html","html-parser","html2text"],"created_at":"2024-10-14T02:04:39.929Z","updated_at":"2025-03-21T23:26:47.937Z","avatar_url":"https://github.com/masroore.png","language":"PHP","readme":"# A PHP package to convert HTML into plain text -- no HTML tags allowed in the output.\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/masroore/html2text.svg?style=flat-square)](https://packagist.org/packages/masroore/html2text)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/masroore/php-html2text/run-tests?label=tests)](https://github.com/masroore/php-html2text/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/masroore/php-html2text/Check%20\u0026%20fix%20styling?label=code%20style)](https://github.com/masroore/php-html2text/actions?query=workflow%3A\"Check+%26+fix+styling\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/masroore/html2text.svg?style=flat-square)](https://packagist.org/packages/masroore/html2text)\n\n## Overview ##\n\n**masroore/html2text** is a PHP package that converts a page of HTML into clean, easy-to-read plain ASCII text.\n\n## Installation\n\n\u003e **Requires [PHP 8.0+](https://php.net/releases/)**\n\nYou can install the package via composer:\n\n```bash\ncomposer require masroore/html2text\n```\n\n## Usage\n\nExtract text from HTML:\n\n```php\nuse Kaiju\\Html2Text\\Html2Text;\n\n$converter = new Html2Text();\necho $converter-\u003econvert($html);\n```\n\n**Callback functions**\n\nYou are able to change process of formatting by providing callbacks in pre-processing, tag-replacing and post-processing:\n\n```php\n# assign a pre-processing callback function. (transform href links)\n$converter-\u003esetPreProcessingCallback(fn (string $s) =\u003e preg_replace('%\u003c\\s*a[^\u003e]*href=[\\'\"](.*?)[\\'\"][^\u003e]*\u003e([\\s\\S]*?)\u003c\\/\\s*a\\s*\u003e%i', '$2 ($1)', $s));\n\n# assign a tag-replacement callback function. (replace \u003cli\u003e tags)\n$converter-\u003esetTagReplacementCallback(fn (string $s) =\u003e preg_replace('/\u003c\\s*li[^\u003e]*\u003e/i', \"\\n- \", $s));\n\n# post-processing hook\n$converter-\u003esetPostProcessingCallback(...);\n\n# process HTML\necho $converter-\u003econvert($html);\n```\n\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nThank you for considering to contribute to Html2Text. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Masroor Ehsan](https://github.com/masroore)\n- [All Contributors](../../contributors)\n\n## License\n\nHtml2Text is an open-sourced software licensed under the [MIT license](LICENSE.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasroore%2Fphp-html2text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasroore%2Fphp-html2text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasroore%2Fphp-html2text/lists"}