fun escapeKDoc()

in core/src/main/java/com/facebook/ktfmt/kdoc/Escaping.kt [32:45]


  fun escapeKDoc(s: String): String {
    val startMarkerIndex = s.indexOf("/*")
    val endMarkerIndex = s.lastIndexOf("*/")

    if (startMarkerIndex == -1 || endMarkerIndex == -1) {
      throw RuntimeException("KDoc with no /** and/or */")
    }

    return s.substring(0, startMarkerIndex + 3) +
        s.substring(startMarkerIndex + 3, endMarkerIndex)
            .replace("/*", SLASH_STAR_ESCAPE)
            .replace("*/", STAR_SLASH_ESCAPE) +
        s.substring(endMarkerIndex)
  }