private static @NotNull String makeImageUrlsAbsolute(@NotNull String html, @NotNull String basePath) {
    Document document = Jsoup.parse(html);
    Elements elements = document.getElementsByTag("img");

    for (Element element : elements) {
      URI uri = null;
      try {
        uri = (new URL(element.attr("src"))).toURI();
        if (!uri.getScheme().equals("file")) continue;
      }
      catch (MalformedURLException | URISyntaxException e) {
        // Assume the scheme is 'file'.
      }

      Path originalPath = Paths.get((uri != null ? uri.getPath() : element.attr("src")));
      if (originalPath.isAbsolute()) continue;

      element.attr("src", Paths.get(basePath, originalPath.toString()).toString());
    }

    return document.outerHtml();
  }
private static @NotNull String makeImageUrlsAbsolute(@NotNull String html, @NotNull String basePath)