code: def generate_slides(self, infile):
          
  
          state = 0
  
          # each slide is a dict
          slide = {}
  
          last_heading = 0
  
          for item in self.generate_lines(infile):
  
              line = item['line']
              heading = item['heading']
              indent = item['indent']
  
              # Any heading is the heading for a new slide
              if heading:
  
                  if slide and last_heading <= 1:
                      yield slide
  
                  last_heading = heading
                      
                  rows = []
                  slide = {}
                  if heading < 2:
                      slide.update(dict(
                          heading = dict(text=line.strip('#')),
                          rows = rows))
  
                  continue
  
              # Any block with more than one hash is a comment
              if last_heading > 1:
                  continue
  
              if indent == 0 and line:
                  # at a potential image
                  rows.append(self.build_row(line))
  
              else:
                  # Just add the line of text
                  items = [dict(text=(' ' * indent) + line)]
                  rows.append(dict(items=items))
  
          if slide:
              yield slide
docs: Process a file of rest and yield dictionaries