You ask what was in the author’s mind, noting that he gives names like Beautiful [Stone] Soup for classes / modules :-)
Here are two more BeautifulStoneSoup behavior examples:
>>> soup = BeautifulSoup.BeautifulStoneSoup( """<alan x="y" ><anne>hello</anne>""" ) >>> print soup.prettify() <alan x="y"> <anne> hello </anne> </alan> >>> soup = BeautifulSoup.BeautifulStoneSoup( """<alan x="y" ><anne>hello</anne>""", selfClosingTags=['alan']) >>> print soup.prettify() <alan x="y" /> <anne> hello </anne> >>>
My answer is: a self-closing tag is not legal if it is not defined for the parser. Thus, the author had options when deciding how to process the illegal fragment, for example, <alan x="y" /> ... (1), suppose that the error / was an error (2) to consider alan as a self-closing tag completely regardless of how it can be used elsewhere at the entrance (3) to make 2 passes over the input fins in the first pass, as each tag was used. Which choice do you prefer?
John machin
source share