def parse_front_matter()

in scripts/nb_to_md.py [0:0]


  def parse_front_matter(self) -> Tuple[str, str, int]:
    """Parses Front Matter values from Markdown
    
      Returns
        A tuple containing the title, description, and weight.
    """
    
    # default values
    title = None
    description = None
    weight = DEFAULT_WEIGHT
    
    if self.exists():
      content = Path(self.file_path).read_text()

      # find the front matter section
      regexp = re.compile('\++\n(.*?)\++\n', re.S)
      m = regexp.match(content)
      front_matter_content =  m.group(1)

      # load the TOML
      front_matter = toml.loads(front_matter_content)

      if 'title' in front_matter:
        title = front_matter['title']

      if 'description' in front_matter:
        description = front_matter['description']

      if 'weight' in front_matter:
        weight = front_matter['weight']
    
    return title, description, weight