Commit f68c7a75 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish "Escape reserved asciidoc character in generated documentation"

See gh-17663
parent b0fa58e8
...@@ -76,7 +76,8 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry { ...@@ -76,7 +76,8 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry {
builder.append("|"); builder.append("|");
} }
else { else {
builder.append("|+++", this.description.replace("|", "\\|"), "+++"); String cleanedDescription = this.description.replace("|", "\\|");
builder.append("|+++", cleanedDescription, "+++");
} }
} }
......
...@@ -90,13 +90,12 @@ class SingleConfigurationTableEntryTests { ...@@ -90,13 +90,12 @@ class SingleConfigurationTableEntryTests {
void descriptionWithPipe() { void descriptionWithPipe() {
ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();
property.setId("spring.test.prop"); property.setId("spring.test.prop");
property.setDefaultValue("first\\second");
property.setDescription("This is a description with a | pipe."); property.setDescription("This is a description with a | pipe.");
property.setType("java.lang.String"); property.setType("java.lang.String");
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property); SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
AsciidocBuilder builder = new AsciidocBuilder(); AsciidocBuilder builder = new AsciidocBuilder();
entry.write(builder); entry.write(builder);
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first\\\\second+`" + NEWLINE assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|" + NEWLINE
+ "|+++This is a description with a \\| pipe.+++" + NEWLINE); + "|+++This is a description with a \\| pipe.+++" + NEWLINE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment