     
     open class func wrapTextInHTML(text: String) -> String {
         
-        let strippedString = text.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
+        let whiteSpaceEscaped = text.trimmingCharacters(in: .whitespaces)
+        
+        let strippedString = whiteSpaceEscaped.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
         
         let detector =  try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
         

        
        return output
    }
    
    open class func cleanStringIncludingParagraphBreaks(body: String) -> String {
        var output = body
        output = cleanString(body: output)
        output = output.replacingOccurrences(of: "<p><br></p>", with: "")
        return output
    }
    
    open class func flattenString(text: String) -> String{
        var output = text
        output = output.replacingOccurrences(of: "\n", with: "")
        output = output.replacingOccurrences(of: "<p>", with: " ")
        output = output.replacingOccurrences(of: "</p>", with: " ")
        output = output.replacingOccurrences(of: "<br>", with: " ")
        return output
    }
    
    open class func attributedTextForString(text: String) -> NSAttributedString {
        
        guard let htmlStringData = text.data(using: String.Encoding.utf8) else {

            }
        }
        
        newStr = newStr.replacingOccurrences(of: "\n", with: "<br />")
        return newStr
    }
}
