krux / postscribe

Asynchronously write javascript, even with document.write.
MIT License
986 stars 157 forks source link

Doesn't render Facebook creatives #366

Closed ayxos closed 7 years ago

ayxos commented 7 years ago

The version of prescribe.js doesn't render Facebook creatives as Facebook uses "custom" HTML tags for their ad placements.

These are not recognized by postscribe.js without a fix - I've did some changes to it already and found it to enable the rendering of those creatives, but there might be more code changes needed, so please check and adapt if necessary.

prescribe/src/streamReaders.js

   // Regular Expressions for parsing tags and attributes
-  var startTag = /^<([\-A-Za-z0-9_!]+)((?:\s+[\w\-]+(?:\s*=?\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
-  var endTag = /^<\/([\-A-Za-z0-9_]+)[^>]*>/;
+  var startTag = /^<([\-A-Za-z0-9_!:]+)((?:\s+[\w\-]+(?:\s*=?\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
+  var endTag = /^<\/([\-A-Za-z0-9_:]+)[^>]*>/;
   var attr = /(?:([\-A-Za-z0-9_]+)\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))|(?:([\-A-Za-z0-9_]+)(\s|$)+)/g;
   var fillAttr = /^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noresize|noshade|nowrap|readonly|selected)$/i;

I dont know if this is just for me or if its mergeable.

P.S i posted this issue on prescribe github repo a month ago. I've just posted it here because maybe gets more attention (https://github.com/krux/prescribe/issues/209)

ayxos commented 7 years ago

This issue has been resolved in the new prescribe version: https://github.com/krux/prescribe/pull/301