robquistnl / simplehtmltotext
一个简单的PHP类,用于将HTML转换为文本
v1.1.1
2016-11-24 15:02 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2024-08-30 01:37:52 UTC
README
一个简单的PHP类,用于将HTML转换为纯文本(例如,用于电子邮件)
安装
使用composer安装(composer require robquistnl/simplehtmltotext)。
用法
$myHtml = '<b>This is HTML</b><h1>Header</h1><br/><br/>Newlines'; echo (new Parser())->parseString($myHtml);
返回
**This is HTML**
### Header ###
Newlines
支持的标签
目前只支持一些基本的标签,并且不会检查CSS。
brhrh1、h2、h3、h4、h5、h6table、tr、td、th(非常基本的支持)b、strong、u、i、ema简单支持;<a href="http://example.org">点击这里</a>变为点击这里 (http://example.org)img简单支持;<img src="http://example.org/image.jpg">变为和<img alt="title" src="http://example.org/image.jpg">变为(title)ul、ol、li、dd、dt