code: def process_document_into_sections(markdown_text):
      sections = []
      buffer = ""
      first_section = True
      for line in markdown_text.split("\n"):
          if line.startswith("#"):
              match = re.search(r"^(\#*)\s+(.*)$", line)
              heading = ""
              if match:
                  heading = match[1]
              if heading == "#":
                  if first_section is True:
                      # Ignore the first detection of `#`.
                      first_section = False
                  else:
                      # When a new `#` is detected, store the text in `buffer` into
                      # an array entry and clear the buffer for the next section.
                      sections.append(buffer)
                      buffer = ""
          buffer += line + "\n"
      # Add the last section on the page.
      sections.append(buffer)
      return sections
  
file_path: generative-ai-docs/demos/palm/python/docs-agent/scripts/markdown_to_plain_text.py
imports: from markdown import markdown
  from bs4 import BeautifulSoup
  import os
  import re
  import json
  import frontmatter
  import read_config
  import uuid
label_desc: Use image node_id 6 for calling a global function with example usage: process_document_into_sections(markdown_text) and returns: sections