code: def process_markdown_files_from_source(
      configs, inputpath, counter, excludepath
  ):
      f_count = 0
      for root, dirs, files in os.walk(resolve_path(inputpath)):
          if IS_CONFIG_FILE:
              if "exclude_path" in configs[counter]:
                  dirs[:] = [d for d in dirs if d not in excludepath]
              if "url_prefix" in configs[counter]:
                  namespace_uuid = uuid.uuid3(
                      uuid.NAMESPACE_DNS, configs[counter]["url_prefix"]
                  )
          for file in files:
              f_count += 1
              # Process only Markdown files
              if file.endswith(".md"):
                  with open(
                      os.path.join(root, file), "r", encoding="utf-8"
                  ) as auto:
                      # Construct a new sub-directory for storing output plain text files
                      new_path = MY_OUTPUT_PATH + re.sub(
                          resolve_path(inputpath),
                          "",
                          os.path.join(root, ""),
                      )
                      is_exist = os.path.exists(new_path)
                      if not is_exist:
                          os.makedirs(new_path)
                      # Grab the filename without the .md extension
                      new_filename = os.path.join(new_path, file)
                      # Add filename to a list
                      file_slash = "/" + file
                      relative_path = os.path.relpath(
                          root + file_slash, inputpath
                      )
                      file_index.append(relative_path)
                      match = re.search(r"(.*)\.md$", new_filename)
                      new_filename_no_ext = match[1]
                      # Read the input Markdown content
                      to_file = auto.read()
                      # Reformat the page and section titles
                      (
                          to_file,
                          metadata,
                      ) = process_page_and_section_titles(to_file)
                      # Process includes lines in Markdown
                      to_file = process_includes(to_file, root)
                      doc = []
                      if USE_CUSTOM_MARKDOWN_SPLITTER is True:
                          # Use a custom splitter to split into small chunks
                          docs = process_document_into_sections(to_file)
                      else:
                          # Use the Markdown splitter to split into small chunks
                          docs = markdown_splitter.create_documents(
                              [to_file]
                          )
                      i = 0
                      for doc in docs:
                          # Clean up Makrdown and HTML syntax
                          if USE_CUSTOM_MARKDOWN_SPLITTER is True:
                              content = markdown_to_text(doc)
                          else:
                              content = markdown_to_text(
                                  doc.page_content
                              )
                          # Save clean plain text to a new filename appended with an index
                          filename_to_save = (
                              new_filename_no_ext + "_" + str(i) + ".md"
                          )
                          # Generate UUID for each plain text chunk and collect its metadata,
                          # which will be written to the top-level `file_index.json` file.
                          md_hash = uuid.uuid3(namespace_uuid, content)
                          uuid_file = uuid.uuid3(
                              namespace_uuid, filename_to_save
                          )
                          if bool(metadata):
                              full_file_metadata[filename_to_save] = {
                                  "UUID": str(uuid_file),
                                  "source": input_path,
                                  "source_file": relative_path,
                                  "source_id": counter,
                                  "URL": url_pre,
                                  "md_hash": str(md_hash),
                                  "metadata": metadata,
                              }
                          else:
                              full_file_metadata[filename_to_save] = {
                                  "UUID": str(uuid_file),
                                  "source": input_path,
                                  "source_file": relative_path,
                                  "source_id": counter,
                                  "URL": url_pre,
                                  "md_hash": str(md_hash),
                              }
                          with open(
                              filename_to_save, "w", encoding="utf-8"
                          ) as new_file:
                              new_file.write(content)
                              new_file.close()
                          i = i + 1
                      auto.close()
      print(
          "Processed "
          + str(f_count)
          + " Markdown files from the source: "
          + inputpath
      )
      return f_count
  
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 7 for calling a global function with example usage: process_markdown_files_from_source(configs, inputpath, counter, excludepath) and returns: f_count