From b4bf6a8c1cc37bdf1cc2959187b3aa86ff493fcd Mon Sep 17 00:00:00 2001 From: Phil <39240633+PhilKes@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:14:59 +0100 Subject: [PATCH] Fix formatting for multiline examples (#106) --- .../kotlin/org/openrewrite/RecipeMarkdownGenerator.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt b/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt index 14d8ed0..dd38b4d 100644 --- a/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt +++ b/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt @@ -840,7 +840,16 @@ class RecipeMarkdownGenerator : Runnable { if (option.valid?.isNotEmpty()?: false) { description += " Valid options: " + option.valid?.joinToString { "`$it`" } } - val example = if (option.example != null) "`${option.example}`" else "" + // Preserve table cell formatting for multiline examples + val example = if (option.example != null) { + if (option.example.contains("\n")) { + "
${option.example.replace("<", "\\<")}
".replace("\n", "
") + } else { + "`${option.example}`" + } + } else { + "" + } writeln( """ | `${option.type}` | ${option.name} | $description | $example |