Skip to content

Commit

Permalink
Fix formatting for multiline examples (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilKes authored Mar 15, 2024
1 parent c88bb6e commit b4bf6a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
"<pre>${option.example.replace("<", "\\<")}</pre>".replace("\n", "<br />")
} else {
"`${option.example}`"
}
} else {
""
}
writeln(
"""
| `${option.type}` | ${option.name} | $description | $example |
Expand Down

0 comments on commit b4bf6a8

Please sign in to comment.