String (String @NotNull [] lines) { lines = PsiLiteralUtil.escapeTextBlockCharacters(StringUtil.join(lines), true, true, false).split("(?<=\n)"); int indent = PsiLiteralUtil.getTextBlockIndent(lines, true, true); if (indent != 0 && lines.length > 0 && !lines[lines.length - 1].endsWith("\n")) { // append \ + newline at the end of the last line, so we can use closing """ to indent lines[lines.length - 1] += "\\\n"; } String content = StringUtil.join(lines); if (content.endsWith(" ")) { content = content.substring(0, content.length() - 1) + "\\s"; } return "\"\"\"\n" + content + "\"\"\""; }