code: def markdown_to_text(markdown_string):
      """Converts a markdown string to plaintext"""
  
      # md -> html -> text since BeautifulSoup can extract text cleanly
      html = markdown(markdown_string)
  
      # remove code snippets
      html = re.sub(r"<pre>(.*?)</pre>", " ", html)
      html = re.sub(r"<code>(.*?)</code >", " ", html)
  
      # extract text
      soup = BeautifulSoup(html, "html.parser")
      text = "".join(soup.findAll(text=True))
  
      return text
  
file_path: doc-parsr/server/src/processing/MlHeadingDetectionModule/train_model/utils.py
imports: from collections import Counter
  from bs4 import BeautifulSoup
  from markdown import markdown
  import re
label_desc: Use image node_id 5 for calling a global function with example usage: markdown_to_text(markdown_string) and returns: text