private static @NotNull String replaceMacro(@NotNull String text, @NotNull String macroName, @NotNull String replacement) {
    while (true) {
      int start = findMacroIndex(text, macroName);
      if (start < 0) {
        break;
      }

      int end = start + macroName.length() + 2;
      int slashCount = getSlashCount(text, end);
      String actualReplacement = slashCount > 0 && !replacement.endsWith("/") ? replacement + "/" : replacement;
      text = StringUtil.replaceSubstring(text, new TextRange(start, end + slashCount), actualReplacement);
    }
    return text;
  }
private static @NotNull String replaceMacro(@NotNull String text, @NotNull String macroName, @NotNull String replacement)