This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Detect unsafe (and potentially unsafe) unbalanced tags in a given HTML snippet. | |
* Hints taken from an html parse (https://gist.github.com/cburgmer/2877758). | |
* | |
* Example: | |
* An unclosed div tag is considered unsafe, because if the snippet is pasted in between two div tags | |
* then it could end up breaking the HTML document. | |
* Self closing tags (tags that you can intentioanlly leave open like <table><tr><td>some text</table>) are also considered unsafe, for the same reason. | |
* However an unclosed void tag (like meta tag) is safe, because browsers will ignore it without any side effects. | |
* |