private static @NotNull @NlsSafe String replaceHashes(@NotNull @NlsSafe String s, @NotNull Set<@NlsSafe String> resolvedHashes) {
    Matcher matcher = HASH_PATTERN.matcher(s);
    StringBuilder result = new StringBuilder();

    while (matcher.find()) {
      //noinspection HardCodedStringLiteral
      String hash = matcher.group();

      if (resolvedHashes.contains(hash)) {
        hash = HtmlChunk.link(GO_TO_HASH + hash, hash).toString();
      }
      matcher.appendReplacement(result, hash);
    }
    matcher.appendTail(result);

    return result.toString();
  }
private static @NotNull @NlsSafe String replaceHashes(@NotNull @NlsSafe String s, @NotNull Set<@NlsSafe String> resolvedHashes)