robquistnl/simplehtmltotext

一个简单的PHP类,用于将HTML转换为文本

v1.1.1 2016-11-24 15:02 UTC

This package is auto-updated.

Last update: 2024-08-30 01:37:52 UTC


README

Build Status Latest Stable Version Total Downloads License

一个简单的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。

  • br
  • hr
  • h1h2h3h4h5h6
  • tabletrtdth(非常基本的支持)
  • bstronguiem
  • a 简单支持;<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)
  • ulollidddt