I am trying to make an array from string. the string contains HTML tags like P, span, a,img. some are nested like span tag inside p, img tag inside a etc. i would not replace any tags or styles. I am trying to parse all the tags and make an array.
Example code looks like this in textData variable
var line_array =[];
var textData : `
<img src="imgurl" alt="" />
<p>some text</p>
<p style="cssStyle">some text</p>
<span style="cssStyle"> some text </span>
<p style="cssStyle">some text<span style="cssStyle"> span text </span></p>
<a href=""><span style="style">text</span><img src="https://via.placeholder.com/100" alt=""/> </a>
`
activate: function (){
let sourceText = document.getElementById('sourceText').innerHTML;
line_array = sourceText;
}
I am trying to make an array look like this... from textData
line_array =[
'<img src="imgurl" alt="" />',
'<p>some text</p>',
'<p style="cssStyle">some text</p>',
'<span style="cssStyle"> some text </span>',
'<p style="cssStyle">some text<span style="cssStyle"> span text </span</p>',
'<a href=""><span style="style">text</span><img src="imgurl" alt=""/></a>'
]