diff --git a/dom-parser.js b/dom-parser.js index e45dd47..1b9749c 100644 --- a/dom-parser.js +++ b/dom-parser.js @@ -1,6 +1,6 @@ function DOMParser(options){ this.options = options ||{locator:{}}; - + } DOMParser.prototype.parseFromString = function(source,mimeType){ @@ -11,11 +11,14 @@ DOMParser.prototype.parseFromString = function(source,mimeType){ var locator = options.locator; var defaultNSMap = options.xmlns||{}; var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1; - var entityMap = isHTML?htmlEntity.entityMap:{'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"}; + var entityMap = isHTML?htmlEntity.entityMap: { + 'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'", + 'shy': '-','mdash': '-','ndash': '-' + }; if(locator){ domBuilder.setDocumentLocator(locator) } - + sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator); sax.domBuilder = options.domBuilder || domBuilder; if(isHTML){ @@ -58,8 +61,8 @@ function buildErrorHandler(errorImpl,domBuilder,locator){ /** * +ContentHandler+ErrorHandler * +LexicalHandler+EntityResolver2 - * -DeclHandler-DTDHandler - * + * -DeclHandler-DTDHandler + * * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2 * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html @@ -74,7 +77,7 @@ function position(locator,node){ /** * @see org.xml.sax.ContentHandler#startDocument * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html - */ + */ DOMHandler.prototype = { startDocument : function() { this.doc = new DOMImplementation().createDocument(null, null, null); @@ -88,7 +91,7 @@ DOMHandler.prototype = { var len = attrs.length; appendElement(this, el); this.currentElement = el; - + this.locator && position(this.locator,el) for (var i = 0 ; i < len; i++) { var namespaceURI = attrs.getURI(i); @@ -151,7 +154,7 @@ DOMHandler.prototype = { this.locator && position(this.locator,comm) appendElement(this, comm); }, - + startCDATA:function() { //used in characters() methods this.cdata = true; @@ -159,7 +162,7 @@ DOMHandler.prototype = { endCDATA:function() { this.cdata = false; }, - + startDTD:function(name, publicId, systemId) { var impl = this.doc.implementation; if (impl && impl.createDocumentType) {