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

    Function createDOM

    • Converts an HTML string to a DOM Document object.

      Parameters

      • html: string

        The HTML string to convert

      Returns Document

      A DOM Document object

      const doc = createDOM("<html><body><h1>Hello, world!</h1></body></html>");
      // Returns: Document object
      export function createDOM(html: string): Document {
      const parser = new DOMParser();
      const doc = parser.parseFromString(html, "text/html");
      if (!doc) {
      throw new Error("Failed to parse HTML");
      }
      return doc;
      }