diff --git a/converter.html b/converter.html index 7d8173b..99f8ad6 100644 --- a/converter.html +++ b/converter.html @@ -3,7 +3,7 @@ -HTML to Aris +HTML to Aris Converter @@ -21,6 +21,7 @@ var isArray = isT('Array'); self.htmlToCtx = function (html) { + var tagRe = /<(\/)?([^\s<>"'`=]+)((\s+[^\s<>"'`=]+(\s*=\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*'|[^'">\s]+))?)+\s*|\s*)(\/)?>/g; var attrRe = /([^\s<>"'`=]+)(\s*=\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*'|[^'">\s]+))?/g; var voidsRe = /area|base|br|col|command|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr/; @@ -28,6 +29,9 @@ var m, root = [''], stack = {c: root}, last = 0, d, tag, k, v; + // remove comments + html = html.replace(/("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*'|`[^`\\]*(?:\\.[^`\\]*)*`)|()/g, '$1'); + while (m = tagRe.exec(html)) { if (!stack) stack = {c: root};