diff --git a/src/parse.js b/src/parse.js index 05f636d..f94ec7b 100644 --- a/src/parse.js +++ b/src/parse.js @@ -1,4 +1,4 @@ -const tagRE = /<[a-zA-Z\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g +const tagRE = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g import parseTag from './parse-tag' // re-used obj for quick lookups of components diff --git a/test/parse.js b/test/parse.js index 930475b..a88558e 100644 --- a/test/parse.js +++ b/test/parse.js @@ -230,6 +230,57 @@ test('parse', function (t) { ]) t.equal(html, HTML.stringify(parsed)) + html = '<0>oh <1>hello1> there! How are <2>you2>?0>' + parsed = HTML.parse(html) + + t.deepEqual(parsed, [ + { + type: 'tag', + name: '0', + attrs: {}, + voidElement: false, + children: [ + { + type: 'text', + content: 'oh ', + }, + { + type: 'tag', + name: '1', + attrs: {}, + voidElement: false, + children: [ + { + type: 'text', + content: 'hello', + }, + ], + }, + { + type: 'text', + content: ' there! How are ', + }, + { + type: 'tag', + name: '2', + attrs: {}, + voidElement: false, + children: [ + { + type: 'text', + content: 'you', + }, + ], + }, + { + type: 'text', + content: '?', + }, + ], + }, + ]) + t.equal(html, HTML.stringify(parsed)) + html = '
' parsed = HTML.parse(html)