Moves anchor name to heading id, if one does not exist. Removes the anchor.

@param heading
@param anchor
965878
private static void anchorToId(Element heading, Element anchor) {
		
		if ("a".equals(anchor.tagName()) && heading.id().isEmpty()) {
			String aName = anchor.attr("name");
			if (!aName.isEmpty()) {
				// set the anchor name as heading ID
				heading.attr("id", aName);
				
				// remove the anchor
				anchor.remove();
			}
		}
	}
399927
void setAnchor(int page, Map.Entry anchor) {
        SimpleImmutableEntry anchorEntry = new SimpleImmutableEntry(page, anchor);
        int anchorCount = anchorList.size();
        if (page < anchorCount) {
            anchorList.set(page, anchorEntry);
        } else if (page == anchorCount) {
            anchorList.add(anchorEntry);
        } else {
            throw new IllegalArgumentException("Anchor index is not correct, expected: " + page + " found: " + anchorCount);
        }
    }
384670
function (anchor) {
            var keys = anchor.split(" ");
            if (keys.length > 2) {
                return false;
            }

            for (var i = 0, l = keys.length; i < l; i++) {
                var key = keys[i];
                if (!ariaUtilsArray.contains(this.ANCHOR_KEYS, key)) {
                    return false;
                }
            }

            return true;
        }
101099
private static int headingIndex(Element element) {
    String tagName = element.tagName();
    if (tagName.startsWith("h")) {
      try {
        return Integer.parseInt(tagName.substring(1));
      }
      catch (Throwable ex) {
        throw new IllegalArgumentException("Must be a header tag: " + tagName, ex);
      }
    }
    else {
      throw new IllegalArgumentException("Must be a header tag: " + tagName);
    }
  }
491371
public function removeFromHead($elementName)
    {
        foreach ($this->_head as $position => $element) {
            if ($element->getName() !== $elementName) {
                continue;
            }

            $this->removeFromHeadByPosition($position);
        }
    }
1027530
function mklink (anchor, name) {
    var id = mkid(name);
    if (anchor) {
        if (!defined[id]) {
            defined[id] = true;
            return "<a name=\"" + id + "\">" + name + "</a>";
        }
        else
            return name;
    }
    else
        return "<a href=\"#" + id + "\">" + name + "</a>";
}
607214
function hasIdInTitle(id) {
            const docText = cat(docFilename);
            const idOldAtEndOfTitleRegExp = new RegExp(`^# (.*?) \\(${id}\\)`, "u"); // original format
            const idNewAtBeginningOfTitleRegExp = new RegExp(`^# ${id}: `, "u"); // new format is same as rules index
            /*
             * 1. Added support for new format.
             * 2. Will remove support for old format after all docs files have new format.
             * 3. Will remove this check when the main heading is automatically generated from rule metadata.
             */

            return idNewAtBeginningOfTitleRegExp.test(docText) || idOldAtEndOfTitleRegExp.test(docText);
        }
906840
void resetHead(long index) {
    for (SegmentedJournalReader reader : readers) {
      if (reader.getNextIndex() < index) {
        reader.reset(index);
      }
    }
  }
416093
function () {
          if (selection.isCollapsed()) {
            var elm = editor.dom.getParent(editor.selection.getStart(), 'a');
            if (elm) {
              editor.dom.remove(elm, true);
            }

            return;
          }

          formatter.remove("link");
        }
990258
public void setTitle(final String title) {
        if (this.title == null) {
            this.title = new Content();
        }
        this.title.setValue(title);
    }
901741
public void setHeader(String name, String value) {
//		int pos = 0;
//		int crlfpos = 0;
        Pattern pattern = null;

        if (getHeaders(name) == null && value != null) {
            // header value not found, append to end
            addHeader(name, value);
        } else {
            pattern = getHeaderRegex(name);
            Matcher matcher = pattern.matcher(mMsgHeader);
            if (value == null) {
                // delete header
                mMsgHeader = matcher.replaceAll("");
            } else {
                // replace header
                String newString = name + ": " + value + mLineDelimiter;
                mMsgHeader = matcher.replaceAll(Matcher.quoteReplacement(newString));
            }

            // set into hashtable
            replaceInternalHeaderFields(name, value);
        }
    }
760284
public function set_anchor($anchor) {
        if (is_null($anchor)) {
            // Remove.
            $this->anchor = null;
        } else if ($anchor === '') {
            // Special case, used as empty link.
            $this->anchor = '';
        } else if (preg_match('|[a-zA-Z\_\:][a-zA-Z0-9\_\-\.\:]*|', $anchor)) {
            // Match the anchor against the NMTOKEN spec.
            $this->anchor = $anchor;
        } else {
            // Bad luck, no valid anchor found.
            $this->anchor = null;
        }
    }
556564
public void setHeader(String name, String value) {
		if (headers == null) {
			headers = new HashMap<String, String>();
		}
		if (value != null) {
			headers.put(name, value);
		} else {
			headers.remove(name);
		}
	}
259073
protected void removeDestination(DestinationHandler dh)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "removeDestination", dh);

        if (dh.isLink())
        {
            if (linkIndex.containsKey(dh))
            {
                linkIndex.remove(dh);
            }
        }
        else
        {
            if (destinationIndex.containsKey(dh))
            {
                destinationIndex.remove(dh);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "removeDestination");
    }
212791
public void addHeader(String name, String value) {
        headers.add(name, value);
        List<String> list = caseSensitiveHeaders.get(name);
        if (list == null) {
            list = new ArrayList<String>();
            caseSensitiveHeaders.put(name, list);
        }
        list.add(value);
    }
916199
private void onMainHit(Node node) {
    node.remove();
    sizeMainQ[node.level]--;
    if (node.level < (levels - 1)) {
      node.level++;
    }

    Node head = headMainQ[node.level];
    node.appendToTail(head);
    sizeMainQ[node.level]++;

    adjust();
  }
591233
function selectHeadings (contentSelector, headingSelector) {
    var selectors = headingSelector
    if (options.ignoreSelector) {
      selectors = headingSelector.split(',')
        .map(function mapSelectors (selector) {
          return selector.trim() + ':not(' + options.ignoreSelector + ')'
        })
    }
    try {
      return document.querySelector(contentSelector)
        .querySelectorAll(selectors)
    } catch (e) {
      console.warn('Element not found: ' + contentSelector); // eslint-disable-line
      return null
    }
  }