sqginfo/html2text
Composer 安装命令:
composer require sqginfo/html2text
包简介
A PHP script to convert HTML into a plain text format
README 文档
README
html2text is a very simple script that uses PHP's DOM methods to load from HTML, and then iterates over the resulting DOM to correctly output plain text. For example:
<html> <title>Ignored Title</title> <body> <h1>Hello, World!</h1> <p>This is some e-mail content. Even though it has whitespace and newlines, the e-mail converter will handle it correctly. <p>Even mismatched tags.</p> <div>A div</div> <div>Another div</div> <div>A div<div>within a div</div></div> <a href="http://foo.com">A link</a> </body> </html>
Will be converted into:
Hello, World!
This is some e-mail content. Even though it has whitespace and newlines, the e-mail converter will handle it correctly.
Even mismatched tags.
A div
Another div
A div
within a div
[A link](http://foo.com)
See the original blog post or the related StackOverflow answer.
Installing
You can use Composer to add the package to your project:
{
"require": {
"soundasleep/html2text": "~0.3"
}
}
And then use it quite simply:
$text = Html2Text\Html2Text::convert($html);
You can also include the supplied html2text.php and use $text = convert_html_to_text($html); instead.
Tests
Some very basic tests are provided in the tests/ directory. Run them with composer install --dev && vendor/bin/phpunit.
License
html2text is dual licensed under both EPL v1.0 and LGPL v3.0, making it suitable for both Eclipse and GPL projects.
Other versions
Also see html2text_ruby, a Ruby implementation.
sqginfo/html2text 适用场景与选型建议
sqginfo/html2text 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 520 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「text」 「email」 「html」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sqginfo/html2text 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sqginfo/html2text 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sqginfo/html2text 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Common libraries used by Zimbra Api
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Text file manipulation
Plain text view engine
统计信息
- 总下载量: 520
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: EPL-1.0
- 更新时间: 2016-12-05