parameters: (self, tag, attrs)
docstring: Encountered the beginning of a tag
docstring_summary: Encountered the beginning of a tag
docstring_tokens: Encountered the beginning of a tag
function: def handle_starttag(self, tag, attrs):
          """Encountered the beginning of a tag"""
          if self.curr_state == 0:
              if tag == "dt":
                  # waiting for the title
                  # got dt, we go state 0->1
                  self.curr_state = 1
          elif self.curr_state == 2:
              if tag == "dl":
                  # the current node becomes parent
                  for pixbuf_element in self.pixbuf_vector:
                      self.xml_handler.pixbuf_element_to_xml(pixbuf_element, self.nodes_list[-1], self.dom)
                  self.pixbuf_vector = []
                  self.chars_counter = 0
                  # got dl, we go state 2->0 and wait for the child
                  self.curr_state = 0
              elif tag == "dt":
                  # the current node has no more job to do
                  for pixbuf_element in self.pixbuf_vector:
                      self.xml_handler.pixbuf_element_to_xml(pixbuf_element, self.nodes_list[-1], self.dom)
                  self.pixbuf_vector = []
                  self.chars_counter = 0
                  self.nodes_list.pop()
                  # waiting for the title
                  # got dt, we go state 2->1
                  self.curr_state = 1
              elif tag == "b": self.curr_attributes[cons.TAG_WEIGHT] = cons.TAG_PROP_HEAVY
              elif tag == "i": self.curr_attributes[cons.TAG_STYLE] = cons.TAG_PROP_ITALIC
              elif tag == "u": self.curr_attributes[cons.TAG_UNDERLINE] = cons.TAG_PROP_SINGLE
              elif tag == "s": self.curr_attributes[cons.TAG_STRIKETHROUGH] = cons.TAG_PROP_TRUE
              elif tag == "span" and attrs[0][0] == cons.TAG_STYLE:
                  match = re.match("(?<=^)(.+):(.+)(?=$)", attrs[0][1])
                  if match != None:
                      if match.group(1) == "color":
                          self.curr_attributes[cons.TAG_FOREGROUND] = match.group(2).strip()
                          self.latest_span.append(cons.TAG_FOREGROUND)
                      elif match.group(1) == "background-color":
                          self.curr_attributes[cons.TAG_BACKGROUND] = match.group(2).strip()
                          self.latest_span.append(cons.TAG_BACKGROUND)
              elif tag == "a" and len(attrs) > 0:
                  link_url = attrs[0][1]
                  if len(link_url) > 7:
                      self.curr_attributes[cons.TAG_LINK] = get_internal_link_from_http_url(link_url)
              elif tag == "br":
                  # this is a data block composed only by an endline
                  self.rich_text_serialize(cons.CHAR_NEWLINE)
                  self.chars_counter += 1
              elif tag == "li":
                  self.rich_text_serialize(cons.CHAR_NEWLINE+self.dad.chars_listbul[0]+cons.CHAR_SPACE)
                  self.chars_counter += 3
              elif tag in ["img", "v:imagedata"] and len(attrs) > 0:
                  for attribute in attrs:
                      if attribute[0] == "src":
                          if attribute[1][:23] == "data:image/jpeg;base64,":
                              jpeg_data = attribute[1][23:]
                              pixbuf_loader = gtk.gdk.pixbuf_loader_new_with_mime_type("image/jpeg")
                              try: pixbuf_loader.write(base64.b64decode(jpeg_data))
                              except:
                                  try: pixbuf_loader.write(base64.b64decode(jpeg_data + "="))
                                  except: pixbuf_loader.write(base64.b64decode(jpeg_data + "=="))
                              pixbuf_loader.close()
                              pixbuf = pixbuf_loader.get_pixbuf()
                              self.pixbuf_vector.append([self.chars_counter, pixbuf, cons.TAG_PROP_LEFT])
                              self.chars_counter += 1
                          elif attribute[1][:22] == "data:image/png;base64,":
                              png_data = attribute[1][22:]
                              pixbuf_loader = gtk.gdk.pixbuf_loader_new_with_mime_type("image/png")
                              try: pixbuf_loader.write(base64.b64decode(png_data))
                              except:
                                  try: pixbuf_loader.write(base64.b64decode(png_data + "="))
                                  except: pixbuf_loader.write(base64.b64decode(png_data + "=="))
                              pixbuf_loader.close()
                              pixbuf = pixbuf_loader.get_pixbuf()
                              self.pixbuf_vector.append([self.chars_counter, pixbuf, cons.TAG_PROP_LEFT])
                              self.chars_counter += 1
