code: public String getPlainTextContext(int fromPos, int toPos, String contents) {
      String text = contents.replace('\n', ' ').replace('\r', ' ').replace('\t', ' ');
      // calculate context region:
      int startContent = fromPos - contextSize;
      String prefix = "...";
      String postfix = "...";
      String markerPrefix = "   ";
      if (startContent < 0) {
        prefix = "";
        markerPrefix = "";
        startContent = 0;
      }
      int endContent = toPos + contextSize;
      if (endContent > text.length()) {
        postfix = "";
        endContent = text.length();
      }
      StringBuilder marker = getMarker(fromPos, toPos, text.length() + prefix.length());
      // now build context string plus marker:
      return prefix + text.substring(startContent, endContent) + postfix + '\n' + markerPrefix + marker.substring(startContent, endContent);
    }
docs: Get a plain text context that uses {@code ^} characters in a new line as a marker of the
  given string region. Ignores {@link #setEscapeHtml(boolean)}.
  @since 2.3