作者 邓超

body html to text

... ... @@ -308,7 +308,10 @@ class Body {
* @time 2024/9/21 9:55
*/
public function getText():string {
return $this->getHtmlOrText('text/plain') ? : strip_tags($this->getHtml());
$text = $this->getHtmlOrText('text/plain') ? : $this->getHtml();
$text = preg_replace('/<style.*?<\/style>/is', '', $text);
$text = preg_replace('/<script.*?<\/script>/is', '', $text);
return strip_tags($text);
}
/**
... ...