import React from "react";

export const formatString = (content: string) =>
  content
    // @ts-ignore
    .replace(/\r\n\r\n/g, "<br />")
    .replace(/(&nbsp;)$/g, "")
    .replace(/^(&nbsp;)/g, "")
    .trim();

const Text = (
  // @ts-ignore
  { content = "", children } = { content: string, children: React.ReactNode },
) => {
  const formattedString = formatString(content);

  return children(formattedString);
};

export default Text;
