作者 邓超

body html to text

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