Strip Hyperlinks

Command: strip-hyperlinks

Description: Remove all hyperlinks from the working text, leaving the link text intact.

Source Code

function stripHyperlinks(working, command, p) {
  
  const parser = new DOMParser();
  const doc = parser.parseFromString(working.text, "text/html");
  doc.querySelectorAll("a").forEach((a) => {
    a.outerHTML = a.innerHTML;
  });

  return doc.body.innerHTML;
}

stripHyperlinks.title = "Strip Hyperlinks";
stripHyperlinks.description = "Remove all hyperlinks from the working text, leaving the link text intact.";
stripHyperlinks.allowedContentTypes = ["html"];

export default stripHyperlinks;
This page is part of the Textflow Command Reference section of this site: