Skip to content

Commit 9cae61f

Browse files
Merge pull request #43 from kachkaev/numeric-tags
Support numeric tags
2 parents 99b7b60 + f042340 commit 9cae61f

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

src/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const tagRE = /<[a-zA-Z\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g
1+
const tagRE = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g
22
import parseTag from './parse-tag'
33

44
// re-used obj for quick lookups of components

test/parse.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,57 @@ test('parse', function (t) {
230230
])
231231
t.equal(html, HTML.stringify(parsed))
232232

233+
html = '<0>oh <1>hello</1> there! How are <2>you</2>?</0>'
234+
parsed = HTML.parse(html)
235+
236+
t.deepEqual(parsed, [
237+
{
238+
type: 'tag',
239+
name: '0',
240+
attrs: {},
241+
voidElement: false,
242+
children: [
243+
{
244+
type: 'text',
245+
content: 'oh ',
246+
},
247+
{
248+
type: 'tag',
249+
name: '1',
250+
attrs: {},
251+
voidElement: false,
252+
children: [
253+
{
254+
type: 'text',
255+
content: 'hello',
256+
},
257+
],
258+
},
259+
{
260+
type: 'text',
261+
content: ' there! How are ',
262+
},
263+
{
264+
type: 'tag',
265+
name: '2',
266+
attrs: {},
267+
voidElement: false,
268+
children: [
269+
{
270+
type: 'text',
271+
content: 'you',
272+
},
273+
],
274+
},
275+
{
276+
type: 'text',
277+
content: '?',
278+
},
279+
],
280+
},
281+
])
282+
t.equal(html, HTML.stringify(parsed))
283+
233284
html = '<div class="handles multiple classes" and="attributes"></div>'
234285
parsed = HTML.parse(html)
235286

0 commit comments

Comments
 (0)