@@ -81,16 +81,13 @@ def is_optional_end(self, tagname, next):
81
81
# An html element's end tag may be omitted if the html element
82
82
# is not immediately followed by a space character or a comment.
83
83
return type not in ("Comment" , "SpaceCharacters" )
84
- elif tagname in ('li' , 'optgroup' , 'option' , ' tr' ):
84
+ elif tagname in ('li' , 'optgroup' , 'tr' ):
85
85
# A li element's end tag may be omitted if the li element is
86
86
# immediately followed by another li element or if there is
87
87
# no more content in the parent element.
88
88
# An optgroup element's end tag may be omitted if the optgroup
89
89
# element is immediately followed by another optgroup element,
90
90
# or if there is no more content in the parent element.
91
- # An option element's end tag may be omitted if the option
92
- # element is immediately followed by another option element,
93
- # or if there is no more content in the parent element.
94
91
# A tr element's end tag may be omitted if the tr element is
95
92
# immediately followed by another tr element, or if there is
96
93
# no more content in the parent element.
@@ -125,6 +122,16 @@ def is_optional_end(self, tagname, next):
125
122
'p' , 'pre' , 'section' , 'table' , 'ul' )
126
123
else :
127
124
return type == "EndTag" or type is None
125
+ elif tagname == 'option' :
126
+ # An option element's end tag may be omitted if the option
127
+ # element is immediately followed by another option element,
128
+ # or if it is immediately followed by an <code>optgroup</code>
129
+ # element, or if there is no more content in the parent
130
+ # element.
131
+ if type == "StartTag" :
132
+ return next ["name" ] in ('option' , 'optgroup' )
133
+ else :
134
+ return type == "EndTag" or type is None
128
135
elif tagname in ('rt' , 'rp' ):
129
136
# An rt element's end tag may be omitted if the rt element is
130
137
# immediately followed by an rt or rp element, or if there is
0 commit comments