Question: In Code Fragment 6.5 (in the textbook, also copied below), we assume that opening tags in HTML have form , a with . More generally,

 In Code Fragment 6.5 (in the textbook, also copied below), we

In Code Fragment 6.5 (in the textbook, also copied below), we assume that opening tags in HTML have form , a with

  • . More generally, HTML allows optional attributes to be expressed as part of an opening tag. The general form used is ; for example, a table can be given a border and additional padding by using an opening tag of . Modify Code Fragment 6.5 so that it can properly match tags, even when an opening tag may include one or more such attributes. def is matched html (raw): """Return True if all HTML tags are properly match; False otherwise." S = ArrayStack() j = raw.find('', j+1) # find next '>' character if k == -1: return false # invalid tag tag = raw [j+1:k] # strip away if not tag.startswith('/'): # this is opening tag S.push (tag) else: # this is closing tag if s.is empty(): return false # nothing to match with if tag [1:] != S.pop(): return False # mismatched delimiter j = raw.find(', a with
  • . More generally, HTML allows optional attributes to be expressed as part of an opening tag. The general form used is ; for example, a table can be given a border and additional padding by using an opening tag of
  • . Modify Code Fragment 6.5 so that it can properly match tags, even when an opening tag may include one or more such attributes. def is matched html (raw): """Return True if all HTML tags are properly match; False otherwise." S = ArrayStack() j = raw.find('', j+1) # find next '>' character if k == -1: return false # invalid tag tag = raw [j+1:k] # strip away if not tag.startswith('/'): # this is opening tag S.push (tag) else: # this is closing tag if s.is empty(): return false # nothing to match with if tag [1:] != S.pop(): return False # mismatched delimiter j = raw.find('
  • Step by Step Solution

    There are 3 Steps involved in it

    1 Expert Approved Answer
    Step: 1 Unlock blur-text-image
    Question Has Been Solved by an Expert!

    Get step-by-step solutions from verified subject matter experts

    Step: 2 Unlock
    Step: 3 Unlock

    Students Have Also Explored These Related Databases Questions!