Parse a JSX-like markup string into an object with error checks
For context, see how React describes writing markup with JSX. Build a JSX-like compiler that transforms a given string representing HTML code into a JavaScript object representation. The compiler should parse the HTML-like string and extract the tag name, attributes (if any), and children content. Consider the following input string:
<a>frontendlead.com</a>
The expected output for the above input should be:
{
"openingElement": {
"name": "a"
},
"closingElement": {
"name": "a"
},
"props": {
"children": [
"frontendlead.com"
]
}
}
The compiler must handle various cases, including strings with extra spaces, and ensure proper tag formatting. For instance, the following examples should be successfully parsed:
<a>bfe.dev</a>< a > bfe.dev < / a >However, certain inputs should trigger parsing errors, such as:
'2a>bfe.dev</a>' or '<a></b>''<a>></a>', '<a><a>'This challenge aims to assess your ability to parse and transform string data, manage errors, and construct object representations, which are essential skills in front-end development and working with virtual DOM concepts.