code: def get_caption_comments(content):
      
  
      if not content.startswith('## fig:'):
          return None, None
  
      content = content.splitlines()
  
      id = content[0].strip('## ')
  
      caption = []
      for line in content[1:]:
          if not line.startswith('# ') or line.startswith('##'):
              break
          else:
              caption.append(line.lstrip('# ').rstrip())
  
      # add " around the caption. TODO: consider doing this upstream
      # in pandoc-attributes
      caption = '"' + ' '.join(caption) + '"'
      return id, caption
docs: Retrieve an id and a caption from a code cell.
  
      If the code cell content begins with a commented
      block that looks like
  
      ## fig:id
      # multi-line or single-line
      # caption
  
      then the 'fig:id' and the caption will be returned.
      The '#' are stripped.