ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...

    Function htmlToAscii

    • Converts HTML to ASCII.

      Parameters

      • html: string

        The HTML string to convert

      Returns string

      The ASCII string

      htmlToAscii("<p>Hello <b>world</b></p><p>This is a test</p>")
      // Returns "Hello world\nThis is a test"
      export function htmlToAscii(html: string): string {
      return html
      .replace(/<\/p>/gi, "\n")
      .replace(/<br\s*\/?>/gi, "\n")
      .replace(/<[^>]+>/g, "")
      .replace(/&amp;/g, "&")
      .replace(/&lt;/g, "<")
      .replace(/&gt;/g, ">")
      .replace(/&nbsp;/g, " ")
      .replace(/&quot;/g, '"')
      .replace(/&#39;/g, "'")
      .trim();
      }