From f35230334ab786cbbc365146241991ff5915cc1f Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 22 Oct 2013 21:29:44 +0000
Subject: [PATCH] Better conversion of html to text if no xml ext

If the xml extension for php is not loaded, this patch will do a better job
of honoring line break hints in the html.
---
 include/html2text.php | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/html2text.php b/include/html2text.php
index 8033a834b..e894a220b 100644
--- a/include/html2text.php
+++ b/include/html2text.php
@@ -27,8 +27,13 @@
 function convert_html_to_text($html, $width=74) {
     $html = fix_newlines($html);
 
-    if (!extension_loaded('xml'))
-        return strip_tags($html);
+    if (!extension_loaded('xml')) {
+        $html = preg_replace(
+           array(':<br ?/?>|</div>:i', ':</p>:i'),
+           array("\n", "\n\n"),
+           $html);
+        return Format::striptags($html);
+    }
 
     $doc = new DOMDocument('1.0', 'utf-8');
     if (!@$doc->loadHTML($html))
-- 
GitLab