Function convertHTMLToBasicHTML

  • Strip HTML to ~30 basic markup HTML tags, lists, tables, images. Convert anchors and relative urls to absolute urls. Basic HTML supports the same elements as Markdown, which is used in writing plain text. Markdown is converted to HTML anyways to display it, and it is better to edit basic HTML in a rich text editor.

    Mozilla DOM Reference
    Source Code of Browser HTML DOM
    RegExp JS V8 Code

    Parameters

    • html: string

      Any page's HTML to process

    • Optionaloptions: {
          images: boolean;
          links: boolean;
          videos: boolean;
          formatting: boolean;
          url: string;
          allowTags: string;
          allowedAttributes: string;
      } = {}
      • images: boolean

        default=true - Whether to include images

      • links: boolean

        default=true - Whether to include links

      • videos: boolean

        default=true - Whether to include videos or not

      • formatting: boolean

        default=true - Whether to include formatting

      • url: string

        base URL for converting relative URLs to absolute

      • allowTags: string

        default="br,p,u,b,i ,em,strong,h1,h2,h3,h4, h5,h6,blockquote, code,ul,ol,li,dd,dl, table,th,tr,td,sub,sup" - Comma-separated list of allowed HTML tags.

      • allowedAttributes: string

        default="text,tag,href, src,type,width, height,id,data" List of allowed HTML attributes

    Returns string

    basic text formatting html