crwlr/html-2-text
最新稳定版本:v0.1.2
Composer 安装命令:
composer require crwlr/html-2-text
包简介
Convert HTML to formatted plain text.
README 文档
README
HTML to formatted Plain Text
This easy-to-use package helps you to convert HTML to formatted plain text.
Demo
use Crwlr\Html2Text\Html2Text; $html = <<<HTML <!DOCTYPE html> <html lang="en"> <head><title>Example Website Title</title></head> <body> <script>console.log('test');</script> <style>#app { background-color: #fff; }</style> <article> <h1>Article Headline</h1> <h2>A Subheading</h2> <p>Some text containing <a href="https://www.crwl.io">a link</a>.</p> <ul> <li>list item</li> <li>another list item</li> <li>and one more <ul> <li>second level <ul> <li>third level</li> </ul> </li> </ul> </li> </ul> <table> <thead> <tr><th>column 1</th><th>column 2</th><th>column 3</th></tr> </thead> <tbody> <tr><td>value 1</td><td>value 2</td><td>value 3</td></tr> <tr><td>value 1</td><td colspan="2">value 2 + 3</td></tr> <tr><td colspan="2">value 1 and 2</td><td>value 3</td></tr> <tr><td>value 1</td><td>value 2</td><td>value 3</td></tr> </tbody> </table> </article> </body> </html> HTML; $text = Html2Text::convert($html);
The resulting text:
# Article Headline ## A Subheading Some text containing [a link](https://www.crwl.io). * list item * another list item * and one more * second level * third level | column 1 | column 2 | column 3 | | -------- | -------- | -------- | | value 1 | value 2 | value 3 | | value 1 | value 2 + 3 | | value 1 and 2 | value 3 | | value 1 | value 2 | value 3 |
Documentation
You can find the full documentation at crwlr.software.
Contributing
If you consider contributing something to this package, read the contribution guide (CONTRIBUTING.md).
统计信息
- 总下载量: 13.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-26
