code: def strip_magics(source):
      
      filtered=[]
      for line in source.splitlines():
          if not line.startswith('%') or line.startswith('%%'):
              filtered.append(line)
      return '\n'.join(filtered)
docs: Given the source of a cell, filter out all cell and line magics.