jindw / xmldom

A PURE JS W3C Standard based(XML DOM Level2 CORE) DOMParser and XMLSerializer.
Other
819 stars 265 forks source link

Added shy, mdash, ndash to entityMap. #205

Open valinaga opened 7 years ago

valinaga commented 7 years ago

For epub documents which includes these special symbols, exception was raised if not found. Adding them to entityMap fixed the problem.

gaggle commented 7 years ago

I encountered the [xmldom error] entity not found:— error. I've switched to @valinaga's fork and my tests now pass. Thanks @valinaga.

bigeasy commented 7 years ago

They don't belong there. You need to include them.

https://stackoverflow.com/questions/13707500/how-to-include-html-entities-into-an-xml-file

gaggle commented 7 years ago

@bigeasy can you elaborate how one "includes them"? I've tried to implement the SO answers but have not gotten it past the mdash.

What I'd like to work is something like this:

const o = {locator: {},errorHandler: (lvl, msg) => {throw new Error(msg)}}
new xmldom.DOMParser(o).parseFromString('<p>&mdash;</p>', 'text/xml')

That fails with:

Error: [xmldom error]   element parse error: Error: [xmldom error]  entity not found:&mdash;

!ENTITY blocks have not helped, e.g.

new xmldom.DOMParser(o).parseFromString('<?xml version="1.0" encoding="utf-8"?> <!ENTITY mdash "&#8212;"> <p>&mdash;</p>', 'text/xml')

Is this the direction you're suggesting as an alternative to this pull request?

(and I didn't mean to steal your thread @valinaga, if this is noise for your problem I can make a new thread)

bigeasy commented 7 years ago

Looking at the code quickly, I don't see that the parser parses ENTITY processing instructions. Will look harder tonight.

gaggle commented 7 years ago

@bigeasy did you get a chance to look further into this? I don't mean to imply impatience on my part, I'm happy this project exists at all and that you chose to contribute :), but in the event that you have had time to look into this matter I will happily listen for hints and help on a schedule that suits you, as I have been unable to progress on my own.