function_tokens: def handle_starttag ( self , tag , attrs ) : if self . curr_state == 0 : if tag == "dt" : # waiting for the title # got dt, we go state 0->1 self . curr_state = 1 elif self . curr_state == 2 : if tag == "dl" : # the current node becomes parent for pixbuf_element in self . pixbuf_vector : self . xml_handler . pixbuf_element_to_xml ( pixbuf_element , self . nodes_list [ - 1 ] , self . dom ) self . pixbuf_vector = [ ] self . chars_counter = 0 # got dl, we go state 2->0 and wait for the child self . curr_state = 0 elif tag == "dt" : # the current node has no more job to do for pixbuf_element in self . pixbuf_vector : self . xml_handler . pixbuf_element_to_xml ( pixbuf_element , self . nodes_list [ - 1 ] , self . dom ) self . pixbuf_vector = [ ] self . chars_counter = 0 self . nodes_list . pop ( ) # waiting for the title # got dt, we go state 2->1 self . curr_state = 1 elif tag == "b" : self . curr_attributes [ cons . TAG_WEIGHT ] = cons . TAG_PROP_HEAVY elif tag == "i" : self . curr_attributes [ cons . TAG_STYLE ] = cons . TAG_PROP_ITALIC elif tag == "u" : self . curr_attributes [ cons . TAG_UNDERLINE ] = cons . TAG_PROP_SINGLE elif tag == "s" : self . curr_attributes [ cons . TAG_STRIKETHROUGH ] = cons . TAG_PROP_TRUE elif tag == "span" and attrs [ 0 ] [ 0 ] == cons . TAG_STYLE : match = re . match ( "(?<=^)(.+):(.+)(?=$)" , attrs [ 0 ] [ 1 ] ) if match != None : if match . group ( 1 ) == "color" : self . curr_attributes [ cons . TAG_FOREGROUND ] = match . group ( 2 ) . strip ( ) self . latest_span . append ( cons . TAG_FOREGROUND ) elif match . group ( 1 ) == "background-color" : self . curr_attributes [ cons . TAG_BACKGROUND ] = match . group ( 2 ) . strip ( ) self . latest_span . append ( cons . TAG_BACKGROUND ) elif tag == "a" and len ( attrs ) > 0 : link_url = attrs [ 0 ] [ 1 ] if len ( link_url ) > 7 : self . curr_attributes [ cons . TAG_LINK ] = get_internal_link_from_http_url ( link_url ) elif tag == "br" : # this is a data block composed only by an endline self . rich_text_serialize ( cons . CHAR_NEWLINE ) self . chars_counter += 1 elif tag == "li" : self . rich_text_serialize ( cons . CHAR_NEWLINE + self . dad . chars_listbul [ 0 ] + cons . CHAR_SPACE ) self . chars_counter += 3 elif tag in [ "img" , "v:imagedata" ] and len ( attrs ) > 0 : for attribute in attrs : if attribute [ 0 ] == "src" : if attribute [ 1 ] [ : 23 ] == "data:image/jpeg;base64," : jpeg_data = attribute [ 1 ] [ 23 : ] pixbuf_loader = gtk . gdk . pixbuf_loader_new_with_mime_type ( "image/jpeg" ) try : pixbuf_loader . write ( base64 . b64decode ( jpeg_data ) ) except : try : pixbuf_loader . write ( base64 . b64decode ( jpeg_data + "=" ) ) except : pixbuf_loader . write ( base64 . b64decode ( jpeg_data + "==" ) ) pixbuf_loader . close ( ) pixbuf = pixbuf_loader . get_pixbuf ( ) self . pixbuf_vector . append ( [ self . chars_counter , pixbuf , cons . TAG_PROP_LEFT ] ) self . chars_counter += 1 elif attribute [ 1 ] [ : 22 ] == "data:image/png;base64," : png_data = attribute [ 1 ] [ 22 : ] pixbuf_loader = gtk . gdk . pixbuf_loader_new_with_mime_type ( "image/png" ) try : pixbuf_loader . write ( base64 . b64decode ( png_data ) ) except : try : pixbuf_loader . write ( base64 . b64decode ( png_data + "=" ) ) except : pixbuf_loader . write ( base64 . b64decode ( png_data + "==" ) ) pixbuf_loader . close ( ) pixbuf = pixbuf_loader . get_pixbuf ( ) self . pixbuf_vector . append ( [ self . chars_counter , pixbuf , cons . TAG_PROP_LEFT ] ) self . chars_counter += 1