Given a HTML string, such as:
const htmlString = "
<h1 style='background-color: red'>Homepage</h1>
<h2>Welcome back!</h2>
"
How would one go about converting this into a list of words (including html tags), for example:
const output = ["<h1 style='background-color: red'>", "Homepage", "</h1>", "<h2>", "Welcome", "back", "!", "</h2>"]
I’ve tried regex, but run into issues when there are html-like elements within the plain text.