Open
Description
const ngHtmlParser = require('angular-html-parser')
const { rootNodes } = ngHtmlParser.parse(
/* HTML */ `
<svg:defs>
<svg:linearGradient></svg:linearGradient>
</svg:defs>
`.trim(),
)
console.log('rootNodes:', ...rootNodes)
rootNodes: Element {
name: ':svg:defs', // <-- why?
attrs: [],
children: [
Text {
value: '\n ',
sourceSpan: [ParseSourceSpan],
i18n: undefined,
type: 'text'
},
Element {
name: ':svg:linearGradient',
attrs: [],
children: [],
sourceSpan: [ParseSourceSpan],
startSourceSpan: [ParseSourceSpan],
endSourceSpan: [ParseSourceSpan],
nameSpan: [ParseSourceSpan],
i18n: null,
type: 'element'
},
Text {
value: '\n ',
sourceSpan: [ParseSourceSpan],
i18n: undefined,
type: 'text'
}
],
sourceSpan: ParseSourceSpan {
start: ParseLocation {
file: [ParseSourceFile],
offset: 0,
line: 0,
col: 0
},
end: ParseLocation {
file: [ParseSourceFile],
offset: 10,
line: 0,
col: 10
},
details: null
},
startSourceSpan: ParseSourceSpan {
start: ParseLocation {
file: [ParseSourceFile],
offset: 0,
line: 0,
col: 0
},
end: ParseLocation {
file: [ParseSourceFile],
offset: 10,
line: 0,
col: 10
},
details: null
},
endSourceSpan: ParseSourceSpan {
start: ParseLocation {
file: [ParseSourceFile],
offset: 63,
line: 2,
col: 4
},
end: ParseLocation {
file: [ParseSourceFile],
offset: 74,
line: 2,
col: 15
},
details: null
},
nameSpan: ParseSourceSpan {
start: ParseLocation {
file: [ParseSourceFile],
offset: 1,
line: 0,
col: 1
},
end: ParseLocation {
file: [ParseSourceFile],
offset: 9,
line: 0,
col: 9
},
details: null
},
i18n: null,
type: 'element'
}
Metadata
Assignees
Labels
No labels