openrewrite / rewrite-recipe-markdown-generator

Utility that generates OpenRewrite recipe documentation in markdown format for all recipes on the classpath.
Apache License 2.0
2 stars 7 forks source link

Fix formatting for multiline examples #106

Closed PhilKes closed 6 months ago

PhilKes commented 6 months ago

What's changed?

Using <pre> for multiline examples + escaping tags inside the example value (e.g. for XML examples).

With the proposed changes it looks like this (createxmlfile.md): image Note: There is a \n missing in CreateXmlFile.java

What's your motivation?

For option examples that are multiline the table cell formatting is broken, see mergeyaml.md, createxmlfile.md, createyamlfile.md E.g. createxmlfile.md: image

This is due to the replacement of \n with an actual line break, which does not render properly when using "`" inside a table:


| Type | Name | Description | Example |
| -- | -- | -- | -- |
| `String` | relativeFileName | File path of new file. | `foo/bar/baz.xml` |
                        | `String` | fileContents | *Optional*. Multiline text content for the file. | `<?xml version="1.0" encoding="UTF-8"?>
<root>
    <child>1</child></root>` |
| `Boolean` | overwriteExisting | *Optional*. If there is an existing file, should it be overwritten. |  |

Anything in particular you'd like reviewers to focus on?

-

Anyone you would like to review specifically?

-

Have you considered any alternatives or workarounds?

No

Any additional context

-

Checklist

timtebeek commented 6 months ago

Awesome; great to see you've worked out this fix so quickly!