fun String.trimMargin(marginPrefix: String = "|"): String(source)
Trims leading whitespace characters followed by marginPrefix from every line of a source string and removes first and last lines if they are blank (notice difference blank vs empty).
Doesn't affect line if it doesn't contain marginPrefix except first and last blank lines.
Doesn't preserve original line endings.
assertEquals("ABC\n123\n456", """ABC |123 |456""".trimMargin())
Return deindented String