Commit b0fa58e8 authored by vivganes's avatar vivganes Committed by Stephane Nicoll

Escape reserved asciidoc character in generated documentation

See gh-17663
parent d9826759
...@@ -76,7 +76,7 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry { ...@@ -76,7 +76,7 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry {
builder.append("|"); builder.append("|");
} }
else { else {
builder.append("|+++", this.description, "+++"); builder.append("|+++", this.description.replace("|", "\\|"), "+++");
} }
} }
......
...@@ -86,6 +86,20 @@ class SingleConfigurationTableEntryTests { ...@@ -86,6 +86,20 @@ class SingleConfigurationTableEntryTests {
+ "|+++This is a description.+++" + NEWLINE); + "|+++This is a description.+++" + NEWLINE);
} }
@Test
void descriptionWithPipe() {
ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();
property.setId("spring.test.prop");
property.setDefaultValue("first\\second");
property.setDescription("This is a description with a | pipe.");
property.setType("java.lang.String");
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
AsciidocBuilder builder = new AsciidocBuilder();
entry.write(builder);
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first\\\\second+`" + NEWLINE
+ "|+++This is a description with a \\| pipe.+++" + NEWLINE);
}
@Test @Test
void mapProperty() { void mapProperty() {
ConfigurationMetadataProperty property = new ConfigurationMetadataProperty(); ConfigurationMetadataProperty property = new ConfigurationMetadataProperty();
......
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