 
     public func convert(html: NSData) -> NSAttributedString {
 
+        let result = NSMutableAttributedString()
         let bufferSize = 1024
         let buffer = Array<Int8>(count: bufferSize, repeatedValue: 0)
         let htmlPtr = UnsafePointer<Int8>(html.bytes)


            super.init(name: name)
        }
    }

    let name: String
    let attributes: [Attribute]?

    init(name: String, attributes: [Attribute]?) {
        self.name = name
        self.attributes = attributes
    }
}



        if rootElementPtr != nil {
            let rootElement = rootElementPtr.memory

            guard let rootElementName = String(CString: UnsafePointer<Int8>(rootElement.name), encoding: NSUTF8StringEncoding) else {
                // We should evaluate how to improve this condition check... is a nil value
                // possible at all here?  If so... do we want to interrupt the parsing or try to
                // recover from it?
                //
                // For the sake of moving forward I'm just interrupting here, but this could change
                // if we find a unit test causing a nil value here.
                //
                fatalError("The root element name should not be nil.")
            }

            let tag = HTMLTag(name: rootElementName)

            var property = rootElement.properties

            while (property != nil) {
                guard let propertyName = String(CString: UnsafePointer<Int8>(property.memory.name), encoding: NSUTF8StringEncoding) else {
                    // We should evaluate how to improve this condition check... is a nil value
                    // possible at all here?  If so... do we want to interrupt the parsing or try to
                    // recover from it?
                    //
                    // For the sake of moving forward I'm just interrupting here, but this could change
                    // if we find a unit test causing a nil value here.
                    //
                    fatalError("The root element name should not be nil.")
                }

                let attribute = HTMLTag.Attribute(name: propertyName)
                tag.attributes.append(attribute)

                property = property.memory.next
            }

            result.addAttribute("HTMLTag", value: tag, range: NSRange(location: 0, length: 0))
        }

        return result
    }
}
