You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
448 B
21 lines
448 B
const {
|
|
Parser,
|
|
DomHandler
|
|
} = require('stricter-htmlparser2')
|
|
|
|
|
|
module.exports = function parse(sourceCode) {
|
|
const handler = new DomHandler()
|
|
new Parser(handler, {
|
|
xmlMode: false,
|
|
lowerCaseAttributeNames: false,
|
|
recognizeSelfClosing: true,
|
|
lowerCaseTags: false
|
|
}).end(sourceCode)
|
|
return {
|
|
type: 'tag',
|
|
name: 'root',
|
|
attribs: {},
|
|
children: Array.isArray(handler.dom) ? handler.dom : [handler.dom]
|
|
}
|
|
}
|
|
|