datacamp-light icon indicating copy to clipboard operation
datacamp-light copied to clipboard

Accented characters in SCT's incorrect_msg and success_msg

Open basteks opened this issue 3 years ago • 0 comments

Hello everyone, While trying to insert accented characters in the incorrect_msg or success_msg of the <code data-type="sct"> tag, they always appear replaced by [removed] (either typing them directly or using encodeURI() which works well for the <div data-type="hint"> tag). I found a workaround by slightly modifying the StripTagBody function in dcl-react.js.gz : I replaced the return i || (i = c.position), "[removed]"; statement by

var html = String.fromCharCode("0x" + s.substring(2)).replace(/[\u00A0-\u9999<>\&]/g, function(z) {
		return '&#'+z.charCodeAt(0)+';';
});
if (html.substring(0,2)=="&#") {
return i || (i = c.position), html;
}
else {
return i || (i = c.position), "[removed]";
}

Same can be done in dcl-react-dev.js.gz, only param s is now called tag and we only returned var html or string "[removed]" without i || (i = c.position),

Do you think you could integrate this enhancement in the cdn hosted versions of dcl-react ? Best regards, Benjamin

basteks avatar Aug 25 '21 05:08 basteks