datasucker / netrunner-datasucker

MIT License
20 stars 7 forks source link

Remove HTML entities from text/titles #6

Open gereons opened 9 years ago

gereons commented 9 years ago

Special characters like & and ' should not be encoded as HTML entities (e.g. card 01036)

ryson282 commented 9 years ago

Possible function to impact: decodeHtmlEntity in main.js

ryson282 commented 9 years ago

Solution: Line 21 of main.js, replace card.title = rawCard.name; by card.title = parseRawValue(rawCard,"name", false);

and modify decodeHtmlEntity as follows.

var decodeHtmlEntity = function(str) { var ret = str.replace(/&#(\d+);/g, function(match, dec) { return String.fromCharCode(dec); }); ret = ret.replace(/</g, '<'); ret = ret.replace(/"/g, '"'); ret = ret.replace(/'/g, "'"); ret = ret.replace(/&/g, '&'); return ret; };

This has been tested & works well. However, this is quite an ugly and not generic code but I did not found how to do this in another way.

Any thought on how to rewrite the decodeHtmlEntity properly ?

ryson282 commented 9 years ago

NB in the previous post / & q u o t ; was automatically translated as /" , etc ...