code: public final void fixHeadingIds(final Element root) {
          final Collection<Element> headings; // Headings to fix
          String idText;      // Text to generate the id
  
          checkNotNull(root, "Received a null pointer as root element");
  
          // Table rows with <th> tags in a <tbody>
          headings = root.select("h1,h2,h3,h4,h5,h6");
          for (final Element heading : headings) {
              if (heading.hasAttr("id")) {
                  // Contains an id
                  // The id text is taken from the attribute
                  idText = heading.attr("id");
              } else {
                  // Doesn't contain an id
                  // The id text is taken from the heading text
                  idText = heading.text();
              }
              heading.attr("id",
                      idText.toLowerCase().replaceAll(ID_INVALID_REGEX, ""));
          }
      }
docs: Adds or fixes heading ids.
  <p>
  If a heading has an id it will be corrected if needed, otherwise it will
  be created from the heading text.
  <p>
  The following operations are applied during this process:
  <ul>
  <li>Text will be set to lower case</li>
  <li>Underscores will be removed</li>
  <li>Points will be removed</li>
  <li>Empty spaces will be removed</li>
  </ul>
  <p>
  With this headings will end looking like
  {@code <h1 id=\"aheading\">A heading</h1>}.
  
  @param root
  root element with headings where an id should be added