code: private List<Content> rewriteAnchor(Element element) {
  
      // detect empty anchor elements and insert at least an empty string to avoid "self-closing" elements
      // that are not handled correctly by most browsers
      if (element.getContent().isEmpty()) {
        element.setText("");
      }
  
      // resolve link metadata from DOM element
      Link link = getAnchorLink(element);
  
      // build anchor for link metadata
      Element anchorElement = buildAnchorElement(link, element);
  
      // Replace anchor tag or remove anchor tag if invalid - add any sub-content in every case
      List<Content> content = new ArrayList<Content>();
      if (anchorElement != null) {
        anchorElement.addContent(element.cloneContent());
        content.add(anchorElement);
      }
      else {
        content.addAll(element.getContent());
      }
      return content;
    }
docs: Checks if the given anchor element has to be rewritten.
  @param element Element to check
  @return null if nothing is to do with this element.
  Return empty list to remove this element.
  Return list with other content to replace element with new content.