code: public final void transformImagesToFigures(final Element root) {
          final Collection<Element> images; // Image elements from the <body>
          Element figure;     // <figure> element
          Element caption;    // <figcaption> element
  
          checkNotNull(root, "Received a null pointer as root element");
  
          images = root.select("section img");
          if (!images.isEmpty()) {
              for (final Element img : images) {
                  figure = new Element(Tag.valueOf("figure"), "");
  
                  img.replaceWith(figure);
                  figure.appendChild(img);
  
                  if (img.hasAttr("alt")) {
                      caption = new Element(Tag.valueOf("figcaption"), "");
                      caption.text(img.attr("alt"));
                      figure.appendChild(caption);
                  }
              }
          }
      }
docs: Transforms simple {@code <img>} elements to {@code <figure>} elements.
  <p>
  This will wrap {@code <img>} elements with a {@code <figure>} element,
  and add a {@code <figcaption>} with the contents of the image's
  {@code alt} attribute, if said attribute exists.
  <p>
  Only {@code <img>} elements inside a {@code <section>} will be
  transformed.
  
  @param root
  root element with images to transform