snippet. Return true if it is well formed under the rules below, and false otherwise.
- A **tag name** is 1 to 9 uppercase Latin letters.
- An **opening tag** is <NAME> and a **closing tag** is </NAME>. Every < (except one that starts a raw block) begins a tag, and everything up to the next > is taken as its name (after the / for a closing tag). If there is no > or the name is not allowed, the snippet is malformed.
- An **element** is an opening tag, its content and a closing tag with the same name. The content may hold any text, other elements and raw blocks; tags must be properly nested.
- A **raw block** starts with <![CDATA[ and ends at the first ]]> after it. Everything inside is plain text, even if it looks like tags. A block with no ]]> makes the snippet malformed.
- The whole snippet must be **exactly one element**: no text, blocks or other elements before or after it.
A > outside of tags is plain text.snippet='<NOTE>buy milk <B>today</B></NOTE>' → True
The outer NOTE tag is closed, and inside it there is text and a properly nested B tag.
snippet='<P><![CDATA[<a> is not a tag]]></P>' → True
Everything between <![CDATA[ and ]]> is plain text, so <a> with its invalid name breaks nothing.
snippet='<A><B></A></B>' → False
The tags overlap: A is closed before the B nested inside it.
snippet consists of Latin letters, digits, spaces and the characters <, >, /, !, [, ], .snippet='<NOTE>buy milk <B>today</B></NOTE>'
True
Run checks the first 3 tests in your browser. Submit checks all 218 tests on the server, hidden ones included.