def remove_element(text, element):
  """Removes double square bracket elements from the text.

  This gets rid of things that otherwise look like entities, e.g.:
    remove_element(text, 'File')
  removes all of the '[[File:...]]'s from the text.

  Args:
    text: The text to process.
    element: A string containing the type of element to remove, e.g., File,
      Image, etc.

  Returns:
    A string containing the processed text.
  """
  while f"[[{element}" in text:
    start = text.find(f"[[{element}")
    num_brackets = 0
    i = 0
    for char in text[start:]:
      if char == "[":
        num_brackets += 1
      elif char == "]":
        num_brackets -= 1
      if num_brackets == 0:
        break
      i += 1
    end = start + i + 1
    text = text[:start] + text[end:]
  return text
Removes double square bracket elements from the text.

  This gets rid of things that otherwise look like entities, e.g.:
    remove_element(text, 'File')
  removes all of the '[[File:...]]'s from the text.

  Args:
    text: The text to process.
    element: A string containing the type of element to remove, e.g., File,
      Image, etc.

  Returns:
    A string containing the processed text.
  
language/fruit/wiki_utils.py